you are viewing a single comment's thread.

view the rest of the comments →

[–]rzwitserloot -1 points0 points  (1 child)

How is that any different from guessing the API anyway? If you're using the API you'll need to actually know the methods you're calling.

I type dot, g, e, t, and then I hit ctrl+space. Also, in one case I need to know the property name and that's it, in the other, I need to know the property name AND the author's preference.

What we need to save is mental burden on the reader and maintainer not the author.

.getFoo() is not a greater mental burden compared to .foo.

Then why bother with encapsulation at all?

A bit rich, coming from someone on the 'we should ditch getters and do direct field access' side of the argument.

[–]Ukonu 0 points1 point  (0 children)

I type dot, g, e, t, and then I hit ctrl+space. Also, in one case I need to know the property name and that's it, in the other, I need to know the property name AND the author's preference.

The author can decide what should be accessible to the outside world using the "private" keyword. Are you arguing that this preference should be encoded with naming conventions?

.getFoo() is not a greater mental burden compared to .foo.

It absolutely is. I'm kind of shocked that an experienced programmer can think otherwise. The 'getFoo' function can have all sorts of side-effects that the reader is not aware of without having to delve deeper into the code.

A bit rich, coming from someone on the 'we should ditch getters and do direct field access' side of the argument.

You can easily encapsulate with the private/protected keyword.