Tag: oop
Traits — Horizontal Reuse (PHP 5.4)
PHP 5.4+
PHP 5.4 traits enable horizontal code reuse — mixins for PHP classes that can't use multiple inheritance. Use sparingly; prefer composition over trait overuse.
2mo ago
php intermediate
Type Widening & Covariance/Contravariance
PHP 7.4+
PHP's rules for overriding method types in subclasses — return types are covariant (can narrow), parameter types are contravariant (can widen), enforced since PHP 7.4.
3mo ago
php advanced
TypeScript Decorators
4.0
1
Metadata annotations on classes, methods, and properties — used in NestJS, Angular, TypeORM, and class-validator to attach behaviour declaratively.
3mo ago
typescript advanced
Tell Don't Ask Principle
PHP 5.0+
Tell objects what to do rather than asking for their state and deciding externally — keep behaviour with the data it operates on.
3mo ago
quality intermediate
Template Method Pattern
Defines the skeleton of an algorithm in a base class, deferring specific steps to subclasses without changing the algorithm's structure.
3mo ago
quality intermediate
Temporary Field
A class field that is only set and used in certain circumstances — most of the time it is empty or null, confusing readers.
3mo ago
quality intermediate
this Binding in JavaScript
ES5
this is determined by how a function is called — call site, not definition site — with arrow functions as the exception (lexical this).
3mo ago
javascript intermediate
Reusable code blocks that can be mixed into any class, providing horizontal code reuse without inheritance.
3mo ago
php intermediate