writing extensible applications

Post on 16-Apr-2017

267 Views

Category:

Engineering

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Presentation title here

Writing Extensible Applications

Presentation title here

About meabout me…

Andrey Yatsenco

● PHP Developer at Oro Inc.● 3 years with Symfony ● 6 years with PHP

https://www.facebook.com/yatsencohttps://github.com/anyt

Presentation title here

Writing Extensible Applications

Agenda● Definition● Common solutions● What Symfony offers

Presentation title here

When applications should be extensible?

When you write:● a lot of similar apps● requirements change a lot● a lot of features in one app● open-source

Presentation title here

provide for change (enhancements)● while minimizing impact to existing system

functions.● is a design principle where the

implementation takes future growth into consideration.

● extensions can be through the addition of new functionality or through modification of existing functionality

Extensibility

Presentation title here

Extensible design is to accept that not everything can be designed in advance

Presentation title here

Why code mustbe extensible?

Presentation title here

Typical problems of not extensible apps

● Difficult to replace part of an app● Difficult to scale an application

Presentation title here

Common solutions

● Abstractions and DI● Modular design● Extensions provider● Event-driven architecture

Presentation title here

Common solutions

● Abstractions and DI● Modular design● Extensions provider● Event-driven architecture

Presentation title here

Abstractions and DI

Abstractions: Dependency Injection:

Presentation title here

Common solutions

● Abstractions and DI● Modular design● Extensions provider● Event-driven architecture

Presentation title here

Modular design

Examples:● Symfony● ZF● Yii● Drupal● Joomla● Wordpress● etc.

Naming:● modules● bundles● packages● plugins● service providers● etc.

Presentation title here

Modular design

Make your framework modular:● Symfony HttpKernel component (bundles)

Presentation title here

Modular design

Separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

Presentation title here

Modular design

Bad practices:● High Cohesion● Circular references

Presentation title here

Modular design

Bad practices: How to avoid this?

Presentation title here

Modular design

Bad practices:

How to avoid this?● Event-driven architecture

Presentation title here

Event-driven architecture

● Observer● Mediator

Presentation title here

Event-driven architecture

Observer:

Presentation title here

Event-driven architecture

Mediator

Presentation title here

Modular design

Bad practices:

How to avoid this?● Event-driven architecture● Providing extensions

Presentation title here

Providing extensions

Presentation title here

What Symfony offers?

● Bundles● Service container● Event dispatcher

Presentation title here

What Symfony offers?

Service container● Dependency Injection

Presentation title here

What Symfony offers?

Service container● Overriding classes of services with the

same dependencies with parameters

Presentation title here

What Symfony offers?

Service container● Overriding services in compiler passes with

the same interface or by extending the original one in Compiler Passes

Presentation title here

What Symfony offers?

Service container● Decorating services (new in Symfony 2.5)

Presentation title here

What Symfony offers?

Service container● Providing bundle configuration

Presentation title here

What Symfony offers?

Event dispatcher (mediator pattern)

Presentation title here

What Symfony offers?

You still can provide extension.There is no out of the box solution, because you don’t need it. You can check examples:● Twig● Form

Presentation title here

Conclusion

● Extensions helps you to make addition and modification of your application while minimizing impact to existing functionality.

Presentation title here

Conclusion

Common solutions● Abstractions and DI● Modular design● Extensions provider● Event-driven architecture

Presentation title here

Conclusion

Symfony offers● Bundles● Service container● Event dispatcher

Presentation title here

P.S.

Ideal OO code not the answer, because of performance.You can scale your infrastructure, because it's cheaper than development in some situations but usually not for a long time.

Presentation title here

?

top related