On Wednesday, 12 December 2018 at 20:12:54 UTC, Guillaume Piolat wrote:
On Wednesday, 12 December 2018 at 14:48:23 UTC, Atila Neves wrote:
On Tuesday, 11 December 2018 at 14:00:10 UTC, dayllenger wrote:
On Tuesday, 11 December 2018 at 13:42:03 UTC, Guillaume Piolat wrote:
One could say getters and particularly setters don't really deserve a nicer way to write them. It's a code stink, it deserve a long ugly name. (10 years ago I would be in the other camp)

Can you please explain it in more detail? I never read such about getters and setters.

Tell, don't ask: https://martinfowler.com/bliki/TellDontAsk.html

Sometimes formulated slightly differently as "Law of Demeter" https://en.wikipedia.org/wiki/Law_of_Demeter

if you like more pompous names.

Law of Demeter is different. Law of Demeter basically translates to "don't have more than one dot", like x.y() is fine, x.y.z() isn't because it makes too many assumptions about internals of x and y.

Properties have use when the setting or getting the variable isn't a trivial assignment. For example, sometimes the units need to be converted along the way. In many cases, especially when GUI programming, you might want to do additional actions when settings/getting a variable, like calling listeners to notify them of the value change so that they can change the value in the GUI widget automatically.

Reply via email to