クラスのインライン化リファクタリング
このリファクタリングでは、あるクラスを別のクラスにマージすることができます。 マージするクラスは削除され、そのメンバーはマージされたクラスが使用されるクラスに移動され、マージされたクラスのすべての用途がそれに応じて更新されます。
以下の例では、 Painter クラス(つまり、フィールド myColor とメソッド InitPainter )を Circle クラスにマージします。
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 年 6 月 12 日