Skip to content

Commit d747e01

Browse files
committed
Update read me
1 parent 4f07743 commit d747e01

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ To accumulate the data of similar properties and methods together.
7373

7474
By creating a new object we add this new instance, or any future instance, to a particular bundle. That bundle is called a `class`. If we have the same set of objects with similar attributes and functionalities we should create a class. Also, class supports inheritance. With classes we can reuse our codes or the codes written by other programmers. (Packages, modules and frameworks)
7575

76+
With proper implementation of classes, in theories, we achieve:
77+
78+
- Separation of concerns
79+
80+
- Decoupling
81+
82+
- Encapsulation
83+
84+
- Implementation hiding
85+
86+
- Inheritance
87+
7688
---
7789

7890
## Naming a class
@@ -375,4 +387,8 @@ Reduce the complexity of the code.
375387

376388
---
377389

390+
To avoid the temptation of writing classes for every problem at hand, and everywhere we like do watch this vice. [Stop writing classes](https://www.youtube.com/watch?v=o9pEzgHorH0)
391+
392+
---
393+
378394
This tutorial is still under development. If you find any spelling, grammatical or syntax error, convey it through raising issues. There may be other concept related mistakes, if you found any please raise issue, or discuss.

examples/4_1_car_class.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1+
'''📝 Python Class Tutorial: Best practice to choose variables in __init__ method.
2+
3+
✨ Example of a car class. Things to be required
4+
'''
5+
6+
17
class Car:
8+
"""A car class to associate all the models of a car company."""
29
MAKE = "TATA Motors"
310
year = 2022
411

512
def __init__(self, model, color, speed):
13+
"""Constructor of Car class with model, color and speed.
14+
15+
Args:
16+
model (_type_): _description_
17+
color (_type_): _description_
18+
speed (_type_): _description_
19+
"""
620
self.model = model
721
self.color = color
822
self.speed = speed

0 commit comments

Comments
 (0)