Skilled Coder
Dec 23, 2024

--

Yes, it's not always the best, but in this context, it is better than exposing fields directly. Using getters/setters provides flexibility for future changes (like validation) without breaking all the callers, which direct field access would do.

--

--

Skilled Coder
Skilled Coder

Written by Skilled Coder

Sharing content and inspiration on programming. Coding Newsletter : https://skilledcoder.substack.com

Responses (2)