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

> why not make them public in the first place?

Because in future I may want to add some validation there, or processing, like sending events on set of a value, etc.

Properties in C# was a genius move that solves it correctly.



Unless we are talking about API, then you add getter and setter. You might even be able to refactor all callers automatically via IDE. I mean, I dont mind getters and setters in java, it is standard at this point.

But origin of it is in EJB specification, it is not something that would be interently needed elsewhere. It just "feels wrong" to programmers (including me) at this point.


That, in my observation, almost never happens.


I'm working in a product that is about 10 years old and 4 months ago it went through a quite a big project which purpose was to add extended auditing to be more enterprise friendly. The system was flooded with auditing events on various changes into internal data. The system provides a public API and allows to install plugins. If we had to change our entities that would be a compatibility nightmare for thousands of plugin vendors.




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

Search: