Erik Engheim
1 min readSep 3, 2020

--

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.

--

--

Erik Engheim
Erik Engheim

Written by Erik Engheim

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

No responses yet