# Monday, September 08, 2003

Is Evil T

"Is Evil.." titles are evil. Too excellent articles on Object Oriented Design: Why extends is evil and Why getter and setter methods are evil. Ignore the inflammatory titles: the subheading of the second article, "Make your code more maintainable by avoiding accessors", is a much better indication of their content. I picked up some great tips on proper use of OOP from reading them. In particular, the section on CRC cards made something click which hadn't clicked when I looked at them earlier this year for my ill fated University software project.[Simon Willison's Weblog]

Oh thank goodness. I've never really understood why int get_myProperty() is supposedly any better than public int myProperty. The accessor encapsulates nothing, it was supposed to be OK and good because inlining reduces to a direct value access  - but any change in the value declaration has the same effect with or without the accessor function. I feel better about my code <G> (shhhhhh, I was grateful when someone explained that goto: was acceptable on occasion as well - having been lambasted for its use and going through silly hoops to get rid of it).

Like everything in life really - things can be bad for you if not used in moderation.

#    Comments [0] |
Comments are closed.