Telerik® JustCode™ by Progress

The Convert Constructor To Factory Method refactoring allows you to easily convert a constructor to a factory method.

Note

Language Support

Supported: C#, VB.NET

Not relevant: JavaScript, ASP.NET,XAML, HTML

To convert a constructor to a factory method

  1. Select the name of the constructor you want to convert.

    Convert Constructor To Factory Method Selected
  2. Press Alt+Insert. From the pop-up menu select Convert Constructor To Factory Method.

  3. Telerik® JustCode™ will generate the factory method and make the constructor private. All usages of the constructor will be replaced with the factory method.

  4. The result is:

    Convert Constructor To Factory Method Result
Tip

To convert a constructor to a factory method you can also navigate on the main menu. Choose JustCode | Refactor | Convert Constructor To Factory Method.