3 ms·
I find the single file preferable because it's less clutter. Less open files in the editor, less jumping between documents, and easier to reason about in code r
by root_axis 7y ago
I find the single file preferable because it's less clutter. Less open files in the editor, less jumping between documents, and easier to reason about in code review and when dealing with merge conflicts (since the context of the changes are present in front of you instead of in another file somewhere). If you're editing 3 components at once that's 3 files open instead of 9. The benefits of this are more noticeable when you're trying to debug a frustrating issue but you're not exactly sure where exactly it originates in the code (files open but maybe they don't all get closed as you peruse through, more .
I also find that in a well-architected application, very large components with lots of markup and styles are rare compared to compact and reusable components used to compose the more complex ones which ultimately means the more complex ones also need less styles and markup; really big components might need to exist in some circumstances, but usually it's a code smell. 1 file also means there is less uptake necessary when bootstrapping new components, you don't need to create 3 new files with matching filenames and import statements (yes, you could get an IDE or a script to do it but its just one less thing to think about with the 1 file approach).
Finally, IMO, in the case of components the distinction is more superficial than logical, breaking up a single unit into 3 highly coupled modules that cannot be imported and reused anywhere else feels unnecessary. You wouldn't break up a class with 3 large methods into 3 different modules and import those into the class module.
In the case where I do have to edit a really large files with lots of coupled logic, my editor allows me to view the same file in multiple views at different positions.