Skip to content

Commit 978cf65

Browse files
Update Lecture2.md
1 parent 85cda8d commit 978cf65

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tutorials/Lecture2.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Each method is shown with its visibility, name, parameters, and return type.
6060
## Overriding Polymorphism
6161

6262
**Polymorphism means “many forms.”**
63+
6364
Overriding is when a child (subclass) provides a new implementation for a method that it inherits from its parent (superclass).
6465

6566
The child class method has the same name and parameters as the method in the parent class. When you call the method on a child class object, Python (or any OOP language) uses the child’s version—even if the object is referenced by the parent type.
@@ -107,6 +108,14 @@ while True:
107108
sleep(1)
108109
```
109110

111+
## DRY
112+
The DRY pattern stands for "**Don't Repeat Yourself**"; it is a fundamental principle of programming aimed at reducing repetition of code and logic. This is to avoid duplicating code, logic, or data.
113+
114+
### Why Use DRY?
115+
- Maintainability: When logic is defined in only one place, updates or bug fixes are only needed once.
116+
- Readability: The code is easier to read and understand because there is less repetition.
117+
- Consistency: Reduces the risk of inconsistencies and errors that can occur when updating duplicated code in multiple places.
118+
110119
## Overloading Polymorphism
111120

112121
**Polymorphism means “many forms.”**

0 commit comments

Comments
 (0)