Lesson-10 (Supp) | Naming Conventions for Getters and Setters | [OOP in Python]

Опубликовано: 14 Октябрь 2024
на канале: Learning Orbis
1,799
33

This is a supplementary lesson for Lesson number 10 of the lesson series on Object Oriented Programming (OOP) in Python. It will be a complete course with the aim is to cover almost everything needed in Object Oriented Programming.

In lesson 10 we covered Getters and Setter. There are a few naming conventions for these methods that can be confusing for beginner. So this lesson focuses on those conventions for better understanding.


Link to complete playlist:
   • Object-Oriented Programming in Python  


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Review Questions of the Lesson
1- To avoid recursion, the method (Getter or Setter) name should be different from the attribute being returned or set. By convention we use single leading underscore with attribute being set and returned to make it different. Can we use double underscores instead of single (keeping in mind the underscore conventions for Data Encapsulation)?

2- What if someone decides to use single underscore with method (both getter and setter) and not with the attribute names being returned or set? The condition of those being different will satisfy and there will not be recursion. But what will be the overall effect in terms of using that attribute?


#OOP #ObjectOrientedProgramming #Python