Search code examples
c++variablesnaming-conventionsvariable-names

class name suggestions for a class full of containers


I have a class as follows

class Package
{
    list<string> targetList;
    list<string> excludedList;
    map<string, string> mapping;
};

I will be using data structures of type, Package, contained within several other classes which might require to compute further information based on this input Package P

For example, a handler which has an instance P of Package, might need to do targetList = targetList - {targetList ^ excludedList} and after subtracting the intersection it might map every targetList string to a new string w.r.t mapping.

With names like Package, Input, InputCollection, Collection someone else reading my code won't be able to understand what it might contain. I'm looking for nice name suggestions, as getting the rightvariable name seems self-documenting.


Solution

  • I would say this highly depends on your problem domain and cannot be answered without the context.

    You should ask yourself whether it is a general purpose library providing an algorithm or if it is solving a specific problem of your domain?

    Be as specific to your domain or algorithm as possible.

    Maybe this is helping you: http://www.itiseezee.com/?p=83

    Just to take out one rule of thumb:

    Readers should not need to mentally translate your names into other names they already know/are familiar with. This problem generally arises from a choice to use NEITHER problem-domain terms nor solution-domain terms (see more, below, on problem-domain and solution-domain).