代码坏味道

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

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值