Monday, August 25, 2008

No setters, no getters ... return of OO?

core-value.gif Have you also often been wondering what your state-of-the-art enterprise-project has to do with the highly praised object-oriented principles?

Well, you are not alone. I think that's an omnipresent dichotomy in current enterprise development. Object-orientation is generally accepted as the way to go. It get's preached to you at university, you read books about it ... but then reality slaps you you hard in the face:

Welcome in the trenches of enterprise-development where object-orientation usually goes no further than using an object-oriented language!

Domain Driven Design (DDD) promotes the application of true object-orientation to enterprise-systems. But the concrete realization of DDD is often harder than we would think, and requires a lot of design-effort and experience.
Dave Laribee and Keith Braithwaite are now promoting an interesting idea: Promoting object-orientation by not using setters and getters!

The idea is, that by not using setters and getters you are forced to think about classes, responsibilities and collaboration instead of procedures over dumb data structures.

Read the posts for yourself, its an interesting thought (and don't miss the coments):
  • Super Models, Part 2: Avoid Mutators
  • TDD, Mocks and Design


  • The discussion is not new, the topic was already discussed in this article: Why getter and setter methods are evil.

    There is much truth in those articles. I wish those ideas would be more widespread down here in the trenches...

    No comments:

    Post a Comment

    Post a Comment

    Related Posts Plugin for WordPress, Blogger...