Getters and Setters are used to add validation logic around getting and setting a value. To avoid direct access of a class field i.e. private variables cannot be accessed directly or modified by external user.
Class inheritance is the capability of one class to derive or inherit the properties from some another class. The benefits of inheritance are: It represents real-world relationships well. It provides re-usability of a code. We don’t have to write the same code again and again. Also, it allows us to add more features to a class without modifying it. It is transitive in nature, which means that if class B inherits from another class A, then all the sub-classes of B would automatically inherit from class A
Unified Modeling Language, is a standardized modeling language consisting of an integrated set of diagrams, developed to help system and software developers for specifying, visualizing, constructing, and documenting the artifacts of software system
More topics covered:
- Data Encapsulation
- Decorator ( @ )
- @property – getter
- @.setter – setter
- Setter avoid crash using None in __init__ method
- dir ( class ) – will show all of the properties and functions
- class <name> ( <class-inherit-from> ) …
- all classes derive from object
- override functions
- Method Resolution Order (MRO) – the order of seeking a method
- help ( class ) – will print the info of this class and the MRO
- adding ”’…”’ comment will appear in the help output
- Polymorpyhism
- isinstnace, issubclass
- super ( )
- <super-class-name>.__init__ (self)
- __init__ calling super ( )
- __str_ calling super ( )
Links:
