SlideShare a Scribd company logo
1 of 60
© 2016 Magento, Inc. Page | 1
Backward Compatibility
Developer’s guide
Igor Miniailo
Magento 2 Architect
© 2016 Magento, Inc. Page | 2
© 2016 Magento, Inc. Page | 3
The main reason we reject a community Pull
Request (PR) or request additional changes is
that the code is not compliant with our Technical
Vision and/or Backward Compatibility Policy.
© 2016 Magento, Inc. Page | 4
© 2016 Magento, Inc. Page | 5
© 2016 Magento, Inc. Page | 6
© 2016 Magento, Inc. Page | 7
• Magento 2 Technical Guidelines
• Versioning
• Backward Compatibility Development
Guide
© 2016 Magento, Inc. Page | 8
Why does BC matter?
For merchants, the process
must be cost-effective, while
developers want their
extensions to be forward-
compatible for as long as
possible.
© 2016 Magento, Inc. Page | 9
Does Magento have to evolve?
Does every change in code bring backward
incompatibility?
© 2016 Magento, Inc. Page | 10
Keep Magento backwards compatible vs.
improving it?
© 2016 Magento, Inc. Page | 11
We MUST do BOTH
© 2016 Magento, Inc. Page | 12
Backward Compatible Fix
*it works (most of the time), but code quality
is far from good enough
© 2016 Magento, Inc. Page | 13
Backward Compatibility
policy for Magento code
© 2016 Magento, Inc. Page | 14
Semantic Versioning
Version numbers are in the format
MAJOR.MINOR.PATCH, where:
– MAJOR indicates incompatible API changes
– MINOR indicates backward-compatible
functionality has been added
– PATCH indicates backward-compatible bug
fixes
© 2016 Magento, Inc. Page | 15
The backward compatibility policy
applies to PHP code annotated with
@api
© 2016 Magento, Inc. Page | 16
Public and Private code
© 2016 Magento, Inc. Page | 17
Public vs Private code
Private code is not supposed to
be used by third party modules,
so, in most cases, its
modifications will only trigger
PATCH version bumps.
Changes in public code always
trigger MINOR or MAJOR
version bumps.
© 2016 Magento, Inc. Page | 18
What examples of Public code Magento has?
• PHP Interface (marked with @api)
• PHP Class (marked with @api)
• Javascript Interface (marked with @api)
• Javascript Class (marked with @api)
• Virtual Type (marked with @api)
• URL paths
• Console commands and their arguments
• Less Variables & Mixins
• Message queue topics and their data types
• UI component declarations
• Layout handles declared by modules
• Events triggered by component (both static dynamic)
• Schema of configuration types introduced by module
• Structure of System Configuration fields used by module
© 2016 Magento, Inc. Page | 19
API vs SPI (Extension Points)
A PHP Interface in Magento can be used several ways by the core
product and extension developers.
• As an API. is a set of interfaces and their
implementations that a module provides to other
modules
• As a Service Provider Interface (SPI). is a set of
interfaces that a module uses internally and allows their
implementation by other modules.
• As both. APIs and SPIs are not mutually exclusive.
© 2016 Magento, Inc. Page | 20
After the code is released, both API and SPI can
be evolved in a backwards-compatible way. But
both have their specific limitations.
© 2016 Magento, Inc. Page | 21
© 2016 Magento, Inc. Page | 22
© 2016 Magento, Inc. Page | 23
© 2016 Magento, Inc. Page | 24
© 2016 Magento, Inc. Page | 25
© 2016 Magento, Inc. Page | 26
We do not distinguish them separately.
SPIs are annotated the same as APIs.
© 2016 Magento, Inc. Page | 27
Who decides whether interface/class belong to API or SPI?
YOU
© 2016 Magento, Inc. Page | 28
Dependency Rules API
If a module uses (calls) an API, it should be dependent on the MAJOR
version.
API dependency example
{
...
"require": {
"magento/module-customer": "~100.0", // (>=100.0 <101.0.0)
},
...
}
© 2016 Magento, Inc. Page | 29
Dependency Rules SPI
If a module implements an API/SPI, it should be dependent on the
MAJOR+MINOR version.
SPI dependency example
{
...
"require": {
"magento/module-customer": "~100.0.0", // (>=100.0.0 <100.1.0)
},
...
}
© 2016 Magento, Inc. Page | 30
http://devdocs.magento.com/guides/v2.1/release-notes/backward-
incompatible-changes-2.1.html
© 2016 Magento, Inc. Page | 31
What keeps us from making mistakes?
To minimize this risk we have developed a tool Semantic
Version Checker Tool that analyzes two code bases and
determines what part of the version need updating
(MAJOR, MINOR, PATCH). As part of the delivery process,
we must run this tool and use the results for input to the
Version Setter tool.
© 2016 Magento, Inc. Page | 32
Prohibited Code Changes
© 2016 Magento, Inc. Page | 33
• Interface/class removal
• Public & protected method removal
• Introduction of a method to a class or
interface
PHP - Prohibited Code Changes
© 2016 Magento, Inc. Page | 34
MagentoCatalogApiCategoryRepositoryInterface
© 2016 Magento, Inc. Page | 35
MagentoCatalogApiCategoryListInterface
© 2016 Magento, Inc. Page | 36
PHP - Prohibited Code Changes
• Static function removal
• Parameter addition in public methods
• Parameter addition in protected
methods
© 2016 Magento, Inc. Page | 37
© 2016 Magento, Inc. Page | 38
PHP - Prohibited Code Changes
• Method argument type modification
• Modification of types of thrown
exceptions (unless a new exception is
a subtype of the old one)
• Constructor modification
© 2016 Magento, Inc. Page | 39
class ExistingClass
{
/**
* @var NewDependencyInterface $newDependency
*/
private $newDependency;
public function __construct(
OldDependencyIntreface $oldDependency,
$oldRequiredConstructorParameter,
$oldOptinalConstructorParameter = null,
NewDependencyInterface $newDependency = null
) {
...
$this>newDependency = $newDependency ?: MagentoFrameworkAppObjectManager::getInstance()
->get(NewDependencyInterface::class);
...
}
public function existingFunction() {
// Existing functionality
...
// Use $this->newDependency wherever the new dependency is needed
...
}
}
© 2016 Magento, Inc. Page | 40
PHP - Prohibited Code Changes
• Modifying the default values of
optional arguments in public and
protected methods
• Removing or renaming constants
© 2016 Magento, Inc. Page | 41
The main rule is that backwards compatibility
is more important than niceness and effort of
the implementation.
© 2016 Magento, Inc. Page | 42
Do all backward
compatible fixes look
ugly because we are not
allowed to make
refactoring?
© 2016 Magento, Inc. Page | 43
Coupling Between Objects Reaches Its Limit with
a New Dependency
© 2016 Magento, Inc. Page | 44
We MUST do continuous Refactoring!
Backward Compatibility should not be an excuse
for not doing refactoring!
© 2016 Magento, Inc. Page | 45
Refactoring objects that
reach their dependency limit
© 2016 Magento, Inc. Page | 46
© 2016 Magento, Inc. Page | 47
© 2016 Magento, Inc. Page | 48
Preserve public and protected class
interfaces to maintain backwards
compatibility.
© 2016 Magento, Inc. Page | 49
© 2016 Magento, Inc. Page | 50
Turn the existing class into a facade to
prevent existing usages of the
refactored methods from breaking.
© 2016 Magento, Inc. Page | 51
© 2016 Magento, Inc. Page | 52
The old public/protected methods
should be marked as deprecated
with the @see tag to suggest the new
implementation for new usages.
© 2016 Magento, Inc. Page | 53
Remove all unused private properties
and methods.
© 2016 Magento, Inc. Page | 54
Mark as deprecated unused protected
properties. Remove the variable type
indicated in the DocBlock to remove
the dependency.
© 2016 Magento, Inc. Page | 55
© 2016 Magento, Inc. Page | 56
© 2016 Magento, Inc. Page | 57
To preserve the constructor signature:
• Remove type hinting for unused parameters to
remove dependency on their type.
• Add @SuppressWarnings(PHPMD.UnusedForm
alParameter) for unused parameters.
© 2016 Magento, Inc. Page | 58
© 2016 Magento, Inc. Page | 59
This is how Backward
Compatible fix should
look like
© 2016 Magento, Inc. Page | 60
Q & A
@iminyaylo

More Related Content

What's hot

Multi-Source Inventory. Imagine. Las Vegas. 2018
Multi-Source Inventory. Imagine. Las Vegas. 2018Multi-Source Inventory. Imagine. Las Vegas. 2018
Multi-Source Inventory. Imagine. Las Vegas. 2018Igor Miniailo
 
Backwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLBackwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLIgor Miniailo
 
Magento Storefront architecture
Magento Storefront architectureMagento Storefront architecture
Magento Storefront architectureIgor Miniailo
 
CamundaCon 2018: Cawemo: Collaborating on Workflow Automation (Camunda)
CamundaCon 2018: Cawemo: Collaborating on Workflow Automation (Camunda)CamundaCon 2018: Cawemo: Collaborating on Workflow Automation (Camunda)
CamundaCon 2018: Cawemo: Collaborating on Workflow Automation (Camunda)camunda services GmbH
 
Mli 2017 technical m2 developer experience
Mli 2017 technical m2 developer experienceMli 2017 technical m2 developer experience
Mli 2017 technical m2 developer experienceHanoi MagentoMeetup
 
2009 Webinar Closets
2009 Webinar Closets2009 Webinar Closets
2009 Webinar Closetsmichaelgrohs
 
ODBC Connector: Update and Improvements
ODBC Connector: Update and ImprovementsODBC Connector: Update and Improvements
ODBC Connector: Update and ImprovementsOdoo
 

