3 ms·
i think this is a case where, if you aren't familiar with htmx, the given example isn't clear. I'll make it more concrete: <div> <button hx-target="#som
by recursivedoubts 4y ago
i think this is a case where, if you aren't familiar with htmx, the given example isn't clear. I'll make it more concrete:
<div>
<button hx-target="#someDiv" ...> ... </button>
<button hx-target="#someDiv" ...> ... </button>
</div>
Here we have two buttons that both target the div `someDiv`. We are repeating that information across both buttons. In an OO language we might be tempted to create a base class or dependency inject this behavior to avoid this repetition, ie to keep things DRY. In htmx, we would hoist this to the parent div:
<div hx-target="#someDiv">
<button ...> ... </button>
<button ...> ... </button>
</div>
This eliminates the code duplication on the two buttons, we are no longer repeating ourselves, but at the cost of sacrificing some locality of behavior. Here, the decrease in LoB is relatively minor, but the further you move from the buttons the more serious the violation is.
I think the concepts hold up, when considered in this light.
- jackblemming 4y agoThat would be called implicit structural coupling for the benefit of reducing syntactic boilerplate. And as you note, sometimes it can be a good trade. Much like functions that have to be called in a specific order are called "temporarily coupled"