Code Smell 163 - Collection in Name

Photo by Mick Haupt on Unsplash

Code Smell 163 - Collection in Name

Have you ever seen a CustomerCollection?

TL;DR: Don't use 'collection' in your name. It is too abstract for concrete concepts.



  1. Rename the collection with a specific name.


Naming is very important.

We need to deal a lot with collections.

Collections are amazing since they don't need nulls to model the absence.

An empty collection is polymorphic with a full collection.

We avoid nulls and IFs.

We often use bad and vague names instead of looking for good names in the MAPPER.

Sample Code


foreach (var customer in customerCollection)
    // iterate with current customer

foreach (var customer in customersCollection)
    // iterate with current customer


foreach (var customer in customers)
    // iterate with current customer


[X] Semi-Automatic

All linters can detect a bad naming like this.

It can also lead to false positives so we must be cautious.


  • Naming


We need to care for all our clean code, variables, classes, and functions.

Accurate names are essential to understand our code.


More Info


Code Smells are just my opinion.


Photo by Mick Haupt on Unsplash

Alzheimer's Law of Programming: Looking at code you wrote more than two weeks ago is like looking at code you are seeing for the first time.

Dan Hurvitz

This article is part of the CodeSmell Series.