← CodeClarityLab Home
Browse by Category
+ added · updated 7d
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Code Readability Metrics
Readability can be measured — cyclomatic complexity, cognitive complexity (SonarQube), lines per function, parameter count, and nesting depth are all quantifiable proxies for readability.
2mo ago quality intermediate
Extract Class Refactoring
Extract Class splits a large class into two — moving a cohesive subset of fields and methods into a new class that the original delegates to.
2mo ago quality intermediate
IoC Container PHP 7.0+
An Inversion of Control container automatically resolves and injects class dependencies — you declare what a class needs, the container figures out how to create it, eliminating manual dependency wiring.
2mo ago quality intermediate
Method Chaining Pitfalls & Alternatives
Method chaining (fluent interfaces) improves readability for builders but creates debugging difficulties, encourages temporal coupling, and can hide null returns.
2mo ago quality intermediate
Reducing Cyclomatic Complexity Techniques
Cyclomatic complexity counts independent code paths — reduce it by early returns, extracting conditions to named functions, using lookup tables, and replacing switch/if chains with polymorphism.
2mo ago quality intermediate
Refactoring Boolean Flag Parameters
Boolean flags as function parameters obscure intent — replace with enums, separate functions, or named options objects for self-documenting APIs.
2mo ago quality intermediate
Types of Code Duplication (Clone vs Semantic)
Not all duplication is equal — clone duplication (copy-paste) always warrants extraction, but semantic duplication (similar logic, different context) may be acceptable.
2mo ago quality intermediate
Abstract Factory Pattern PHP 5.0+
Creates families of related objects ensuring they are used together consistently without mixing implementations.
2mo ago quality intermediate
Active Record Pattern PHP 5.0+
A design pattern where a database row is wrapped in an object that includes both the data and the persistence logic — the object knows how to save, update, and delete itself.
2mo ago quality intermediate
Dead Condition PHP 5.0+
A boolean condition that is always true or always false due to logic errors, making the branch either always execute or never execute.
2mo ago quality intermediate
Fluent Builder Pattern
Returns $this from each setter enabling method chaining — used in query builders, test factories, and configuration objects.
2mo ago quality intermediate
Gateway Pattern
A class that encapsulates access to an external system or resource — wrapping HTTP APIs, queues, or legacy systems behind a clean interface that the rest of the application uses.
2mo ago quality intermediate
Global Variable Abuse PHP 5.0+
Using global variables or the global keyword to share state between functions — making code unpredictable, untestable, and impossible to reason about.
2mo ago quality intermediate
Low Cohesion
A class or module that does many unrelated things — high coupling's counterpart, making code hard to understand, test, and reuse.
2mo ago quality intermediate
Memento Pattern PHP 5.0+
A behavioural pattern that captures an object's internal state and stores it externally so it can be restored later — enabling undo, snapshots, and versioning without exposing internals.
2mo ago quality intermediate
Prototype Pattern PHP 5.0+
Creating new objects by cloning a prototype — fast when object creation is expensive and variations are needed.
2mo ago quality intermediate
Table Module Pattern
One class per database table handling all logic — a pragmatic middle ground between Transaction Script and full Domain Model.
2mo ago quality intermediate
Transaction Script Pattern
A pattern where each business operation is a single procedure — simple, linear, and appropriate for straightforward workflows without complex domain logic.
2mo ago quality intermediate
Diagram: Builder Pattern Builder Pattern PHP 5.0+
Constructs complex objects step-by-step using a fluent interface, separating construction from representation.
2mo ago quality intermediate
Diagram: Chain of Responsibility Pattern Chain of Responsibility Pattern PHP 5.0+
Passes a request along a chain of handlers, each deciding whether to process it or pass it to the next handler.
2mo ago quality intermediate
✓ schema.org compliant