Extract Method
noun
say it: “ik-STRAKT METH-ud” /ɪkˈstrækt ˈmɛθəd/
A refactoring that moves a few lines into a new method of their own, named for what they do.
What is the Extract Method refactoring?
Extract Method (often said "pull out a method") is the refactoring that moves a few lines into a method of their own, named for what they do. It doesn't change what the code does, only its shape. It cures more code smells than any pattern, because most smells are a job without a name, and a method is the smallest home a job can have: a comment that explains the next lines is often the new method's name.
In a sentence
- “One extract method turned the comment "work out the price" into a method the new button could call.”
Level: Apprentice · More Software Development terms at this level
Updated