You got to just use your head. For many simple data structures it is obvious that the public fields will never change. E.g. for something like a point, vector etc the fields will never change. These are known and well understood concepts we have used for decades.

And even if you make a mistake in this, it really doesn’t matter. A modern IDE can trivially refactor a direct field access into using a getter or setter function.

And for plenty of languages you don’t even need a refactoring because the syntax for setting and getting a property and public field is identical. Swift, Ruby, Python, Lua and Julia all work like that.

There really is no need to prematurely create setters and getters other than for the cases I have listed in my article.

Geek dad, living in Oslo, Norway with passion for UX, Julia programming, science, teaching, reading and writing.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store