SlideShare a Scribd company logo
1 of 102
AWESOME
ARCHITECTURES IN
MAGENTO 2.3
Riccardo Tempesta
CTO MAGESPECIALIST
MAGENTO MASTER 2019
MAGENTO COMMUNITY MAINTAINER
TOP 5 MAGENTO CONTRIBUTOR 2018
#MM19PL - @RicTempesta
AWESOME
ARCHITECTURES IN
MAGENTO 2.3
Riccardo Tempesta
CTO MAGESPECIALIST
MAGENTO MASTER 2019
MAGENTO COMMUNITY MAINTAINER
TOP 5 MAGENTO CONTRIBUTOR 2018
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
DISCLAIMER 1:
The next slides contain a personal
interpretation that may differ from the
official Magento architects position.
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
DISCLAIMER 2:
My english is bad, but you don’t want to
try my polish!
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Why this speech?
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Becoming a Magento2 developer
is not stressful at all
-- Mark, 23 years old
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
«confusion» comes from latin:
«cum + fusus»
It means:
«Bonded with» or «Fused with»
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
«confusion» comes from latin:
«cum + fusus»
It means:
«Bonded with» or «Fused with»
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Magento 1
Another framework
Do not try to approach Magento2 as you were approaching Magento1
or any other «classical» framework
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Magento2 is a very complex
software with a very large codebase
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Developing process
Developer Codebase Instructions CPU
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Developing process
Developer Codebase Instructions CPU
Machines do not have any problem interpreting and running more code
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Developing process
Developer Codebase Instructions CPU
Machines do not have any problem interpreting and running more codeWe start having problems understanding
and maintaining a considerable amount of
code
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Increasing the code size:
95% of time: reading to understand
5% of time: write new code
We are the bottleneck
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
We are the bottleneck
We need to optimize the
95% of time spent in reading
and understaning our code
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
We are the bottleneck
How can we avoid it?
•Add structures
•Raise abstractions
•Reduce cognitive load
•…
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
We are the bottleneck
What are the tools?
•Methods
•Classes
•Modules
•Applications
•…
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
We are the bottleneck
What are the tools?
•Methods
•Classes
•Modules
•Applications
•…
Interactions and relations between these is what we call: Software Architecture
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Evolution of architectures
from 1990’s to 2010’s
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
1990’s
Spaghetti coding (aka Copy & Paste)
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
1990’s
Spaghetti coding (aka Copy & Paste)
2000’s
Lasagna coding (aka Layered Monolith)
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
1990’s
Spaghetti coding (aka Copy & Paste)
2000’s
Lasagna coding (aka Layered Monolith)
2010’s
Ravioli coding (aka Microservices)
the «Spaghetti coding era»
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
User Interface A blackbox working
somehow
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
… inside the box:
Code production over code maintainability
… everything coupled with everything
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
No architecture at all
• Hard to maintain
• High cognitive load
• Bad scalabilitycost
timeEvolution limit
the «Lasagna coding era»
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Every upper layer depends
on the underneath layers
Software is built in layers
The layered monolith
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
HTML
PHP
DATABASE
The layered monolith
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Controller
Model
ResourceModel
The layered monolith
Like most of the existing frameworks, Magento1 is here.
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The layered approach
Customer Catalog Quote
Controller
Model
Resource model
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The layered approach
Customer Catalog Quote
Controller
Model
Resource model
Every functional area is developed following a «horizontal» model
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The layered approach
Customer Catalog Quote
Controller
Model
Resource model
But we need interactions across different areas
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The drawback
The application becomes a N-layered monolyth
requiring every single layer to be working.
Only bing releases because we were not able to to
deploy each layer separately.
Unable to scale layers separately.
the «Ravioli coding era»
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Microservices
The final application is a
composition
of multiple «small»
features.
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Microservices
Each component can be
deployed separately.
Each component can be
scaled independently from
the whole application.
Where is Magento2 now?
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Spaghetti Lasagna Ravioli
Where is Magento2 now?
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Spaghetti Lasagna Ravioli
Where is Magento2 now?
Magento 1
Magento 2.0
Magento 2.1
Magento 2.2
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Whaaaaaat?!?!
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Something changed in
Magento 2.3 after one of
the most advanced
community projects: MSI
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Igor Miniailo
Magento 2 Architect,
Magento / Adobe
@iminyaylo
Eugene Shakhsuvarov
Software Development
Engineer, Magento / Adobe
@ishakhsuvarov
https://github.com/magento/inventory
The Magento Inventory Project (aka MSI)
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The service isolation
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Customer Catalog Quote
Controller
Model
Resource model
The Layered monolith approach:
Software is developed «horizontally»
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Customer Catalog Quote
Controller
Model
Resource model
In the service isolation model we consider each functional
area as an independent module
Software is developed «vertically»
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Customer Catalog Quote
Controller
Model
Resource model
But we still have a problem with modules requiring
acces to other modules information
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Customer Catalog Quote
Controller
Model
Resource model
Customer API Catalog API Quote API
Customer Catalog Quote
We should split each module in:
• API module
• Implementation module
Note: This is an example, Magento2 modules implemenetation may differ
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Modules interact with other modules via API only
Customer API
Customer
Catalog API
Catalog
Quote API
Quote
«API first» approach
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
API / Interface
API first
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
API / Interface
API first
Concrete module
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
•Single responsibility
•Open for extensions, Closed for modification
•Liskov substitution
•Interface segregation
•Dependency inversion
A functional area should depend on the abstraction of another functional area
and not on concrete its implementation.
The «D» of SOLID brought at functional area level
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Functional area dependency inversion
MyModule
AnotherModuleAPI
AnotherModule
Depends on
Dependson
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Functional area dependency inversion
MyModule
AnotherModuleAPI
AnotherModule
Depends on
Dependson
Another advantage:
Can be replaced with a 3rd party implementation
if needed
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Functional area dependency inversion
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Functional area dependency inversion
Cross contexts interactions
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Functional area dependency inversion
Inventory
In the old way:
They would have been depending on each other
We would have to modify «Sales» and «Inventory» accordingly their needs
Mutual dependency
Sales
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Functional area dependency inversion
Inventory
In the old way:
They would have been depending on each other
We would have to modify «Sales» and «Inventory» accordingly their needs
Mutual dependency
Sales
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Decoupled dependency
Inventory
SalesInventorySales
There is no more direct dependency
between «Sales» and «Inventory»
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Decoupled dependency
Inventory
SalesInventorySales
There is no more direct dependency
between «Sales» and «Inventory»
Plugin to «Sales» to
modifiy/add what
we need
We need «smaller» classes
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
•Single responsibility
•Open for extensions, Closed for modification
•Liskov substitution
•Interface segregation
•Dependency inversion
A class has a single «atomic» responsibility and must be easy to replace.
This is why old Magento1 «Helpers» should not be used anymore.
The «S» of SOLID
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Divide et impera!
The rule:
You should be able to
understand the specific
responsibility and
behavior of a class by
simply reading its name.
«If you have problems naming your class, then you probably need a refactor!»
-- The Rick
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
When the responsibility is an action
<?php
…
class GetProductIdsBySkus implements GetProductIdsBySkusInterface
{
…
public function execute(array $skus): array
{
$idsBySkus = $this->productResource->getProductsIdsBySkus($skus);
$notFoundedSkus = array_diff($skus, array_keys($idsBySkus));
…
return $idsBySkus;
}
…
}
You have a single public method class and its name should contain a verb.
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The single responsibility corollary
Class A extends B
Class B extends C
Class B
Class C
DI
Class A
Composition over extension
The future…
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Anton Kril’s architecture vision of Magento2
Director of architecture at Magento and Master of the Universe
The Modulegeddon!
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
OMG! So many modules…
More than 40 for Inventory only
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
OMG! So many modules…
First reaction…
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
OMG! So many modules…
Second reaction… (or near death experience)
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
OMG! So many modules…
Then you see the light!
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
You see all the advantages:
•Fully modular system
•Full service isolation
•Clear code writing
•Classes and responsibilities are easy to find
•Each module or class is easy to replace
•Easy to handle in a structured teamwork
•No more «god modules» made of hundreds of classes
Oh wait! We forgot something!
#MM19PL - @RicTempesta
Database!
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Customer Catalog Quote
Controller
Model
Resource model
Customer API Catalog API Quote API
Customer Catalog Quote
Database Isolation
In the «vertical» approach, tables could be on different databases!
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The foreign key problem
Inventory area Catalog area
Source item
Product IDProduct ID
Foreign key
Product entity
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The foreign key problem
Inventory area Catalog area
Source item
Product IDProduct ID
Foreign key
Product entity
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The foreign key problem
Inventory area Catalog area
Product SKUProduct SKU
No DB dependency
And use of business keys
Source item Product entity
Mind the CAP theorem
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The CAP theorem
•Consistency
•Availability
•Partitioning
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The CAP theorem
•Consistency
•Availability
•Partitioning
You can have only 2
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The CAP theorem
We need partitioning because our
functional areas are vertically splitted.
We need availability because we are
building an e-commerce solution.
So we cannot be immediately
consistent.
The eventual consistency
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The CRUD approach (if we had consistency)
Write data Read same data
We have: immediate consistency
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
In a partitioned (or distributed) system
Write data
We have: eventual consistency
Read potentially oudated data
CQS: Command-Query Separation
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
CQS: Command
Example:
A hypothetical «save» (or «create») method, should not return the newly created object ID.
Use of business keys is recommended in this case
Modifies the DB (or application state) and does not return anything
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
CQS: Query
Does not modify the database (or application state)
CQRS: Command-Query
Responsibility Segregation
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Different read/write logic
Write data (with a representation) Read data (with another representation)
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
The inventory example
Write quantity Read salable quantityWrite reservations
Good examples
#MM19PL - @RicTempesta
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Where to find good examples
• https://github.com/magento/inventory
• https://github.com/magento/security-package/pull/2
Inventory project (aka MSI) Notifier project
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Where to find good examples
• https://github.com/magento/inventory
• https://github.com/magento/security-package/pull/2
Inventory project (aka MSI) Notifier project
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Where to find good examples
• https://github.com/magento/inventory
• https://github.com/magento/security-package/pull/2
Inventory project (aka MSI) Notifier project
Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
Magento is an open source Community
To be involved in the Magento evolution:
Join the Magento EngCom Slack Channel
magentocommeng.slack.com
#appdesign
magentocommeng.slack.com
#msi
Thank you!
Riccardo Tempesta (aka The Rick)
MageSpecialist
@RicTempesta
riccardo.tempesta@magespecialist.it
#MM19PL
Awesome Architectures in Magento 2.3 - MM19PL

