Comments (6)
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.
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.
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.
Actually does AOP work with final classes?
from kickasscommerce.
Woo thanks for the input @IvanChepurnyi
from kickasscommerce.
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)
- The repo knows to much
- We suck at FE HOT 1
- We suck at designing logos HOT 6
- Lots of * in the composer.json HOT 1
- Add build processes and code checks to the repo
- Standardise APIs HOT 2
- Invalid cache key HOT 1
- Is SlimPHP the best solution for routing HOT 1
- Are we a lib or a framework? HOT 9
- Session data - how do the cool kids/frameworks handle that? HOT 1
- A bit of admin HOT 7
- Move Moltin bridge to it's own repo HOT 1
- move to Moltin V2 API HOT 3
- Composer.lock should be not in the repo, the project should require PHP 7
- Add in some easy to use DI HOT 13
- Make maps Immutable HOT 2
- Add fancy interceptors HOT 1
- Remove hardcoded dependencies to Moltin in router HOT 3
- Make the cache interceptor wrap bridge class methods instead of repositories
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kickasscommerce.