What's hot (7)

Multi-Source Inventory. Imagine. Las Vegas. 2018
Multi-Source Inventory. Imagine. Las Vegas. 2018Multi-Source Inventory. Imagine. Las Vegas. 2018
Multi-Source Inventory. Imagine. Las Vegas. 2018
 
Backwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NLBackwards Compatibility Developers Guide. #MM17NL
Backwards Compatibility Developers Guide. #MM17NL
 
Magento Storefront architecture
Magento Storefront architectureMagento Storefront architecture
Magento Storefront architecture
 
CamundaCon 2018: Cawemo: Collaborating on Workflow Automation (Camunda)
CamundaCon 2018: Cawemo: Collaborating on Workflow Automation (Camunda)CamundaCon 2018: Cawemo: Collaborating on Workflow Automation (Camunda)
CamundaCon 2018: Cawemo: Collaborating on Workflow Automation (Camunda)
 
Mli 2017 technical m2 developer experience
Mli 2017 technical m2 developer experienceMli 2017 technical m2 developer experience
Mli 2017 technical m2 developer experience
 
2009 Webinar Closets
2009 Webinar Closets2009 Webinar Closets
2009 Webinar Closets
 
ODBC Connector: Update and Improvements
ODBC Connector: Update and ImprovementsODBC Connector: Update and Improvements
ODBC Connector: Update and Improvements
 

Similar to Backward Compatibility Developer's Guide Webinar

API design best practices
API design best practicesAPI design best practices
API design best practicesIgor Miniailo
 
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZBackward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZIgor Miniailo
 
Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Igor Miniailo
 
API Design Best Practices by Igor Miniailo
API Design Best Practices by Igor MiniailoAPI Design Best Practices by Igor Miniailo
API Design Best Practices by Igor MiniailoMagecom UK Limited
 
Igor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesIgor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesAtwix
 
MageConf 2017, Design API Best Practices
MageConf 2017, Design API Best PracticesMageConf 2017, Design API Best Practices
MageConf 2017, Design API Best PracticesIgor Miniailo
 
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceEugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceMeet Magento Italy
 
Volodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformVolodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformMeet Magento Italy
 
Magento 2.3 Schema and Data Patches
Magento 2.3 Schema and Data PatchesMagento 2.3 Schema and Data Patches
Magento 2.3 Schema and Data Patchesatishgoswami
 
Magento2.3 API Functional Testing
Magento2.3 API Functional TestingMagento2.3 API Functional Testing
Magento2.3 API Functional TestingVishwas Bhatnagar
 
Max Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMax Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMeet Magento Italy
 
Max Pronko - 10 migration mistakes from Magento 1 to Magento 2
Max Pronko - 10 migration mistakes from Magento 1 to Magento 2Max Pronko - 10 migration mistakes from Magento 1 to Magento 2
Max Pronko - 10 migration mistakes from Magento 1 to Magento 2Meet Magento Italy
 