More Related Content

Similar to Awesome Architectures in Magento 2.3 - MM19PL

M-RTOS webinar presentation July 20th 2020
M-RTOS webinar presentation July 20th 2020M-RTOS webinar presentation July 20th 2020
M-RTOS webinar presentation July 20th 2020Marketing Donalba
 
Architecture in-the-small-slides
Architecture in-the-small-slidesArchitecture in-the-small-slides
Architecture in-the-small-slidesvinaikopp
 
Improving the Demand Side of the AI Economy (API World 2018)
Improving the Demand Side of the AI Economy (API World 2018)Improving the Demand Side of the AI Economy (API World 2018)
Improving the Demand Side of the AI Economy (API World 2018)Konstantin Savenkov
 
Magento 2 TDD Code Kata Intro
Magento 2 TDD Code Kata IntroMagento 2 TDD Code Kata Intro
Magento 2 TDD Code Kata Introvinaikopp
 
IoT, arquitectura de solución y cómo enriquecerlo con Confluent
IoT, arquitectura de solución y cómo enriquecerlo con ConfluentIoT, arquitectura de solución y cómo enriquecerlo con Confluent
IoT, arquitectura de solución y cómo enriquecerlo con Confluentmimacom
 
How to create a Vue Storefront theme
How to create a Vue Storefront themeHow to create a Vue Storefront theme
How to create a Vue Storefront themeDivante
 
Migrate to-pg pgconfeu2019
Migrate to-pg pgconfeu2019Migrate to-pg pgconfeu2019
Migrate to-pg pgconfeu2019Loxodata
 
Purely Functional Web Apps (Extended Version, 16.02.2016)
Purely Functional Web Apps (Extended Version, 16.02.2016)Purely Functional Web Apps (Extended Version, 16.02.2016)
Purely Functional Web Apps (Extended Version, 16.02.2016)miciek
 
PGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
PGConf APAC 2018: PostgreSQL 10 - Replication goes LogicalPGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
PGConf APAC 2018: PostgreSQL 10 - Replication goes LogicalPGConf APAC
 
Riccardo Di Pietro -European Maker Faire Week 2016 - Building the Internet of...
Riccardo Di Pietro -European Maker Faire Week 2016 - Building the Internet of...Riccardo Di Pietro -European Maker Faire Week 2016 - Building the Internet of...
Riccardo Di Pietro -European Maker Faire Week 2016 - Building the Internet of...PhD. student @University of Catania,Italy
 
Digital disruptions as one of my 2015-2016 lectures at the University of Berg...
Digital disruptions as one of my 2015-2016 lectures at the University of Berg...Digital disruptions as one of my 2015-2016 lectures at the University of Berg...
Digital disruptions as one of my 2015-2016 lectures at the University of Berg...Roberto Peretta
 
Slides from NanoMarkets webinar on Smart Coatings Feb 2015
Slides from NanoMarkets webinar on Smart Coatings  Feb 2015Slides from NanoMarkets webinar on Smart Coatings  Feb 2015
Slides from NanoMarkets webinar on Smart Coatings Feb 2015n-tech Research
 
IRJET- Multi Design - Pattern React Application with Django Backend
IRJET- Multi Design - Pattern React Application with Django BackendIRJET- Multi Design - Pattern React Application with Django Backend
IRJET- Multi Design - Pattern React Application with Django BackendIRJET Journal
 
The productive developer guide to Angular 2
The productive developer guide to Angular 2The productive developer guide to Angular 2
The productive developer guide to Angular 2Maurice De Beijer [MVP]
 
Expert System Global Intranet - Design Process
Expert System Global Intranet - Design ProcessExpert System Global Intranet - Design Process
Expert System Global Intranet - Design ProcessGianluca Nicoletta
 
Ready-Mix Concrete (RMC Plant)-627631-.pdf
Ready-Mix Concrete (RMC Plant)-627631-.pdfReady-Mix Concrete (RMC Plant)-627631-.pdf
Ready-Mix Concrete (RMC Plant)-627631-.pdfchandanprasad66
 

Similar to Awesome Architectures in Magento 2.3 - MM19PL (20)

M-RTOS webinar presentation July 20th 2020
M-RTOS webinar presentation July 20th 2020M-RTOS webinar presentation July 20th 2020
M-RTOS webinar presentation July 20th 2020
 
Architecture in-the-small-slides
Architecture in-the-small-slidesArchitecture in-the-small-slides
Architecture in-the-small-slides
 
Improving the Demand Side of the AI Economy (API World 2018)
Improving the Demand Side of the AI Economy (API World 2018)Improving the Demand Side of the AI Economy (API World 2018)
Improving the Demand Side of the AI Economy (API World 2018)
 
Magento 2 TDD Code Kata Intro
Magento 2 TDD Code Kata IntroMagento 2 TDD Code Kata Intro
Magento 2 TDD Code Kata Intro
 
GraphQL in Magento 2
GraphQL in Magento 2GraphQL in Magento 2
GraphQL in Magento 2
 
Industry 4.0 … Rewind
Industry 4.0 … RewindIndustry 4.0 … Rewind
Industry 4.0 … Rewind
 
IoT, arquitectura de solución y cómo enriquecerlo con Confluent
IoT, arquitectura de solución y cómo enriquecerlo con ConfluentIoT, arquitectura de solución y cómo enriquecerlo con Confluent
IoT, arquitectura de solución y cómo enriquecerlo con Confluent
 
How to create a Vue Storefront theme
How to create a Vue Storefront themeHow to create a Vue Storefront theme
How to create a Vue Storefront theme
 
Migrate to-pg pgconfeu2019
Migrate to-pg pgconfeu2019Migrate to-pg pgconfeu2019
Migrate to-pg pgconfeu2019
 
Purely Functional Web Apps (Extended Version, 16.02.2016)
Purely Functional Web Apps (Extended Version, 16.02.2016)Purely Functional Web Apps (Extended Version, 16.02.2016)
Purely Functional Web Apps (Extended Version, 16.02.2016)
 
PGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
PGConf APAC 2018: PostgreSQL 10 - Replication goes LogicalPGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
PGConf APAC 2018: PostgreSQL 10 - Replication goes Logical
 
SFSCON23 - Luca Basile - The Entando Marketplace
SFSCON23 - Luca Basile - The Entando MarketplaceSFSCON23 - Luca Basile - The Entando Marketplace
SFSCON23 - Luca Basile - The Entando Marketplace
 
Riccardo Di Pietro -European Maker Faire Week 2016 - Building the Internet of...
Riccardo Di Pietro -European Maker Faire Week 2016 - Building the Internet of...Riccardo Di Pietro -European Maker Faire Week 2016 - Building the Internet of...
Riccardo Di Pietro -European Maker Faire Week 2016 - Building the Internet of...
 
Digital disruptions as one of my 2015-2016 lectures at the University of Berg...
Digital disruptions as one of my 2015-2016 lectures at the University of Berg...Digital disruptions as one of my 2015-2016 lectures at the University of Berg...
Digital disruptions as one of my 2015-2016 lectures at the University of Berg...
 
31. Magento Meetup Austria: News
31. Magento Meetup Austria: News31. Magento Meetup Austria: News
31. Magento Meetup Austria: News
 
Slides from NanoMarkets webinar on Smart Coatings Feb 2015
Slides from NanoMarkets webinar on Smart Coatings  Feb 2015Slides from NanoMarkets webinar on Smart Coatings  Feb 2015
Slides from NanoMarkets webinar on Smart Coatings Feb 2015
 
IRJET- Multi Design - Pattern React Application with Django Backend
IRJET- Multi Design - Pattern React Application with Django BackendIRJET- Multi Design - Pattern React Application with Django Backend
IRJET- Multi Design - Pattern React Application with Django Backend
 
The productive developer guide to Angular 2
The productive developer guide to Angular 2The productive developer guide to Angular 2
The productive developer guide to Angular 2
 
Expert System Global Intranet - Design Process
Expert System Global Intranet - Design ProcessExpert System Global Intranet - Design Process
Expert System Global Intranet - Design Process
 
Ready-Mix Concrete (RMC Plant)-627631-.pdf
Ready-Mix Concrete (RMC Plant)-627631-.pdfReady-Mix Concrete (RMC Plant)-627631-.pdf
Ready-Mix Concrete (RMC Plant)-627631-.pdf
 

Recently uploaded

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Awesome Architectures in Magento 2.3 - MM19PL

  • 1. AWESOME ARCHITECTURES IN MAGENTO 2.3 Riccardo Tempesta CTO MAGESPECIALIST MAGENTO MASTER 2019 MAGENTO COMMUNITY MAINTAINER TOP 5 MAGENTO CONTRIBUTOR 2018 #MM19PL - @RicTempesta
  • 2. AWESOME ARCHITECTURES IN MAGENTO 2.3 Riccardo Tempesta CTO MAGESPECIALIST MAGENTO MASTER 2019 MAGENTO COMMUNITY MAINTAINER TOP 5 MAGENTO CONTRIBUTOR 2018 #MM19PL - @RicTempesta
  • 3. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta DISCLAIMER 1: The next slides contain a personal interpretation that may differ from the official Magento architects position.
  • 4. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta DISCLAIMER 2: My english is bad, but you don’t want to try my polish!
  • 5. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Why this speech?
  • 6. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Becoming a Magento2 developer is not stressful at all -- Mark, 23 years old
  • 7. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta «confusion» comes from latin: «cum + fusus» It means: «Bonded with» or «Fused with»
  • 8. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta «confusion» comes from latin: «cum + fusus» It means: «Bonded with» or «Fused with»
  • 9. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Magento 1 Another framework Do not try to approach Magento2 as you were approaching Magento1 or any other «classical» framework
  • 10. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Magento2 is a very complex software with a very large codebase
  • 11. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Developing process Developer Codebase Instructions CPU
  • 12. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Developing process Developer Codebase Instructions CPU Machines do not have any problem interpreting and running more code
  • 13. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Developing process Developer Codebase Instructions CPU Machines do not have any problem interpreting and running more codeWe start having problems understanding and maintaining a considerable amount of code
  • 14. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Increasing the code size: 95% of time: reading to understand 5% of time: write new code We are the bottleneck
  • 15. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta We are the bottleneck We need to optimize the 95% of time spent in reading and understaning our code
  • 16. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta We are the bottleneck How can we avoid it? •Add structures •Raise abstractions •Reduce cognitive load •…
  • 17. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta We are the bottleneck What are the tools? •Methods •Classes •Modules •Applications •…
  • 18. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta We are the bottleneck What are the tools? •Methods •Classes •Modules •Applications •… Interactions and relations between these is what we call: Software Architecture
  • 19. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Evolution of architectures from 1990’s to 2010’s
  • 20. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta 1990’s Spaghetti coding (aka Copy & Paste)
  • 21. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta 1990’s Spaghetti coding (aka Copy & Paste) 2000’s Lasagna coding (aka Layered Monolith)
  • 22. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta 1990’s Spaghetti coding (aka Copy & Paste) 2000’s Lasagna coding (aka Layered Monolith) 2010’s Ravioli coding (aka Microservices)
  • 23. the «Spaghetti coding era» #MM19PL - @RicTempesta
  • 24. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta User Interface A blackbox working somehow
  • 25. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta … inside the box: Code production over code maintainability … everything coupled with everything
  • 26. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta No architecture at all • Hard to maintain • High cognitive load • Bad scalabilitycost timeEvolution limit
  • 27. the «Lasagna coding era» #MM19PL - @RicTempesta
  • 28. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Every upper layer depends on the underneath layers Software is built in layers The layered monolith
  • 29. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta HTML PHP DATABASE The layered monolith
  • 30. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Controller Model ResourceModel The layered monolith Like most of the existing frameworks, Magento1 is here.
  • 31. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The layered approach Customer Catalog Quote Controller Model Resource model
  • 32. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The layered approach Customer Catalog Quote Controller Model Resource model Every functional area is developed following a «horizontal» model
  • 33. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The layered approach Customer Catalog Quote Controller Model Resource model But we need interactions across different areas
  • 34. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The drawback The application becomes a N-layered monolyth requiring every single layer to be working. Only bing releases because we were not able to to deploy each layer separately. Unable to scale layers separately.
  • 35. the «Ravioli coding era» #MM19PL - @RicTempesta
  • 36. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Microservices The final application is a composition of multiple «small» features.
  • 37. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Microservices Each component can be deployed separately. Each component can be scaled independently from the whole application.
  • 38. Where is Magento2 now? #MM19PL - @RicTempesta
  • 39. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Spaghetti Lasagna Ravioli Where is Magento2 now?
  • 40. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Spaghetti Lasagna Ravioli Where is Magento2 now? Magento 1 Magento 2.0 Magento 2.1 Magento 2.2
  • 41. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Whaaaaaat?!?!
  • 42. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Something changed in Magento 2.3 after one of the most advanced community projects: MSI
  • 43. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Igor Miniailo Magento 2 Architect, Magento / Adobe @iminyaylo Eugene Shakhsuvarov Software Development Engineer, Magento / Adobe @ishakhsuvarov https://github.com/magento/inventory The Magento Inventory Project (aka MSI)
  • 44. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta
  • 46. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Customer Catalog Quote Controller Model Resource model The Layered monolith approach: Software is developed «horizontally»
  • 47. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Customer Catalog Quote Controller Model Resource model In the service isolation model we consider each functional area as an independent module Software is developed «vertically»
  • 48. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Customer Catalog Quote Controller Model Resource model But we still have a problem with modules requiring acces to other modules information
  • 49. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Customer Catalog Quote Controller Model Resource model Customer API Catalog API Quote API Customer Catalog Quote We should split each module in: • API module • Implementation module Note: This is an example, Magento2 modules implemenetation may differ
  • 50. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Modules interact with other modules via API only Customer API Customer Catalog API Catalog Quote API Quote
  • 52. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta API / Interface API first
  • 53. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta API / Interface API first Concrete module
  • 54. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta •Single responsibility •Open for extensions, Closed for modification •Liskov substitution •Interface segregation •Dependency inversion A functional area should depend on the abstraction of another functional area and not on concrete its implementation. The «D» of SOLID brought at functional area level
  • 55. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Functional area dependency inversion MyModule AnotherModuleAPI AnotherModule Depends on Dependson
  • 56. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Functional area dependency inversion MyModule AnotherModuleAPI AnotherModule Depends on Dependson Another advantage: Can be replaced with a 3rd party implementation if needed
  • 57. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Functional area dependency inversion
  • 58. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Functional area dependency inversion
  • 60. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Functional area dependency inversion Inventory In the old way: They would have been depending on each other We would have to modify «Sales» and «Inventory» accordingly their needs Mutual dependency Sales
  • 61. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Functional area dependency inversion Inventory In the old way: They would have been depending on each other We would have to modify «Sales» and «Inventory» accordingly their needs Mutual dependency Sales
  • 62. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Decoupled dependency Inventory SalesInventorySales There is no more direct dependency between «Sales» and «Inventory»
  • 63. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Decoupled dependency Inventory SalesInventorySales There is no more direct dependency between «Sales» and «Inventory» Plugin to «Sales» to modifiy/add what we need
  • 64. We need «smaller» classes #MM19PL - @RicTempesta
  • 65. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta •Single responsibility •Open for extensions, Closed for modification •Liskov substitution •Interface segregation •Dependency inversion A class has a single «atomic» responsibility and must be easy to replace. This is why old Magento1 «Helpers» should not be used anymore. The «S» of SOLID
  • 66. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Divide et impera! The rule: You should be able to understand the specific responsibility and behavior of a class by simply reading its name. «If you have problems naming your class, then you probably need a refactor!» -- The Rick
  • 67. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta When the responsibility is an action <?php … class GetProductIdsBySkus implements GetProductIdsBySkusInterface { … public function execute(array $skus): array { $idsBySkus = $this->productResource->getProductsIdsBySkus($skus); $notFoundedSkus = array_diff($skus, array_keys($idsBySkus)); … return $idsBySkus; } … } You have a single public method class and its name should contain a verb.
  • 68. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The single responsibility corollary Class A extends B Class B extends C Class B Class C DI Class A Composition over extension
  • 69. The future… #MM19PL - @RicTempesta
  • 70. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Anton Kril’s architecture vision of Magento2 Director of architecture at Magento and Master of the Universe
  • 72. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta OMG! So many modules… More than 40 for Inventory only
  • 73. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta OMG! So many modules… First reaction…
  • 74. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta OMG! So many modules… Second reaction… (or near death experience)
  • 75. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta OMG! So many modules… Then you see the light!
  • 76. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta You see all the advantages: •Fully modular system •Full service isolation •Clear code writing •Classes and responsibilities are easy to find •Each module or class is easy to replace •Easy to handle in a structured teamwork •No more «god modules» made of hundreds of classes
  • 77. Oh wait! We forgot something! #MM19PL - @RicTempesta
  • 79. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Customer Catalog Quote Controller Model Resource model Customer API Catalog API Quote API Customer Catalog Quote Database Isolation In the «vertical» approach, tables could be on different databases!
  • 80. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The foreign key problem Inventory area Catalog area Source item Product IDProduct ID Foreign key Product entity
  • 81. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The foreign key problem Inventory area Catalog area Source item Product IDProduct ID Foreign key Product entity
  • 82. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The foreign key problem Inventory area Catalog area Product SKUProduct SKU No DB dependency And use of business keys Source item Product entity
  • 83. Mind the CAP theorem #MM19PL - @RicTempesta
  • 84. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The CAP theorem •Consistency •Availability •Partitioning
  • 85. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The CAP theorem •Consistency •Availability •Partitioning You can have only 2
  • 86. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The CAP theorem We need partitioning because our functional areas are vertically splitted. We need availability because we are building an e-commerce solution. So we cannot be immediately consistent.
  • 88. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The CRUD approach (if we had consistency) Write data Read same data We have: immediate consistency
  • 89. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta In a partitioned (or distributed) system Write data We have: eventual consistency Read potentially oudated data
  • 91. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta CQS: Command Example: A hypothetical «save» (or «create») method, should not return the newly created object ID. Use of business keys is recommended in this case Modifies the DB (or application state) and does not return anything
  • 92. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta CQS: Query Does not modify the database (or application state)
  • 94. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Different read/write logic Write data (with a representation) Read data (with another representation)
  • 95. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta The inventory example Write quantity Read salable quantityWrite reservations
  • 96. Good examples #MM19PL - @RicTempesta
  • 97. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Where to find good examples • https://github.com/magento/inventory • https://github.com/magento/security-package/pull/2 Inventory project (aka MSI) Notifier project
  • 98. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Where to find good examples • https://github.com/magento/inventory • https://github.com/magento/security-package/pull/2 Inventory project (aka MSI) Notifier project
  • 99. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Where to find good examples • https://github.com/magento/inventory • https://github.com/magento/security-package/pull/2 Inventory project (aka MSI) Notifier project
  • 100. Awesome Architectures in Magento 2.3 – 16 September 2019 – Riccardo Tempesta #MM19PL - @RicTempesta Magento is an open source Community To be involved in the Magento evolution: Join the Magento EngCom Slack Channel magentocommeng.slack.com #appdesign magentocommeng.slack.com #msi
  • 101. Thank you! Riccardo Tempesta (aka The Rick) MageSpecialist @RicTempesta riccardo.tempesta@magespecialist.it #MM19PL