Is there any reason to use "container" classes?
- by Michael
I realize the term "container" is misleading in this context - if anyone can think of a better term please edit it in.
In legacy code I occasionally see classes that are nothing but wrappers for data. something like:
class Bottle {
int height;
int diameter;
Cap capType;
getters/setters, maybe a constructor
}
My understanding of OO is that classes are structures for data and the methods of operating on that data. This seems to preclude objects of this type. To me they are nothing more than structs and kind of defeat the purpose of OO. I don't think it's necessarily evil, though it may be a code smell.
Is there a case where such objects would be necessary? If this is used often, does it make the design suspect?