Design Patterns


 Modular Design to Multiple Design Patterns


There are so many design patterns to which is perfect the debuts starts with you should use this or that or both or all. But how to use all these. Which language to select PHP, XML, JS, Node, YAML, INI, so on.

In Magento 2, they have smartly used each design pattern to specific language. To help developer readable and easy to understand by the IDE's like PHP Storm, VS Code.

It is like they will have to use it and there is no chooses.

There is lot of though process which language is suitable for each purposes.

For example, Layouts using YAML it might be difficult because we have to add attributes and tags. This is not perfect and nor readable.

XML - It is perfect for validations using XSD format. IDE can easily validate it. More important developer readable. Core team add many tags to customise.

  • block
  • containers
  • head
  • css
  • js
  • style
  • remove
  • referenceBlock
  • referenceContainer
  • move
  • handle
  • config
  • layout
  • plugin
  • type
  • virtualType
  • plugin
  • and many more ...

Here are the design patterns used in Magento2

  • MVVC
  • Front controller
  • Singleton
  • Service Contract
  • Proxy Classes / Lazy loading
  • Model/Resource Model/Collection
  • Factory Classes
  • Controller design patterns
  • Dependency Injection design pattern
  • Observer
  • Iterator
  • Registry
  • Object Pool
  • Prototype
  • UI Design Patterns

Each patterns is used with specific language.


We will post new content on Magento 2 soon.