Page 12 - Design Patterns
-
Maxim Mironjuk
-
June 21, 2025
ObjectManager::getInstance()->get() hides dependencies, makes testing impossible, and blocks static analysis. Everything about the Service Locator anti-pattern, and the correct alternative.
-
Maxim Mironjuk
-
June 20, 2025
Functional composition assembles small, individually tested functions into a new function, instead of nesting calls deeply inside one another. With a self-written compose() function, this pattern can be implemented in PHP 8.4 in a type-safe way and without any extra dependency.
-
Maxim Mironjuk
-
June 19, 2025
Multi tenancy decides whether a SaaS application safely separates data from hundreds of tenants or one day risks a data leak between customers. This post compares shared schema with tenant_id, schema-per-tenant, and database-per-tenant by isolation, migration effort, and resource isolation, so the decision rests on real criteria instead of gut feeling.
-
Maxim Mironjuk
-
June 19, 2025
TypeScript allows generics over concrete types, but not generics over type constructors themselves. A function that works equally well for any container type such as Array, Option, or Promise cannot be written directly. Through a technique called defunctionalization, known as the URI pattern from fp-ts, this missing feature can still be simulated in a practical way.
-
Maxim Mironjuk
-
June 17, 2025
A collapsible sidebar navigation is one of the most common layout elements in dashboards and admin interfaces. With Alpine.js, the complete state, from opening and closing to browser persistence and a mobile overlay variant, fits into one compact component, with no need to load React or Vue.
-
Maxim Mironjuk
-
June 13, 2025
A single Zod schema is quick to write, but in a growing codebase with dozens of endpoints and domain objects, a lack of deliberate architecture quickly leads to duplicated validation code sprawling everywhere. This article shows concrete Zod schema design patterns for reuse, discriminated unions, recursive tree types, transform pipelines and branded types, so validation logic gets the same structure as any other part of the application architecture.
-
Maxim Mironjuk
-
June 08, 2025
In most agency projects, attribute sets grow uncontrolled: every new product type gets its own set, naming conventions are missing, and after two years nobody can say which of the eighty sets are actually still used in production. Teams that instead align attribute sets with product types and business requirements before creation, generate them programmatically through Data Patches and keep them under a clear governance process, keep the EAV structure maintainable, performant and comprehensible for new developers.
-
Maxim Mironjuk
-
June 05, 2025
Redux Toolkit has largely replaced classic Redux with its endless switch statements and action type constants. With createSlice, RTK Query and Entity Adapter, global state in React applications can be modeled with far less code, more type safety and built in server state caching.
-
Maxim Mironjuk
-
June 03, 2025
A command palette has become close to a standard feature in developer tools and increasingly shows up in ordinary web applications too: a keystroke opens a centered search field that filters commands, pages or records and can be navigated with the arrow keys. Behind this seemingly simple pattern sit a number of detail problems: correct overlay positioning, a clearly recognizable active entry, groups with their own headings, and a visual highlight for fuzzy search matches. This article shows how to implement all of that cleanly and maintainably with plain Tailwind CSS plus a bit of Alpine.js for state management.
-
Maxim Mironjuk
-
June 02, 2025
The Strategy pattern defines a family of algorithms, encapsulates each one and makes them interchangeable. In Magento 2 it shows up everywhere: tax calculation, shipping methods, price rules, payment methods, all of them rely on Strategy.
-