Is defining get/set methods for every field overkill?

thebluepandabear therealbluepandabear at protonmail.com
Thu Nov 24 04:49:23 UTC 2022


On Wednesday, 23 November 2022 at 13:52:18 UTC, ryuukk_ wrote:
> On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear 
> wrote:
>> I am creating a TUI library and I have a class with the 
>> following constant fields:
>>
>> ```
>> class Label : Renderable {
>>     const string text;
>>     const TextAlignment textAlignment;
> As for the get/set, i almost never use `private`, and i never 
> use getter/setter to just access variables, it's pointless imo
>
> Unless you expect your users to extend/override your types, 
> then it make sense, but i personally prefer composition, as i'm 
> not a fan of OOP

Thanks for the input, I've modified the code since then so that 
`private` isn't used, etc.




More information about the Digitalmars-d-learn mailing list