lundi 28 mars 2016

Ember.js What should be made a Component?

Basically, if you were given a design of a web page with all kinds of UI patterns/elements, some with interaction and some just static, how would you decide what should be made into a component and what can just stay as html?

This is more of a philosophical question and goes beyond Ember.js; I included it because thats what I'm learning/using right now.

There are some patterns which should obviously be implemented as components, such as tab switchers or filters and my naive reasoning is that they have interaction and are used multiple times on the page. But how far do I go with that? Are each of these reasons sufficient to justify a component or are they only necessary or are they neither? Should a make a button component just because there are many buttons on the page? Should I make a slider component even if I know there will only ever be one slider on the page?

What are good rules of thumb to decide whether to implement something as a component? I could envision creating components for every single thing so that the entire page is just components within components. Surely that is too far? Especially given that Ember's components each have an instantiation cost and lifecycle, theres also a performance aspect to consider when deciding what should be a component right?

I'm interested to hear everybody's viewpoints. Thanks.




Aucun commentaire:

Enregistrer un commentaire