← Back to context

Comment by pennomi

7 days ago

Code locality has some advantages and some disadvantages.

A “perfect” website has things cleanly separated out between style, logic, and DOM, but that does cause cases where you might have to edit three files every time you change a single widget of your website. Neglecting to do that can leave dead or incorrect code just because the issues do not inherently present themselves to you.

Yes, a perfectly principled programmer would do it right… but have you worked with other people before? They’re not necessarily very reliable.

I'd argue that it's impossible to have locality in all aspects. If your style, logic, and DOM are separated almost certainly you have a separation in domain - you're going to have styles, logic, and DOM concerned with "widgets" in your product and if they're separated by whether they are style or logic that means they can't be correlated by their "widgetness".

Really the decision comes down to whether it's better to separate based on style/logic/dom or on the business domain, and I think at least for web apps, separation by domain wins out in most cases.