8 ms·
I've never understood how people view the separation of template, styles, and business logic into separate files as simpler. Now, to work on a single component,
by JMTQp8lwXL 7y ago
I've never understood how people view the separation of template, styles, and business logic into separate files as simpler. Now, to work on a single component, I need to open three files in my editor, instead of one.
- Marazan 7y agoIt is an over reaction to bad PHP. Bad PHP pages mixes all kinds of shit together. This leads to the thought that to do it 'good' everything needs to be seperated. It's a wrong thought but I see how people got there.
- brylie 7y agoThe "separate files" argument is a red herring. It is really about separate "mindsets" or "modes of thinking". In effect, JavaScript logic tends to be procedural/imperative, while templates allow declarative semantics, and styles are nearly a 2.5D constraint language. "Separation of concerns" here means only having to think in a particular mode, rather than blending all of those modes of thought into a single eyespan. Notably, Vue allows for single-file components, while preserving the familiar and intentionally designed separation of declarative (HTML), imperative (JavaScript), and aesthetic (CSS) code.
- JMTQp8lwXL 7y agoI don't see how separate files forces you to think differently. It might aid in that effort, but it likely doesn't force it.
- gorbypark 7y agoIn vue (or atleast the way the majority of people use vue), each component is separated into a .vue file. That component's template, style and business logic is all encapsulated in that one file. A basic .vue file starts out with <template></template><style></style><script></script>. It keeps everything nice and simple, in my opinion. Each different "mode of thinking" is separated out, but still all together in one file.