27-28 February, 2019, London
During Magento Meetup 13 which took place in Dublin, Ireland at February 9, 2016 I’ve had a chance to share thoughts about Design Patterns usage in Magento 2.
I’ve uploaded presentation to SlideShare website. Feel free to share your experience using Design Patterns in Magento 2.
I decided to start from Magento 2 architectural goals. The goals were set few years ago for Magento 2 project:
Loose coupling between modules. Over the last year before the official Magento 2.0 GA release all teams were working on reducing complexity in Magento modules. It resulted in higher amount of tiny modules with less cross-module dependencies.
SOLID Principles. One of main for my point of view decisions was to accept usage of 5 main object oriented design principles. Thanks to @AntonKril who is now Magento 2 Architect. Anton broadcasted (I hope this is a right word) to every single developer who worked on Magento 2. Would this happens occasionally without him? I don’t know. Maybe few month later.
Design Patterns. In Magento 2 you may find tons of Design Patterns starting from Gang of Four Design Patterns, Enterprise Patterns by Martin Fawler. Sometimes I see overuse of some Design Patterns.
Configuration over customization. With the Inversion of Control Design Pattern and Object Manager implementation the real power of Dependency Injection become available for Magento developers. Now, in Magento 2 you are free to set preference class when you use interface. Or configure virtual type (which is also class created dynamically) with custom constructor arguments.
These are good ways to reduce amount of code developer should write each time.
Max Pronko is an international Magento Expert, development consultant, motivational speaker and Magento award-winning developer. He is known for the educational development programs for organizations of all sizes and has positively affected thousands of people and organizations worldwide.
Subscribe to my Magento 2 tips and tutorials content.
Every week I send an interesting email directly to your inbox