private and providing access methods (getters and setters) to manipulate it. This technique helps improve data access encapsulation, control, and consistency.
parameters are being passed repeatedly to a method or function. This technique involves creating a new object that encapsulates these related parameters, simplifying the method call and improving code readability.
two or more distinct phases or different types of tasks. This technique involves separating these phases into separate methods or functions, to improve the readability, modularity and maintainability of the code.
tasks that are being performed in a single method or function. You then extract each phase into a separate method or function, allowing each to be more focused and specific in its responsibility.
functionality that can be better organized in a new, separate class. This technique involves creating a new class and transferring related attributes and methods to this new class.
an unnecessary intermediary between other classes. This technique involves eliminating the middleman, allowing method calls to be made directly between the relevant classes.
access to a delegate object and that direct access is being overused or violating the principle of encapsulation. This technique involves hiding the delegate object behind methods of the class that encapsulate it, limiting direct access to the delegate.
located in a class that is not the most appropriate to house it. This technique involves moving the function to another class that has a more appropriate responsibility or where the function can be more easily reused.
code that are no longer used and have no impact on the operation of the program. This technique involves removing these unnecessary code snippets, simplifying and making the code cleaner and more readable.
object that is used as a value, but you realize that you need to treat it as an object with its own identity. This technique involves replacing the value representation with a reference representation, allowing multiple objects to refer to the same instance.
with multiple branches and the logic becomes difficult to understand and maintain. This technique involves decomposing the condition into smaller, clearer parts, making the code easier to understand and maintain.
detect and capture errors or invalid states during development and debugging. This technique involves inserting assertions to validate conditions that must be true at certain points in the code.
a class with one or more constructors that can be overridden by a factory function. This technique involves creating a static function that encapsulates object creation, providing a more expressive and flexible interface for creating instances of the class.
in subclasses and want to move them to the superclass to avoid code duplication and promote reuse. This technique involves moving a method from one or more subclasses to the parent class, making it a common method that can be shared by all subclasses.
is performing functionality that is specific to a subset of objects in that class. This technique involves creating a new subclass that represents this specific subset of objects and moving the relevant functionality to this new subclass.
classes where differentiation between subclasses becomes unnecessary or irrelevant. This technique involves removing one or more intermediate subclasses, moving their attributes and behaviors directly to the parent class.