Tag: oop
Structural Subtyping with Protocol
Python 3.8+
Protocol classes define structural interfaces — any class with matching methods satisfies the protocol without explicit inheritance (type-safe duck typing).
3mo ago
python intermediate
Singleton (Anti-Pattern)
A class that restricts instantiation to a single instance — widely considered an anti-pattern due to hidden global state and testability issues.
3mo ago
general intermediate
Specification Pattern
PHP 5.0+
Encapsulating business rules as composable objects that evaluate whether a candidate satisfies them — separating rules from entity code.
3mo ago
architecture intermediate
State Pattern
PHP 5.0+
Encapsulates the varying behaviour of an object based on its internal state into separate state objects, eliminating state-based conditionals.
3mo ago
quality intermediate
Static Methods & Properties
PHP 5.0+
Class-level methods and properties that exist independently of any instance — useful for utilities and factories, but harmful when overused.
3mo ago
php intermediate
Strategy Pattern
PHP 5.0+
Defines a family of interchangeable algorithms behind a common interface, allowing the algorithm to be selected at runtime.
3mo ago
general intermediate
Switch Statement Smell
Repeated switch/if-elseif chains on the same type indicator signal a missing polymorphic design.
3mo ago
quality intermediate
Single Responsibility Principle
PHP 5.0+
A class or function should have one reason to change — doing one thing and doing it well.
3mo ago
general beginner
SOLID Principles (Overview)
PHP 5.0+
Five object-oriented design principles — SRP, OCP, LSP, ISP, DIP — that together guide towards maintainable, extensible code.
3mo ago
quality intermediate