Replace Constructor Dialog Box
See Also
Use this dialog box to replace a public constructor with a factory method. You can use the Refactor command to introduce a new static factory method that calls the constructor and replaces existing calls to the constructor with calls to the new factory method.
- After replacing a public constructor with a factory method, the constructor is made private.
The Replace Constructor dialog box appears after you have chosen the Refactor > Replace Constructor with Factory command while having a constructor selected in the Source Editor.
The Replace Constructor dialog box has the following field:
- Factory Method Name. Contains the name of the new factory method to be applied.
Specify the new name of the method by modifying this field.
Unless you click Refactor, you need to follow these steps
to complete the refactoring:
- Click Preview.
The Refactoring
window opens and displays a tree view of the code to be affected by the refactoring.
- Check the items displayed in the Refactoring window to make sure that you want them
all changed. Clear the checkbox next to any parts of the code that
you do not want changed.
- Click Refactor.
- You should always perform a clean build after completing
any refactoring commands. You can do a clean build by right-clicking the project's
node in the Projects window and choosing Clean and Build Project.
- See Also
- Refactoring: Quick Reference
- Replace Constructor With Builder Dialog Box
- Undoing Refactoring Changes
Legal Notices