Testing in Magento 2
Testing in Magento 2 Testing in Magento 2
Testing in Magento 2 Igor Miniailo
 
SFMUG April 2020
SFMUG April 2020SFMUG April 2020
SFMUG April 2020Jeff Canada
 
Experience in Magento Community Projects
Experience in Magento Community ProjectsExperience in Magento Community Projects
Experience in Magento Community ProjectsMagecom UK Limited
 
Using Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesUsing Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesRenu Mishra
 
Magento Function Testing Framework - Intro and Overview
Magento Function Testing Framework - Intro and OverviewMagento Function Testing Framework - Intro and Overview
Magento Function Testing Framework - Intro and OverviewTom Erskine
 
Oleksii Korshenko - Magento 2 Backwards Compatible Policy
Oleksii Korshenko - Magento 2 Backwards Compatible PolicyOleksii Korshenko - Magento 2 Backwards Compatible Policy
Oleksii Korshenko - Magento 2 Backwards Compatible PolicyMeet Magento Italy
 
Everything about the magento open source 2
Everything about the magento open source 2Everything about the magento open source 2
Everything about the magento open source 2Clap Creative
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 

Similar to Backward Compatibility Developer's Guide Webinar (20)

API design best practices
API design best practicesAPI design best practices
API design best practices
 
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZBackward Compatibility Developer's Guide in Magento 2. #MM17CZ
Backward Compatibility Developer's Guide in Magento 2. #MM17CZ
 
Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2Backward Compatibility Developer's Guide in Magento 2
Backward Compatibility Developer's Guide in Magento 2
 
API Design Best Practices by Igor Miniailo
API Design Best Practices by Igor MiniailoAPI Design Best Practices by Igor Miniailo
API Design Best Practices by Igor Miniailo
 
Igor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best PracticesIgor Miniailo - Magento 2 API Design Best Practices
Igor Miniailo - Magento 2 API Design Best Practices
 
MageConf 2017, Design API Best Practices
MageConf 2017, Design API Best PracticesMageConf 2017, Design API Best Practices
MageConf 2017, Design API Best Practices
 
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum PerformanceEugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
Eugene Shaksuvarov - Tuning Magento 2 for Maximum Performance
 
Volodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design PlatformVolodymyr Kublytskyi - Develop Product, Design Platform
Volodymyr Kublytskyi - Develop Product, Design Platform
 
Magento 2.3 Schema and Data Patches
Magento 2.3 Schema and Data PatchesMagento 2.3 Schema and Data Patches
Magento 2.3 Schema and Data Patches
 
Magento2.3 API Functional Testing
Magento2.3 API Functional TestingMagento2.3 API Functional Testing
Magento2.3 API Functional Testing
 
Max Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & QualityMax Yekaterinenko - Magento 2 & Quality
Max Yekaterinenko - Magento 2 & Quality
 
Max Pronko - 10 migration mistakes from Magento 1 to Magento 2
Max Pronko - 10 migration mistakes from Magento 1 to Magento 2Max Pronko - 10 migration mistakes from Magento 1 to Magento 2
Max Pronko - 10 migration mistakes from Magento 1 to Magento 2
 
Testing in Magento 2
Testing in Magento 2 Testing in Magento 2
Testing in Magento 2
 
SFMUG April 2020
SFMUG April 2020SFMUG April 2020
SFMUG April 2020
 
Experience in Magento Community Projects
Experience in Magento Community ProjectsExperience in Magento Community Projects
Experience in Magento Community Projects
 
Using Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL QueuesUsing Magento 2.3 MySQL Queues
Using Magento 2.3 MySQL Queues
 
Magento Function Testing Framework - Intro and Overview
Magento Function Testing Framework - Intro and OverviewMagento Function Testing Framework - Intro and Overview
Magento Function Testing Framework - Intro and Overview
 
Oleksii Korshenko - Magento 2 Backwards Compatible Policy
Oleksii Korshenko - Magento 2 Backwards Compatible PolicyOleksii Korshenko - Magento 2 Backwards Compatible Policy
Oleksii Korshenko - Magento 2 Backwards Compatible Policy
 
Everything about the magento open source 2
Everything about the magento open source 2Everything about the magento open source 2
Everything about the magento open source 2
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 

More from Igor Miniailo

Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)Igor Miniailo
 
Architecture and workflow of Multi-Source Inventory
Architecture and workflow of Multi-Source InventoryArchitecture and workflow of Multi-Source Inventory
Architecture and workflow of Multi-Source InventoryIgor Miniailo
 
Dare to Share Magento Community Engineering
Dare to Share Magento Community Engineering Dare to Share Magento Community Engineering
Dare to Share Magento Community Engineering Igor Miniailo
 
Magento Developer Talk. Microservice Architecture and Actor Model
Magento Developer Talk. Microservice Architecture and Actor ModelMagento Developer Talk. Microservice Architecture and Actor Model
Magento Developer Talk. Microservice Architecture and Actor ModelIgor Miniailo
 
Applying Code Customizations to Magento 2
Applying Code Customizations to Magento 2 Applying Code Customizations to Magento 2
Applying Code Customizations to Magento 2 Igor Miniailo
 
Modular development in Magento 2
Modular development in Magento 2Modular development in Magento 2
Modular development in Magento 2Igor Miniailo
 
Мониторинг веб приложений на PHP в режиме реального времени с помощью Pinba. ...
Мониторинг веб приложений на PHP в режиме реального времени с помощью Pinba. ...Мониторинг веб приложений на PHP в режиме реального времени с помощью Pinba. ...
Мониторинг веб приложений на PHP в режиме реального времени с помощью Pinba. ...Igor Miniailo
 
Сommand Query Responsibility Segregation (CQRS) - Отделяем Мух от Котлет
Сommand Query Responsibility Segregation (CQRS) - Отделяем Мух от КотлетСommand Query Responsibility Segregation (CQRS) - Отделяем Мух от Котлет
Сommand Query Responsibility Segregation (CQRS) - Отделяем Мух от КотлетIgor Miniailo
 

More from Igor Miniailo (8)

Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
Magento 2 Automated Testing via examples of Multi-Source Inventory (MSI)
 
Architecture and workflow of Multi-Source Inventory
Architecture and workflow of Multi-Source InventoryArchitecture and workflow of Multi-Source Inventory
Architecture and workflow of Multi-Source Inventory
 
Dare to Share Magento Community Engineering
Dare to Share Magento Community Engineering Dare to Share Magento Community Engineering
Dare to Share Magento Community Engineering
 
Magento Developer Talk. Microservice Architecture and Actor Model
Magento Developer Talk. Microservice Architecture and Actor ModelMagento Developer Talk. Microservice Architecture and Actor Model
Magento Developer Talk. Microservice Architecture and Actor Model
 
Applying Code Customizations to Magento 2
Applying Code Customizations to Magento 2 Applying Code Customizations to Magento 2
Applying Code Customizations to Magento 2
 
Modular development in Magento 2
Modular development in Magento 2Modular development in Magento 2
Modular development in Magento 2
 
Мониторинг веб приложений на PHP в режиме реального времени с помощью Pinba. ...
Мониторинг веб приложений на PHP в режиме реального времени с помощью Pinba. ...Мониторинг веб приложений на PHP в режиме реального времени с помощью Pinba. ...
Мониторинг веб приложений на PHP в режиме реального времени с помощью Pinba. ...
 
Сommand Query Responsibility Segregation (CQRS) - Отделяем Мух от Котлет
Сommand Query Responsibility Segregation (CQRS) - Отделяем Мух от КотлетСommand Query Responsibility Segregation (CQRS) - Отделяем Мух от Котлет
Сommand Query Responsibility Segregation (CQRS) - Отделяем Мух от Котлет
 

Recently uploaded

Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...instagramfab782445
 
How to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdfHow to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdfOffice Furniture Plus - Irving
 
The hottest UI and UX Design Trends 2024
The hottest UI and UX Design Trends 2024The hottest UI and UX Design Trends 2024
The hottest UI and UX Design Trends 2024Ilham Brata
 
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best ServiceHigh Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
ab-initio-training basics and architecture
ab-initio-training basics and architectureab-initio-training basics and architecture
ab-initio-training basics and architecturesaipriyacoool
 
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...Nitya salvi
 
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best ServiceIndependent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证wpkuukw
 
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...Amil baba
 
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...sriharipichandi
 
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherry
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime PondicherryPondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherry
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherrymeghakumariji156
 
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789CristineGraceAcuyan
 
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...Nitya salvi
 
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Nitya salvi
 
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样awasv46j
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationZenSeloveres
 
Lecture 01 Introduction To Multimedia.pptx
Lecture 01 Introduction To Multimedia.pptxLecture 01 Introduction To Multimedia.pptx
Lecture 01 Introduction To Multimedia.pptxShoaibRajper1
 
Simple Conference Style Presentation by Slidesgo.pptx
Simple Conference Style Presentation by Slidesgo.pptxSimple Conference Style Presentation by Slidesgo.pptx
Simple Conference Style Presentation by Slidesgo.pptxbalqisyamutia
 
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKLANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKMarekMitek1
 
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service AvailableCall Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service AvailableNitya salvi
 

Recently uploaded (20)

Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
Abortion pill for sale in Muscat (+918761049707)) Get Cytotec Cash on deliver...
 
How to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdfHow to Create a Productive Workspace Trends and Tips.pdf
How to Create a Productive Workspace Trends and Tips.pdf
 
The hottest UI and UX Design Trends 2024
The hottest UI and UX Design Trends 2024The hottest UI and UX Design Trends 2024
The hottest UI and UX Design Trends 2024
 
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best ServiceHigh Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
High Profile Escorts Nerul WhatsApp +91-9930687706, Best Service
 
ab-initio-training basics and architecture
ab-initio-training basics and architectureab-initio-training basics and architecture
ab-initio-training basics and architecture
 
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
Just Call Vip call girls Kasganj Escorts ☎️8617370543 Two shot with one girl ...
 
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best ServiceIndependent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
 
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
一比一定(购)滑铁卢大学毕业证(UW毕业证)成绩单学位证
 
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
NO1 Top Pakistani Amil Baba Real Amil baba In Pakistan Najoomi Baba in Pakist...
 
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
Anupama Kundoo Cost Effective detailed ppt with plans and elevations with det...
 
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherry
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime PondicherryPondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherry
Pondicherry Escorts Service Girl ^ 9332606886, WhatsApp Anytime Pondicherry
 
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
 
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
Call Girls In Ratnagiri Escorts ☎️8617370543 🔝 💃 Enjoy 24/7 Escort Service En...
 
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
Just Call Vip call girls Fatehpur Escorts ☎️8617370543 Two shot with one girl...
 
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
一比一原版(WLU毕业证)罗瑞尔大学毕业证成绩单留信学历认证原版一模一样
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentation
 
Lecture 01 Introduction To Multimedia.pptx
Lecture 01 Introduction To Multimedia.pptxLecture 01 Introduction To Multimedia.pptx
Lecture 01 Introduction To Multimedia.pptx
 
Simple Conference Style Presentation by Slidesgo.pptx
Simple Conference Style Presentation by Slidesgo.pptxSimple Conference Style Presentation by Slidesgo.pptx
Simple Conference Style Presentation by Slidesgo.pptx
 
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEKLANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
LANDSCAPE ARCHITECTURE PORTFOLIO - MAREK MITACEK
 
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service AvailableCall Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
Call Girls Jalaun Just Call 8617370543 Top Class Call Girl Service Available
 

