クラスのインライン化リファクタリング
このリファクタリングでは、あるクラスを別のクラスにマージすることができます。 マージするクラスは削除され、そのメンバーはマージされたクラスが使用されるクラスに移動され、マージされたクラスのすべての用途がそれに応じて更新されます。
以下の例では、 ペインター クラス(つまり、フィールド 自分の色 とメソッド ペインターを初期化 )を 円 クラスにマージします。
class Painter
{
private Color myColor;
public Painter(Color c)
{
myColor = c;
InitPainter(myColor);
}
private void InitPainter(Color color)
{
//init painter
}
}
class Circle
{
private Painter myPainter;
public Circle(Color c)
{
myPainter = new Painter(c);
}
}
class Circle
{
private Color myColor;
public Circle(Color c)
{
myColor = c;
InitPainter(myColor);
}
private void InitPainter(Color color)
{
//init painter
}
}
クラスをインライン化する
リファクタリングを適用した後、プロパティまたはフィールドはその型のメンバーに置き換えられます。 プロパティまたはフィールドのすべての用途はそれに応じて更新されます。
2026 年 11 月 6 日