Coder Social home page Coder Social logo

Comments (6)

IvanChepurnyi avatar IvanChepurnyi commented on May 30, 2024 2

AOP is a bad design decision. I don't like interceptors in Magento 2 either (I don't use word plugin here for a reason, as it is not a plugin). If you design SOLID application, your system must follow the Open Closed Principle.

Also, inheritance is a bad decision in majority of the cases as well. Making your code composite has far more benefits and forces you to write architecture that is extensible without actually using "extends".

If you have to extend from a class in order to change the behavior it is a code smell, so your exposed extension points must always have an interface, so anyone can replace implementation without extending from your implementation. It also means you should never use new operator directly, in favor of factories, so at any point of time your concrete class can become an interface.

Hope this one will help you to make the right decision.

from kickasscommerce.

shochdoerfer avatar shochdoerfer commented on May 30, 2024 2

I would not call AOP bad per se, as with any programming practice one needs to know where it is applicable and most importantly where not. Given that we are talking about PHP, in this specific case I would not try to rely on AOP because it will bring lots of code generation with it.

AOP will not work with final classes as the generated code needs to extend the userland classes otherwise you are not able in "replace" the userland classes with the generated code.

from kickasscommerce.

sandermangel avatar sandermangel commented on May 30, 2024 1

So the reason I wanted to use AOP is I believe in real world projects any classes in/output, at some point, will need to changed.
For every method we write the universe makes a client out there with a feature requests that changes it.

So you could use DI, extend the old class, and rewrite whatever you need to rewrite but for me extending classes or replacing them feels like over engineering. Why not make a small class with some annotation, wrap it before, after, around or whatever, change what you need and do this without the rest of the classes having to know about it.

The downside is the 'magic' that happens, It's hard to figure out who's rewriting what, so a tool for that would be handy.
But the benefits of lightweight, conflict free augmentation of existing code outweighs that in my opinion.

from kickasscommerce.

dmanners avatar dmanners commented on May 30, 2024

Actually does AOP work with final classes?

from kickasscommerce.

dmanners avatar dmanners commented on May 30, 2024

Woo thanks for the input @IvanChepurnyi

from kickasscommerce.

adam-paterson avatar adam-paterson commented on May 30, 2024

The more I play around with it and some research I don't think AOP is the right choice for our framework.

from kickasscommerce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.