PHP, Value Objects and You 🫵
summary
Claims that value objects make PHP code more expressive and less buggy with concrete patterns: prefer the constructor and immutability over mutable setters, prefer immutable instances that spawn new instances for changes, prefer self‑validating creation and named static factories for conversions (RGB↔HEX↔HSV), and prefer aggregating objects so color interpolation lives on a color range instead of a ColorUtils class which can be removed. Avoid mocking pure data, avoid value‑object interfaces/abstracts, consider mapping libraries like Valenor and beware DateTime's extra complexity.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 1:03Why value objects talk
- 3:30Value objects and modeling
- 5:40Real-world value objects
- 7:50Immutable and final value objects
- 9:16Validating value objects
- 11:21Converting value object representations
- 12:47Combining value objects
- 13:08Code smells for value objects
- 14:30Refactoring utility classes
- 16:58Value objects operators and methods
- 19:45Value objects anti-patterns
- 23:10Bounded contexts
- 24:58Naming conventions
- 25:41Avoiding fromArray and toArray
- 27:07Mocking value objects in tests
- 28:11Principles for value objects
- 29:15Bending value object rules
- 30:38Q&A
- 32:51Q&A
- 33:37Q&A