Backward Compatibility Developer's Guide Webinar

  • 1. © 2016 Magento, Inc. Page | 1 Backward Compatibility Developer’s guide Igor Miniailo Magento 2 Architect
  • 2. © 2016 Magento, Inc. Page | 2
  • 3. © 2016 Magento, Inc. Page | 3 The main reason we reject a community Pull Request (PR) or request additional changes is that the code is not compliant with our Technical Vision and/or Backward Compatibility Policy.
  • 4. © 2016 Magento, Inc. Page | 4
  • 5. © 2016 Magento, Inc. Page | 5
  • 6. © 2016 Magento, Inc. Page | 6
  • 7. © 2016 Magento, Inc. Page | 7 • Magento 2 Technical Guidelines • Versioning • Backward Compatibility Development Guide
  • 8. © 2016 Magento, Inc. Page | 8 Why does BC matter? For merchants, the process must be cost-effective, while developers want their extensions to be forward- compatible for as long as possible.
  • 9. © 2016 Magento, Inc. Page | 9 Does Magento have to evolve? Does every change in code bring backward incompatibility?
  • 10. © 2016 Magento, Inc. Page | 10 Keep Magento backwards compatible vs. improving it?
  • 11. © 2016 Magento, Inc. Page | 11 We MUST do BOTH
  • 12. © 2016 Magento, Inc. Page | 12 Backward Compatible Fix *it works (most of the time), but code quality is far from good enough
  • 13. © 2016 Magento, Inc. Page | 13 Backward Compatibility policy for Magento code
  • 14. © 2016 Magento, Inc. Page | 14 Semantic Versioning Version numbers are in the format MAJOR.MINOR.PATCH, where: – MAJOR indicates incompatible API changes – MINOR indicates backward-compatible functionality has been added – PATCH indicates backward-compatible bug fixes
  • 15. © 2016 Magento, Inc. Page | 15 The backward compatibility policy applies to PHP code annotated with @api
  • 16. © 2016 Magento, Inc. Page | 16 Public and Private code
  • 17. © 2016 Magento, Inc. Page | 17 Public vs Private code Private code is not supposed to be used by third party modules, so, in most cases, its modifications will only trigger PATCH version bumps. Changes in public code always trigger MINOR or MAJOR version bumps.
  • 18. © 2016 Magento, Inc. Page | 18 What examples of Public code Magento has? • PHP Interface (marked with @api) • PHP Class (marked with @api) • Javascript Interface (marked with @api) • Javascript Class (marked with @api) • Virtual Type (marked with @api) • URL paths • Console commands and their arguments • Less Variables & Mixins • Message queue topics and their data types • UI component declarations • Layout handles declared by modules • Events triggered by component (both static dynamic) • Schema of configuration types introduced by module • Structure of System Configuration fields used by module
  • 19. © 2016 Magento, Inc. Page | 19 API vs SPI (Extension Points) A PHP Interface in Magento can be used several ways by the core product and extension developers. • As an API. is a set of interfaces and their implementations that a module provides to other modules • As a Service Provider Interface (SPI). is a set of interfaces that a module uses internally and allows their implementation by other modules. • As both. APIs and SPIs are not mutually exclusive.
  • 20. © 2016 Magento, Inc. Page | 20 After the code is released, both API and SPI can be evolved in a backwards-compatible way. But both have their specific limitations.
  • 21. © 2016 Magento, Inc. Page | 21
  • 22. © 2016 Magento, Inc. Page | 22
  • 23. © 2016 Magento, Inc. Page | 23
  • 24. © 2016 Magento, Inc. Page | 24
  • 25. © 2016 Magento, Inc. Page | 25
  • 26. © 2016 Magento, Inc. Page | 26 We do not distinguish them separately. SPIs are annotated the same as APIs.
  • 27. © 2016 Magento, Inc. Page | 27 Who decides whether interface/class belong to API or SPI? YOU
  • 28. © 2016 Magento, Inc. Page | 28 Dependency Rules API If a module uses (calls) an API, it should be dependent on the MAJOR version. API dependency example { ... "require": { "magento/module-customer": "~100.0", // (>=100.0 <101.0.0) }, ... }
  • 29. © 2016 Magento, Inc. Page | 29 Dependency Rules SPI If a module implements an API/SPI, it should be dependent on the MAJOR+MINOR version. SPI dependency example { ... "require": { "magento/module-customer": "~100.0.0", // (>=100.0.0 <100.1.0) }, ... }
  • 30. © 2016 Magento, Inc. Page | 30 http://devdocs.magento.com/guides/v2.1/release-notes/backward- incompatible-changes-2.1.html
  • 31. © 2016 Magento, Inc. Page | 31 What keeps us from making mistakes? To minimize this risk we have developed a tool Semantic Version Checker Tool that analyzes two code bases and determines what part of the version need updating (MAJOR, MINOR, PATCH). As part of the delivery process, we must run this tool and use the results for input to the Version Setter tool.
  • 32. © 2016 Magento, Inc. Page | 32 Prohibited Code Changes
  • 33. © 2016 Magento, Inc. Page | 33 • Interface/class removal • Public & protected method removal • Introduction of a method to a class or interface PHP - Prohibited Code Changes
  • 34. © 2016 Magento, Inc. Page | 34 MagentoCatalogApiCategoryRepositoryInterface
  • 35. © 2016 Magento, Inc. Page | 35 MagentoCatalogApiCategoryListInterface
  • 36. © 2016 Magento, Inc. Page | 36 PHP - Prohibited Code Changes • Static function removal • Parameter addition in public methods • Parameter addition in protected methods
  • 37. © 2016 Magento, Inc. Page | 37
  • 38. © 2016 Magento, Inc. Page | 38 PHP - Prohibited Code Changes • Method argument type modification • Modification of types of thrown exceptions (unless a new exception is a subtype of the old one) • Constructor modification
  • 39. © 2016 Magento, Inc. Page | 39 class ExistingClass { /** * @var NewDependencyInterface $newDependency */ private $newDependency; public function __construct( OldDependencyIntreface $oldDependency, $oldRequiredConstructorParameter, $oldOptinalConstructorParameter = null, NewDependencyInterface $newDependency = null ) { ... $this>newDependency = $newDependency ?: MagentoFrameworkAppObjectManager::getInstance() ->get(NewDependencyInterface::class); ... } public function existingFunction() { // Existing functionality ... // Use $this->newDependency wherever the new dependency is needed ... } }
  • 40. © 2016 Magento, Inc. Page | 40 PHP - Prohibited Code Changes • Modifying the default values of optional arguments in public and protected methods • Removing or renaming constants
  • 41. © 2016 Magento, Inc. Page | 41 The main rule is that backwards compatibility is more important than niceness and effort of the implementation.
  • 42. © 2016 Magento, Inc. Page | 42 Do all backward compatible fixes look ugly because we are not allowed to make refactoring?
  • 43. © 2016 Magento, Inc. Page | 43 Coupling Between Objects Reaches Its Limit with a New Dependency
  • 44. © 2016 Magento, Inc. Page | 44 We MUST do continuous Refactoring! Backward Compatibility should not be an excuse for not doing refactoring!
  • 45. © 2016 Magento, Inc. Page | 45 Refactoring objects that reach their dependency limit
  • 46. © 2016 Magento, Inc. Page | 46
  • 47. © 2016 Magento, Inc. Page | 47
  • 48. © 2016 Magento, Inc. Page | 48 Preserve public and protected class interfaces to maintain backwards compatibility.
  • 49. © 2016 Magento, Inc. Page | 49
  • 50. © 2016 Magento, Inc. Page | 50 Turn the existing class into a facade to prevent existing usages of the refactored methods from breaking.
  • 51. © 2016 Magento, Inc. Page | 51
  • 52. © 2016 Magento, Inc. Page | 52 The old public/protected methods should be marked as deprecated with the @see tag to suggest the new implementation for new usages.
  • 53. © 2016 Magento, Inc. Page | 53 Remove all unused private properties and methods.
  • 54. © 2016 Magento, Inc. Page | 54 Mark as deprecated unused protected properties. Remove the variable type indicated in the DocBlock to remove the dependency.
  • 55. © 2016 Magento, Inc. Page | 55
  • 56. © 2016 Magento, Inc. Page | 56
  • 57. © 2016 Magento, Inc. Page | 57 To preserve the constructor signature: • Remove type hinting for unused parameters to remove dependency on their type. • Add @SuppressWarnings(PHPMD.UnusedForm alParameter) for unused parameters.
  • 58. © 2016 Magento, Inc. Page | 58
  • 59. © 2016 Magento, Inc. Page | 59 This is how Backward Compatible fix should look like
  • 60. © 2016 Magento, Inc. Page | 60 Q & A @iminyaylo

Editor's Notes

  1. Backward compatibility is a property of a system, product, or technology that allows for interoperability with an older legacy system
  2. We promise to be backward compatible for classes and methods annotated with @api within MINOR and PATCH updates to our components. As changes are introduced, we annotate methods with @deprecated. The methods are removed only with the next MAJOR component version. 
  3. Let’s recap what we had with Magento 1 – where everything is an extension points. All the protected mess and so on. We can’t make changes in contract – all changes suppose to extend existing contract.
  4. Tilde = Significant Release Operator