2 ms·
Component-based file structure is firmly in the "good" column for me. It makes small components much more feasible. If you're forced to split out your view,
by bryanlarsen 12y ago
Component-based file structure is firmly in the "good" column for me. It makes small components much more feasible.
If you're forced to split out your view, your template, your stylesheet, your controller, your model, your business logic, et cetera into separate files you are forced to keep components large.
However, if you have a component-based structure, whenever you notice a very small piece of common functionality it becomes trivial to create a new component for that functionality. You end up with a very large number of very small, very easy to understand components, with clear areas of responsibility.
- marknutter 12y ago> If you're forced to split out your view, your template, your stylesheet, your controller, your model, your business logic, et cetera into separate files you are forced to keep components large. Why exactly does this force you to keep your components large?
- bryanlarsen 12y agoA typical component in my React app contains about 3 lines of HTML. Have you ever seen a 3 line HTML template?
- ben336 12y agoI have. Not uncommon in Backbone development for instance to keep templates in separate files from the views. If the templates are short you can inline them, but sometimes its easier to just be consistent and give every template its own file. It definitely does add friction compared to React though.
- Fishkins 12y ago"force" is certainly an overstatement, but it does add friction to creating small components.