Skip to content
Luca Ubiali Web Developer

The Intermediate Trap

August 7th, 2024
Continuous Learning

Episode - https://laracasts.com/series/jeffreys-larabits/episodes/40


Think of a Stackoveflow, where users can mark a reply as “best”.

When a replay is marked as best a few things can happen: an activity feed is updated, the user that replied is awarded with XPs, a notification email is sent out.

The intermediate approach to that, in Laravel, would be to create multiple listeners to handle all that.

This approach can be hard to interpret a few months after the initial implementation as it requires browsing through multiple files.

A different approach is to keep it simple: create an action class (or service class, call it however you like) and stick all the logic in there. This type of co-location makes it easier to get the full picture of a specific feature.