When should I make property functions?
Atila Neves
atila.neves at gmail.com
Tue Nov 20 13:00:24 UTC 2018
On Monday, 19 November 2018 at 20:11:11 UTC, Trent Caprico wrote:
> In Java, it is considered best to always make all member
> variables private, and make getters/setters for the 'public'
> members.
>
> In D, should I create @property functions for all 'public'
> fields when I first define the class, or is it best to wait
> until a property function is actually needed?
I consider getters a code smell and setters a code stink.
Sometimes they're needed, but one should never be happy about
using them.
Tell, don't ask: https://martinfowler.com/bliki/TellDontAsk.html
The more the class/struct clients know about the internals, the
greater the coupling and that's never a good thing.
More information about the Digitalmars-d
mailing list