RAD Studio (Common)
ContentsIndex
PreviousUpNext
Extract Method Overview (Delphi)

Use the Extract Method refactoring operation to change a code fragment into a method whose name describes the purpose of the method. The Extract Method feature analyzes any highlighted code. If that code is not extractable to a method, the refactoring engine warns you. If the method can be refactored, the refactoring engine creates a new method outside of the current method. The refactoring engine then determines any parameters, generates local variables, determines the return type, and prompts the user for a new name. The refactoring engine inserts a method call to the new method in the location of the old method. 

There are certain limitations to the extract method refactoring. They include:

  • Cannot extract expressions, only statements.
  • Cannot extract statements that include a call to inherited in Delphi.
  • Cannot extract statements that are contained within a with statement.
  • Cannot extract statements that call a local procedure or function.
If you select an expression and choose the Extract Method command, your selection will be expanded to include the entire statement. If the expression in your statement is used as a result, the extracted code returns a function result in place of the expression.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!