Refactor: replace type code with class (c++)
来源:互联网 发布:数据结构英文版 c语言 编辑:程序博客网 时间:2024/05/16 05:36
重构前
class Person {public:static const int A = 0;static const int B = 1;static const int AB = 2;static const int O = 3;Person(int bloodType) {this->bloodType = bloodType;}int getBloodType() {return this->bloodType;}void setBloodType(int bloodType) {this->bloodType = bloodType;}private:int bloodType;};Person zhang(0);Person wang(1);
重构后
class BloodType {public:static BloodType A;static BloodType B;static BloodType AB;static BloodType O;explicit BloodType(int code) {this->_code = code;}private:int _code;};BloodType BloodType::A = BloodType(0);BloodType BloodType::B = BloodType(1);BloodType BloodType::AB = BloodType(2);BloodType BloodType::O = BloodType(3);class PersonRF {public:PersonRF(BloodType btype):bloodType(btype){}BloodType getBloodType() {return this->bloodType;}void setBloodType(BloodType bloodType) {this->bloodType = bloodType;}private:BloodType bloodType;};PersonRF li(BloodType::A);PersonRF zhao(BloodType::B);
0 0
- Refactor: replace type code with class (c++)
- Replace Type Code with Class(以类取代型别码)
- 8.13 replace type code with class(以类取代类型码)
- 重新组织数据之十三 :Replace Type Code with Class(以类取代型别码)
- replace type code with class(重构)用类替换类型码
- 重构手法30:Replace Type Code with Class (以类取代类型码)
- 重构之2.Replace Type Code with Class(以类取代类型码)
- Replace Type Code with Subclasses(以子类取代型别码)
- Code Refactor
- 重构-代替类型代码几中方式的比较(Replace type code with ...)
- 重构-代替类型代码几中方式的比较(Replace type code with ...)
- Replace Type Code with State/Strategy(以State/Strategy取代型别码)
- 8.14 replace type code with subclasses (以子类取代类型码)
- 8.15 replace type code with state/strategy (以state/strategy取代类型码)
- 重构手法31:Replace Type Code with Subclass (以子类取代类型码)
- 重新组织数据之十四 :Replace Type Code with Subclasses(以子类取代型别码)
- 重构之3.Replace Type Code with Subclasses(以子类取代类型码)
- 重构之4.Replace Type Code with State/Strategy(以State/Strategy取代类型码)
- redis 3.0集群安装与配置
- php5.4压缩包版(zip)安装教程
- 如何从HttpServletRequest中获取外网IP地址
- Java 基础知识汇总
- 学习Android的点点滴滴--button click事件处理
- Refactor: replace type code with class (c++)
- mysql性能查看命令1
- 设置字体属性
- Intellij Idea 注释行如何自动缩进?
- 8.Observe the information in the columns:
- tomcat设置环境变量
- 自学知识总结
- RabbitMQ学习(十)之spring整合发送同步消息(注解实现)
- Hadoop单节点