0

Code smell "man in the middle" type in Self-Encapsulation refactoring?

Dinosaure 8 months ago updated by Alexander Shvets 8 months ago 0

Hello,
In the page Self Encapsulate Field (refactoring.guru), you advise to create a private getter for private field, to be used inside the private scope of a class.
It looks alot like a "man in the middle", given that the private fields stays read+write accessible, the getter is just an unconvenient way of reading the value.

I get it for a public getter field (Encapsulate Field (refactoring.guru)), but self-encapsulation kinda smells bad, makes the code less readable and harder to maintain.
What's the point?

I'm all open to argument on this topic tho. :)

Regards,
Gweltaz.