Hacker News new | ask | show | jobs
by mbivert 700 days ago
> In fact, declarative approach does also allow to connect handlers with ease (onclick and similar attributes are very much a thing).

Yup, but it's more limited: consider the modal: you can't — without relying on attributes, or worse, the page's structure — hide the modal when clicking on the little cross, in an onclick attribute.

> The approaches that do scale tend to favour declarative approach with isolated imperative logic

I think it's key regardless of the approach: you want to break down your pages in pieces (e.g. "components"), have them eventually communicate with each others, while keeping those communications as local as possible.

Very much in the same way we design programs over small units (procedure, function, object, etc.).

1 comments

Modals are generally involved in a full-blown Web app. For an average post or article, you don’t need node handles, pure declarative HTML is enough. At the same time, implementing a full-blown app imperatively directly with createElement would result in an unmaintainable mess. In other words, there seem to be very few use cases where such approach is justified.
> For an average post or article, you don’t need node handles

It goes without saying...

> At the same time, implementing a full-blown app imperatively directly with createElement would result in an unmaintainable mess

I disagree, and I've built non-trivial UIs with createElement; a key is to have the discipline to keep the "components" well-isolated.