3 ms·
> A large part of the advances towards _adaptable_ component-based code comes only when you let go of principles like DRY. > I don't want to think about how th
by chriswarbo 9y ago
> A large part of the advances towards _adaptable_ component-based code comes only when you let go of principles like DRY.
> I don't want to think about how that component exists in a vast web of generic CSS utilities and abstracted decoupled code. Copy and pasting CSS properties is cheap. Conversely overly abstracting your presentational code is a short cut to expensive CSS spaghetti.
You probably know this, but based on your phrasing I just wanted to point out that DRY isn't for mechanically compressing source code; it's for removing 'out of sync' issues, like causing bugs when we forget to update this copy of a procedure when we altered that copy.
Removing such 'conceptual repetition' makes life easier, since (a) we don't need to remember any couplings that need to be kept in sync (this is the "obvious" benefit), but equally importantly (b) if there are multiple copies of something, we don't have to worry about the other ones since they're not related.
It's perfectly fine if many similar chunks of code are scattered around a project, as long as they don't have to be 'kept in sync'. The whole point of "components" (/modules/packages/etc.) is to be self-contained, so it's perfectly reasonable to avoid coupling them together in a "vast web".
Wrong abstraction < Redundancy < Elegant abstraction
- codedokode 9y agoIn CSS if several components have similar styles it is often better to copy-paste because in future you might need to change those components independently.
- Wintamute 9y agoYou're right. I think we're on the same page. I was trying to get across the idea that CSS and visual presentation is a special case, peculiarly unsuited to DRY. Often visual features are only superficially similar ... e.g. at a certain stage in development the "Foo" component is superficially visually similar to the "Bar" component. If we then couple them together by both using the same CSS, but the implementation diverges as new features are added then we've given ourself a headache.