4 ms·
I generally think the reflex to try to pass an object to an attribute on an element is a code-smell that the element hasn't been properly decomposed into sub-co
by moron4hire 1y ago
I generally think the reflex to try to pass an object to an attribute on an element is a code-smell that the element hasn't been properly decomposed into sub-components. In those cases, I look more to adding child elements to represent those objects as an HTML serialization of the object.
- jongjong 1y agoWow. Yes. Great comment. So glad to come across someone else who fully gets it. Components should 'communicate' with each other. If you start passing elaborate structures, this is getting into the realm of micromanagement, not 'communication'. It means your concerns aren't properly separated. This is not a new theory. Alan Kay, who invented OOP has been saying such things for decades. People got totally the wrong idea about OOP by focusing on mechanisms to allow passing complex structures to each other. That was never the point. Imagine if you worked with other people towards some goal and instead of talking to each other and separating responsibilities, ready-made, complex parts would just come out of people's mouths and everyone tried to make each others' parts fit together as an afterthought... Or imagine trying to catch a taxi and you bring a steering wheel and a tank of petrol with you to give to the taxi driver. It's absurd, obviously so, but that's what a lot of people have been doing with code.