Is there any reason to use "plain old data" classes?
Posted
by
Michael
on Programmers
See other posts from Programmers
or by Michael
Published on 2010-12-27T14:35:37Z
Indexed on
2010/12/27
15:59 UTC
Read the original article
Hit count: 412
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?
© Programmers or respective owner