Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As a C# developer I urge caution. When getters and setters become as trivial as

public int Age { get; set; }

Code becomes less OO and more procedural filled with anaemic models / bags of state. Practices like Tell don't Ask, Information Hiding and Rich Models, slip away.



> Code becomes less OO

Frankly...good. If there is one thing Java desperately needs, it's less OO code.


Accessor messages in Smalltalk, a pure Object-Oriented Programming environment, have been that trivial for a long time. See: http://www.jmcsweeney.co.uk/computing/m206/accessors.php

The issue, as I see it, isn't the ease of creating accessors; the issue is that students do not seem to learn about the practices you've mentioned.

I demonstrate "Tell, Don't Ask", "Information Hiding", and "Encapsulation" in the following presentation:

http://whitemagicsoftware.com/encapsulation.pdf


Very very valid points, in my experience.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: