6 karma · joined January 24, 2022
There is a but though, don't make PHP your last language, broaden your horizon.
C4 modeling would give you the abstract design or system architecture graph, you don't have to do all 4 levels diagram, just do the one that makes sense to you.
If you are doing something simple, you might not need to do any of that but as soon as you are building something of scale with optimal security not doing system designing is like building a skyscraper with no design, well, you know what might go wrong :)
In a DAW(Digital Audio Workstation), this is like adjusting the knobs, adding effects when you haven't even added any samples, it just doesn't make any sense, stop forcing yourself to do things that doesn't align with your flow, you'll likely get annoyed for no reason.
The way I work is I do the architecture design, I write the code, then I write my test by following the design graph.
If I don't know what the design would look like, I do what I call "code freestyling" to get a basic idea of what the overall design would look like then I repeat the above step.
If you anyone is about to say that isn't open source, well, there is nothing you can do about it, sorry
Event and Event Handlers: I rely heavily on this one, event handlers subscribes to an event or you queue them to a certain event, when that event is emitted, it relays the info to the handlers which do their own thing. This pattern is simple, flexible but can be problematic sometimes (i.e. annoying if there is no async support, tight coupling if you are not careful, etc).
Hookers: This is inspired by the event pattern above, I use this in my Template System. The way it works is I build a base template, then I define the segment (hooks) I want to extend if I am to reuse the base template. Just like event handlers, you also subscribe to hooks but in this case, it is done directly in templates reusing the base.
I took this one step further, you can have hooks within hooks, remove a particular hook with their respective handlers, hook before a hook and hook after a hook. Very flexible and speeds up building page templates.
State Pattern: I use this one for breaking down complex problems, it works but you can easily shoot yourself in the foot.
Pattern makes sense if you understand the "Problem Space", if you do understand the problem you are solving, the pattern to use would come naturally (sometimes you do need to freestyle around to see which would one would make sense)
Give foolishness a break, at least for a week.