`

代码坏味道

 
阅读更多

1、代码坏味道

重复代码(Duplicated Code)

Extract Class;

Extract Medhod;

Pull Up Method;

Template Method 设计模式;

 

过长函数(Long Method)

Extract Method

Replace Temp with Query

Introduce Parameter Object、Preserve Whole Object

Replace Method with Method Object

 

Large Class(过大的类)

Extract Class

Extract Subclass

Extract Interface

 

Long Parameter List(过长参数列)

Introduce Parameter Object、Preserve Whole Object

 

Divergent Change(发散式变化)

软件本就该“软”,一旦需要修改,希望直接跳到修改点,只在该处修改不影响其他。

Extract Class

 

Shotgun Surgery(散弹式修改)

Move Method 

Move Field

Inline Class

 

Feature Envy(依恋情结)

Move Method 

Move Field

Extract Class

 

Data Clumps(数据泥团)

Extract Class

Introduce Parameter Object

Preserve Whole Object

 

Primitive Obsession(基本类型偏执)

Replace Data Value with Object

Replace Type Code with Class、Replace Type Code with State/Strategy

 

 

Switch Statements(switch 惊悚现身)

Replace Type Code with Subclasses 

Replace Type code iwth State/strategy

Replace Conditional with Polymorphism

Replace Parameter with explicit Methods

Introduce Null Object

 

Parallel Inheritance Hierarchies(平行继承体系)

Move method

Move field

 

Lazy Class(冗赘类)

Collapse Hierarchy

 

Speculative Generality(夸夸其谈未来性)

Collapse Hierarchy

Inline Class

Rename Method

 

Temporary Field(令人迷惑的字段)

Extract Class

Introduce Null Object

 

Message Chains(过度耦合消息链)

Hide Delegate

 

Middle Man(中间人)

Remove Middle Man

InlineMethod

Replace Delegation with Inheritance

 

Inappropriate Intimacy(狎昵关系)

Move Method

Move Field

Change Bidirectional Association to Unidirectional

Hide Delegate

 

Alternative Classes with Different Interfaces(异曲同工的类)

Rename Method

Extract Superclass

 

Incomplete Library Class(不完美的类库)

Introduce Foreign Method

Introduce Local Extension

Data Class(纯挚的数据类)

Encapsulate Field

Encapsulate Collection

Remove Setting Method

 

Refused Bequest(被拒绝的遗赠)

Push Down Method\

Push Down Field

Replace Inheritance with Delegation

 

Comments(过多的注释)

Rename Method

Extract Class

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics