Factory Method and Abstract Factory – implementations, differences table, Simple Factory
Factory Method and Abstract Factory are both creational patterns that remove the new keyword from business logic – but they solve different problems. Factory Method delegates creation to subclasses. Abstract Factory creates families of related objects. I implement both from scratch, compare them in a table, and show where Simple Factory fits as a pragmatic alternative.
- Published in Wzorce projektowe
Design patterns – introduction, 23 GoF patterns table, when to use and when not to
Design patterns are reusable solutions to recurring design problems. The Gang of Four book from 1994 catalogued 23 patterns split into three categories. They are not code snippets to paste in – they are a vocabulary for communicating design decisions. This post is an introduction and reference table before I cover each pattern individually in the coming weeks.
- Published in Wzorce projektowe
SOLID principles in PHP – theory into code
SOLID principles are five design guidelines that make object-oriented code maintainable, extensible, and testable. They are not rules to be applied mechanically but tools for reasoning about design decisions. I show each principle in PHP with a before/after example and a concrete connection to Magento 2 architecture.
- Published in PHP
PHP 8.1 in practice – enums after a month, database storage, Money value object
PHP 8.1 was released in November 2021. After a month of migrating modules and writing new code with the new features I have a clear view of what matters in practice. Enums are the biggest quality-of-life improvement – I show how I store them in the database, use them in match expressions, and build a Money value object that shows readonly properties and enums working together.
- Published in PHP
