Maintainability Through Colocation
kentcdodds.com
Maintainability Through Colocation
1–4 of 4 posts
Re: Maintainability Through Colocation
#2Very much agree with this, and I tend to make similar decisions, including strongly preferring CSS in JS frameworks.
The one item I'd caveat though is colocation of state. The author is right that often it is best to colocate state with the component that needs it. On the other hand though, often the state cannot be decoupled in this way and you have interactions between states of different components; in these cases, it is often better to colocate all the state together in one place. That is the essence behind e.g. stores like redux in web programming.
Re: Maintainability Through Colocation
#3Why not colocate your database queries and business logic inside of your view/template/stylesheet? Just put it all in one file.
Re: Maintainability Through Colocation
#4Why not colocate your database queries and business logic inside of your view/template/stylesheet? Just put it all in one file.
I do it in React using hooks. For example with GraphQL queries.