Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Framework-Agnostic Applications - A story about components

Framework-Agnostic Applications - A story about components

In this talk, I covered some software architecture concepts in order to make more scalable and reusable application code avoiding coupling with framework tools.

Presented at PHP Experience 2018

Lucas Mendes

March 06, 2018
Tweet

More Decks by Lucas Mendes

Other Decks in Programming

Transcript

  1. Framework-agnostic Applications A story about components Lucas Mendes 
 Software

    Architect at Tienda Nube Find me on Twitter: @devsdmf
  2. What you should not expect from this talk? • Code

    snippets • Programming language advertising • Framework advertising • Recipes
  3. What I will cover in this talk? • Software Architecture

    • Object-Oriented principles • Design patterns • Mindset change
  4. “Software architecture refers to the high level structures of a

    software system, the discipline of creating such structures, and the documentation of these structures.” - Wikipedia
  5. Why Components? • Components are reusable • Components are extensible

    • Components are scalable • Components are testable • And we reduce the side-effects when another part of the application changes
  6. An e-commerce platform should… • Have products • Manage the

    stock of these products • Let customers buy something • Generate an order • Receive payments • Delivery the products • And so many other business rules
  7. –Vaughn Vernon “Developing software that delivers true business value is

    not the same as developing ordinary business software. Software that delivers true business value aligns with the business strategic initiatives.”
  8. Domains in an e-commerce platform • Customers • Orders •

    Shipping • Payment • Products • Stock • Discount Coupons • etc…
  9. In Payments, you can pay for… • An Order •

    A Service • A Donation • etc…
  10. In Payments, you can pay with… • Credit card •

    Debit card • Ticket • EFT • Cryptocurrencies • etc…
  11. In Payments, you can pay through… • Cielo • Rede

    • PagSeguro • MoIP • PayPal • Stripe • etc…
  12. Single Responsibility • A Payment Request • A Payment Result

    • A Gateway Implementation • Some payment processors specific implementations • etc…
  13. Open/Closed Principle • PagSeguro has 2 different implementation models: Standard

    and Transparent. • I have a PagSeguro Adapter class that implements the Standard checkout. • Our customers needs Transparent payments too • I should be able to extend the PagSeguro class in order to create a Transparent adapter class
  14. Liskov Substitution Principle • The Payment gateway should be able

    to process a payment using both the PagSeguro adapter as with the PagSeguro Transparent adapter.
  15. Interface Segregation • Each payment service has specific rules like

    authentication, payment methods, installments, taxes, etc… • You should define these behaviors using client-specific interfaces • Authenticable Interface • Installments Interface • Offline Interface • Transparent Interface • etc…
  16. Dependency Inversion • One should “depends upon abstractions, not concretions”.

    • Use Dependency Injection of the abstractions • Use DI containers to care about the concretion of these abstractions
  17. Facades and Services • Write the whole framework-specific code as

    Facades and Services • Inject and integrate it with the framework using tools like Dependency Injection Container, Service Container, etc… • If you need/want to move away from your current framework, you only need to write a new “specific service” that integrates your business component into the framework.
  18. Thank You! Lucas Mendes 
 Software Architect at Tienda Nube

    Find me on Twitter: @devsdmf We’re hiring!