Prefer decorators over events?
As mentioned in a previous post, I am currently working on my framework 'Phespro'. One of my goals is, to make it very extensible while keeping it super simple.
When I began programming, I was overwhelmed by the sheer amount of things I would need to learn when using frameworks. Today I have no problem understanding the different approaches and concepts. But for a beginner, this is a very hard thing. Therefore I would like to reduce the required knowledge, new developers need to learn when starting with Phespro.
You never have enough events
Many systems rely on events and filters for providing extensibility. But in my experience, none of those systems have enough of those events. I regulary run into the problem that extension points are missing.
Use decorator pattern instead of events
When you think about it, there is already something that is comparable to events. The decorator pattern can be used to solve the exact same problems, which are solved with event systems.
So instead of manually adding thousands and thousands of events (which even slow down the system), the simpler way is, to write your services following SOLID principles and use a dependency injection container to enable decorating the services.
Because of those assumptions, I will not add an event system to Phespro.
But if you need an event system in Phespro, don't hesitate to add one to your installation. This should be super simple.Back to Posts