Hardcoded parts
CONSTANTS Have you ever saw something like that? We have a few code smells here. I’ve discussed some of them in other articles, such as nested ‘if’ statements and unclear intentions of those conditions. What else should be done to improve it? The answer is: avoid hard-coded definitions of...
Dependency Injection code smells
The use of injection does not automatically ensure that our code is correctly structured. While it’s an excellent mechanism for breaking dependencies and writing decoupled code, improper usage can introduce chaos into our system. There are certain code smells that, when detected, should alert you to potential design flaws...
Improving conditions clauses- few small things with hudge impact
It’s fascinating how very small changes can improve code readability. Below, you can find some examples often found in the code of inexperienced programmers. Conditional operators: Lets say that we have a condition that looks like in this example: What is wrong with this code? The intention behind the...
Refactoring Example – guard clauses
I believe the most effective way to learn is through hands-on experience with real-world cases. Below, I will discuss a case study from one of our actual projects, focusing on how we managed the refactoring of a specific section of legacy code. Please note that this article won’t delve...
Static Factory Methods aka Named Constructors
How to Handle Method Overloading in PHP and Create a Single Object Instance with Multiple Conditions? The Static Factory Method is Your Solution....