Extract Classとは大きなクラスの一部を切り出して小さなクラスを作成することです。
そうすることによって、クラスを適度な大きさで意味のあるかたまりに分割することができ、またその固まりにクラス名として名前をつけることができます。
将来のクラスの再利用性も向上します。
リファクタリング前:
public class AirTicket
{
public DateTime FlightDateTime;
public string FlightNumber;
public string Price;
//このプロパティをCustomerクラスとして抽出する
public string CustomersName;
public string CustomersMileageAccountId;
public string CustomersTel;
}
リファクタリング後:
public class AirTicket
{
public DateTime FlightDateTime;
public string FlightNumber;
public string Price;
public Customer Customer;
}
public class Customer
{
public string CustomersName;
public string CustomersMileageAccountId;
public string CustomersTel;
}
|
Copyright(c) 2012 WoodenSoldier Software |