Should you use getters and setters within a class?

Getters and setters are mandatory for others classes to access instance variables of a class to not violate the encapsulation principle (which is quite important in OO programming). In the end it’s a matter of choice, but you’re saving one method call using your first example.

Sizin İçin Seçtik  What is late variable in Flutter?

Leave a Reply

Your email address will not be published. Required fields are marked *