类
Python中,类的命名使用帕斯卡命名方式,即首字母大写。
Python中定义类的方式如下:
class 类名([父类名[,父类名[,...]]]):
pass
省略父类名表示该类直接继承自object,类的实例化如下:
class Person():
def __ini...
文章雪飞鸿
2016-11-03
894浏览量
重构——32以State/Strategy取代类型码(Replace Type Code with State/Strategy)
以State/Strategy取代类型码(Replace Type Code with State/Strategy)
你有一个类型码,它会影响到类的行为,但是你无法通过继承手法消除它;以状态对象取代类型码
一、动机
本项重构与Replace Type Code with Subclass很相似,...