Is defining get/set methods for every field overkill?


Sat Nov 19 22:12:17 UTC 2022


On Saturday, 19 November 2022 at 19:54:59 UTC, Ali Çehreli wrote:
> On 11/19/22 01:05, [] () {} () wrote:
>
> > All this because some programmer wanted to save a few key
> strokes, or
> > did not anticipate change, or did not anticipate the need to
> ensure data
> > is valid before assigning it, or returning it.
> >
> > So no. It's not overkill. It's called software engineering.
>
> I disagree. Engineering is about applying different solutions 
> to different problems. Blindly following guidelines whether it 
> is fit for purpose would be dogmatic, not pragmatic.
>
> Ali

Neither I, nor anyone in my team blindly follows anything, or 
anyone ;-)

What goes on inside an object, is the responsibilty of that 
object.

That's a guideline (i.e. encapsulation) that we accept as being 
an important principle in software *engineering*, for us, and for 
all of the reasons I've mentioned, and so we implement and follow 
it.

Not having that encapsulation would (and has) create major 
problems for us, and our customers.

Again, if you and/or your team have discovered something 
different (i.e. encapsulation is not that important afterall), 
then that's great, for you. But it wouldn't be great for us, or 
our customers, that much I do know.



More information about the Digitalmars-d-learn mailing list