Practice extract refactoring pattern vocabulary: extract method, extract class, pull up, move method, inline variable, and describing refactoring intent to reviewers.
0 / 12 completed
1 / 12
'I'm applying _____ method to reduce the size of this function.' What refactoring moves code into a new named function?
'Extract method' (Fowler) takes a code fragment and moves it into a new method with a descriptive name, improving readability and enabling reuse.
2 / 12
'We used _____ class to separate these two responsibilities.' What refactoring creates a new class from part of an existing one?
'Extract class' takes a subset of an existing class's responsibilities and moves them into a new class, applying the Single Responsibility Principle.
3 / 12
'_____ up to parent class' moves a method from a subclass to the parent. What is this refactoring called?
'Pull up method' (Fowler) moves a method from one or more subclasses to the parent class, eliminating duplication across subclasses.
4 / 12
'_____ method to another class' — this refactoring is used when a method uses more data from another class than its own.
'Move method' relocates a method to the class it is most coupled to, improving cohesion and reducing inappropriate intimacy between classes.
5 / 12
'I _____ the temporary variable — it was only used once and the expression is clear enough.' What refactoring removes the variable?
'Inline temporary variable' (Fowler) replaces a variable that holds a simple expression with the expression itself, removing unnecessary indirection.
6 / 12
Reviewer: 'This function is getting quite long and complex. I think we should extract a separate method to handle the calculation of the discount.' What refactoring pattern does this comment describe?
The reviewer is suggesting a new method be created from a portion of the existing function. This directly corresponds to the 'Extract Method' refactoring pattern, which aims to improve readability and maintainability by breaking down complex logic into smaller, more manageable units. Incorrect options represent different refactoring strategies.
7 / 12
Developer: 'I've created a new class called `PaymentProcessor` to encapsulate the logic for handling payments. It handles communication with external payment gateways and manages transaction details.' What refactoring technique is being employed here?
The developer created a new class to separate the responsibilities of handling payments. This is precisely what the 'Extract Class' refactoring pattern achieves – separating concerns by creating new classes from existing ones. The other options represent different design patterns with distinct goals.
8 / 12
Reviewer: 'This class is becoming quite complex. It's doing too much – handling user authentication, data validation, and session management all within one place. We should extract a separate AuthenticationService to handle just the authentication logic.' What refactoring pattern does this comment describe?
This describes the 'Extract Class' refactoring. The reviewer is identifying a single class that has too many responsibilities and suggests creating a new, focused class to handle one specific aspect – authentication. This improves modularity and reduces complexity by separating concerns.
9 / 12
Slack message from Alex: 'Just finished refactoring the `OrderValidator` class. I've extracted a new method called `validatePaymentDetails()` – it now just handles checking payment information against our gateway API. The rest of the validation logic remains in the original `OrderValidator`.' What is the primary benefit of this change?
The key here is 'reduced coupling'. By extracting `validatePaymentDetails()` into its own method within the `OrderValidator`, you've separated a specific task. This makes the `OrderValidator` class more focused and less dependent on the details of payment validation, improving maintainability.
10 / 12
During a code review, you see this comment: 'This method does too much – it calculates the discount, validates the user's input, and handles error logging. We should refactor to separate these concerns.' What refactoring approach is being suggested?
This describes the 'Extract Method' refactoring. The comment identifies a method performing multiple distinct tasks and proposes creating separate methods for each task. This improves modularity and makes the code easier to understand and test. Incorrect options involve different separation strategies.
11 / 12
You're reviewing a PR containing a change where a large function is broken down into several smaller functions. The reviewer comments: 'These new methods are more focused and easier to test.' Which refactoring pattern best describes this situation?
This is a classic example of the 'Extract Method' refactoring. Breaking down a large function into smaller, more manageable functions improves code readability and maintainability by reducing complexity and promoting modularity. It's about isolating specific tasks within distinct methods.
12 / 12
In a Slack channel discussing code improvements, Sarah says: 'I've refactored the `UserSession` class. I extracted a new function called `isValidSession()` that checks if the session is still valid and returns true or false.' What type of refactoring does this represent?
This demonstrates the 'Extract Method' pattern. Sarah has identified a specific task – validating session validity – and created a dedicated function to perform that task within the `UserSession` class. This enhances clarity and makes the code more focused on its core responsibility.
What will I practice in "Extract Refactoring Patterns Vocabulary"?
This is a Refactoring Language exercise set. It walks through 12 scenario-based multiple-choice questions built around real usage of refactoring language terminology that IT professionals encounter on the job.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free to complete with no account, sign-up, or paywall.
How many questions are in this exercise?
This set contains 12 questions. Each one shows immediate feedback and a detailed explanation after you answer, so you learn the correct usage right away rather than waiting for a final score.
Do I need prior experience to complete this exercise?
No prior experience is required. Each question includes a full explanation covering the reasoning behind the correct answer, so the exercise itself teaches the refactoring language vocabulary as you go.
Can I retry the exercise if I get questions wrong?
Yes — use the "Try again" button on the results screen to reset your answers and go through all the questions again. There is no limit on attempts.
Is my progress saved?
Your answers and score for the current session are tracked in the browser as you go. No account or login is needed, and there is nothing to install.
What if I don't understand a term used in a question?
Read the explanation shown after you answer each question — it breaks down the correct term in plain English with a real-world example. You can also check the site Glossary for quick definitions.
How is this different from reading a blog article on the topic?
Exercises like this one are interactive drills that test and reinforce specific vocabulary through multiple-choice questions, while blog articles explain concepts in prose. Practising here after reading builds active recall, not just passive recognition.
Where can I find more Refactoring Language exercises?
See the Refactoring Language exercises hub for the full set of related pages, or browse all exercise categories from the main Exercises index.
Can I use this exercise to prepare for a technical interview?
Yes — refactoring language vocabulary comes up often in technical discussions and interviews. Pair this exercise with our dedicated Interview Preparation section for role-specific practice.