I was wondering how everyone organizes his code. Talking internals, not how to organize files.
Meaning, I put all extra requests like POST /post/:id/vote
in the model. And make routes responsible for getting and setting the data into the controller. And also pass the definitions into outlets, instead of used {{render controller}}
.
Also i keep controller to the minimal, responsible for paging if a list view, and if element should be shown or hidden, and all other ui related stuff.
As for components i used it for plugins, making custom controls. And sometimes reusable elements like post-item
.
So for me it gets down to this.
- Models: Handle outside requests to my api
- Routes: General structure, and all logic
- Controllers: UI logic
- View: UI element logic
- Components: Everything repeatable. From buttons to templates
But sometime there is a point where you don’t know how to put your code, like if i have a follow button
, where should this be? For creating new post, it can be accessible from everywhere, where do you put that?
How do you structure your app?