Introduction Replace Conditional with Polymorphism is a refactoring technique where conditional statements are replaced with polymorphic classes and methods. Polymorphism, a fundamental principle of Object-Oriented Programming (OOP), allows objects of different types to be treated as objects of a common… Read More »Replace Conditional with Polymorphism
“Replace Constructor with Factory Method” is a refactoring technique used in object-oriented programming. This technique involves replacing the direct use of a constructor for object creation with a call to a factory method. A factory method is a method that returns an instance of the class.
Refactoring is a crucial aspect of writing and maintaining clean, efficient code. One of the techniques used in refactoring is the ‘Introduce Local Extension’ method. This article will delve into what this technique is, when it’s used, and provide practical… Read More »Introduce Local Extension
In software development, a “magic number” is a direct usage of a number in the code. These numbers can sometimes be confusing and can lead to difficulties when trying to understand the purpose of the number. In order to improve… Read More »Replace Magic Number with Symbolic Constant
“Replace Exception with Error Code” is a refactoring technique where a method that throws an exception is replaced with a method that returns an error code. This technique is typically used when the cost of exception handling is high, or when the exceptions are used for control flow, which is generally considered a bad practice.
In this post, we learn when to apply this refactoring and its pros and cons.
The Replace Method with Method Object refactoring technique is used to transform a method into a separate class, converting the method parameters into its fields, and allowing the method to be broken down into multiple methods within that new class.
Introduction “Remove Assignments to Parameters” is a type of refactoring that deals with eliminating assignments to the parameters of a method. The general rule of thumb is that parameters should be treated as constants, not variables that can be changed.… Read More »Remove Assignments to Parameters
Refactoring is a process of altering the structure of the existing code without changing its external behavior. Among the several refactoring techniques, one of the most effective and useful is the Introduce Parameter Object refactoring technique. This technique comes handy… Read More »Introduce Parameter Object
Refactoring code involves altering the structure of code to make it more understandable and maintainable without changing its observable behavior. One such strategy of refactoring is known as “Replace Temp with Query”. What is Replace Temp with Query? Replace Temp… Read More »Replace Temp with Query