As soon as one of these programmers introduces a new attribute, he or she will make it a private variable and creates "automatically" a getter and a setter for this attribute. Unfortunately, it is widespread belief that a proper Python class should encapsulate private attributes by using getters and setters. According to this principle, the attributes of a class are made private to hide and protect them. These methods are of course the getter for retrieving the data and the setter for changing the data. Data encapsulation - as we have learnt in our introduction on Object Oriented Programming of our tutorial - is seen as the bundling of data with the methods that operate on them. 'mutators') are used in many object oriented programming languages to ensure the principle of data encapsulation. Getters(also known as 'accessors') and setters (aka.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |