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

Been writing code for almost 20 years and never found the get/set paradigm useful. I’m fact it’s introduced a lot of incidental complexity when I tried it. Objects and functions to transform objects immutably to the extent possible are much better imo. I don’t use Classes anymore unless they’re static.


Immutability is nice when you have it, however the languages and paradigms you speak of I imagine the OP would also complain are "clever code".

Otherwise it's not a "paradigm", simply having mutable state means you will want to retrieve and modify state on a part of an object/struct/array, in this case the alternative is "plain" getter/setter methods, however these are not guaranteed to even be named the same much less be in a similar area of code. Get/Set properties have two objective advantages that setter methods and raw properties do not. 1. They are always named the same, and thus you can always find them. 2. They are debuggable, where a plain property is not, which is very useful for widely modified properties.

You of course can feel what you like about using them, however I posit them as a fairly neutral example of language evolution where things got objectively better over time, where there are many "stupid", specifically looking at Java, conventions which were/are needlessly enforced for reasons not to do with code clarity at all but rather old people being set in their religious ruts.

There are many, many examples which are much more controversial, but I think it is also illustrative that something as dirt simple as setting or getting a variable can have such illogical and emotional reaction from a wide range of individuals, making up nonsense about how they know the best way of doing things, and claiming things about "young" developers.




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

Search: