SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

Similar a 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
 
Leveraging Automation for a Disposable Infrastructure
Leveraging Automation for a Disposable InfrastructureLeveraging Automation for a Disposable Infrastructure
Leveraging Automation for a Disposable InfrastructureMike Fowler
 
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
 
6 track kinect@Bicocca - iniziative
6   track kinect@Bicocca - iniziative6   track kinect@Bicocca - iniziative
6 track kinect@Bicocca - iniziativeMatteo Valoriani
 
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]
 

Similar a 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)
 
Leveraging Automation for a Disposable Infrastructure
Leveraging Automation for a Disposable InfrastructureLeveraging Automation for a Disposable Infrastructure
Leveraging Automation for a Disposable Infrastructure
 
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
 
6 track kinect@Bicocca - iniziative
6   track kinect@Bicocca - iniziative6   track kinect@Bicocca - iniziative
6 track kinect@Bicocca - iniziative
 
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
 
Headless Architecture
Headless ArchitectureHeadless Architecture
Headless Architecture
 

Último

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

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