-
Notifications
You must be signed in to change notification settings - Fork 6
10장 ISP:인터페이스 분리 원칙
Jaeyoung Heo edited this page Feb 2, 2022
·
2 revisions
자유롭게 작성 해 주세요.
재영
- 필요 이상을 많은 걸 포함하는 모듈에 의존하면 해롭다.
# Bad
class Vehicle:
def start():
pass
def stop():
pass
def fly():
pass
class Car(Vehicle):
def start():
sth_1()
def stop():
sth_2():
def fly():
# no implementation
class Plane(Vehicle):
def start():
# no implementation
def stop():
# no implementation
def fly():
sth()
# Better
class Vehicle:
pass
class Movable:
def start():
pass
def stop():
pass
class Flyable:
def fly():
pass
class Car(Movable, Vehicle):
def start():
sth_1()
def stop():
sth_2()
class Plane(Flyable, Vehicle):
def fly():
sth()