 {
SuperVip,
Vip,
Normal
}

class Customer
  {
public Customer(string name, CustomerKind kind)
 {
m_Name = name;
m_Kind = kind;
}

private string m_Name;
public string Name
 {
 get { return m_Name; }
}

private CustomerKind m_Kind;
public CustomerKind Kind
 {
 get { return m_Kind; }
}

public override string ToString()
 {
return "Name: " + m_Name + "[" + m_Kind.ToString() + "]";
}
}
- 然而,当这种结合使用枚举和条件判断的代码阻碍了你进行更灵活的扩展,并有可能导致日后的维护成本增加,你可以代之以多态,使用Replace Conditional with Polymorphism来对代码进行重构。
上一页 [1] [2] [3] [4] 下一页 |