Wednesday, September 12, 2007

'Class names in Plural' smell

Just ran into a piece of code where somebody was using a class that was in plural, like for example Computers. Well, that smells. If you have a collection/list/bag/set/whatever of computers, then use the appropriate collection class. Since this was not the case probably more is going on. This is a collection of items with a certain characteristic that they share. Probably a bunch of computers forming a domain with additional properties that rise above the collection level. I'm arguing that you should use a class name that reflects the item(s) in common - most likely in singular.

No comments: