Posts
Code Smell: Large Class
This post examines why overly large classes make code harder to understand, maintain, and test. It outlines strategies for splitting classes, creating subclasses, or defining interfaces to clarify responsibilities. Refactoring in this way promotes better design, easier testing, and greater code reuse.
Avoiding Unnecessary Null Checks
Null checks are a common source of bugs and clutter in code. This article explores ways to avoid returning or passing nulls, including using the Null Object pattern, throwing exceptions, and designing objects that encapsulate behavior. By eliminating nulls, you simplify code, reduce errors, and encourage cleaner design.
Misconceptions About Code Reuse
Reusing code is important, but inheritance and static utility classes are often misapplied. Inheritance should focus on modeling hierarchies, not sharing methods, while utility classes can violate object-oriented principles. This article explains how to use composition and meaningful class responsibilities to create cleaner, more flexible, and maintainable code.
How to Prevent Legacy Code From Emerging
Legacy code does not appear out of nowhere. It often grows from small shortcuts, missing tests, and neglected refactoring. This article explains how developers unintentionally create messy, unmaintainable code and offers practical strategies to prevent it. By maintaining code, refactoring while adding features, and writing tests, you can keep your codebase clean and easier to work with over time.
Code Smell: Code comments
This post argues that frequent or explanatory comments often indicate overly complex implementation. Instead of relying on comments, developers should simplify structure, clarify intent through naming, and break down complex logic. It also outlines when comments remain appropriate and valuable.
Code Smell: Primitive Obsession
This post explains how overusing primitive data types to model domain concepts can weaken structure and create hidden complexity. It outlines strategies to replace grouped data with dedicated objects, strengthen typing, and reduce repetition. Refactoring in this way improves clarity, keeps related behavior together, and makes the system easier to maintain.
Code Smell: Switch Statements
This post explores how scattered and duplicated conditional logic increases maintenance effort and risk when requirements change. It shows how reorganizing behavior around dedicated types reduces repetition and makes introducing new variations more straightforward. The result is a design that is easier to extend without repeatedly modifying existing logic.
Code Smell: Long method
This post explores why long methods reduce readability and make understanding code harder. It outlines strategies for breaking large methods into smaller, self-explanatory units, including extracting methods, using parameter objects, and decomposing conditionals. Refactoring in this way improves clarity, maintainability, and can uncover hidden duplication.
Code Smell: Long Parameter List
This post explores how methods with many parameters can reduce readability and increase confusion. It outlines practical strategies to simplify calls, such as grouping related data or replacing parameters with explicit methods. Refactoring in this way improves clarity and can also reveal hidden duplication.