-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New] When should I create a new component ? #39
Comments
Hello @Elfayer !! I'm super glad to see your help. This topic is great, but it's also subjective though. Allow me to think a little bit more about it and I'll come back to you ASAP. Please, if you may/like, invite some friends to help us out. The more people helping, the merrier. Guys, if you can, please, give us your thoughts :D |
I would say, create components only when you need. Wait until the code needs to be reused. Or it grows too big. Like you said, they are not for free. |
I would also propose to think of the whole application or product creation and development not as a finite activity but as a process. In that sense upgrading versions of libraries, adding new features or refactoring your own code are that basically may never end (at least for years, which is an epoch in world of frontend). From that prospective creating new components or refactoring the existing ones may be a subject of change along the way. First you create a large component in some part of the application, later you brake it down to several reusable smaller ones. Those small components evolve and later may be generalized into,again some bigger block (page?) say if it's only used in one place. |
Hello everyone! What do you think about the following: Create components when neededWhy?Vue.js is a component framework based. Not knowing when create components can lead to issues like:
How?
|
Assuming you are open for discussion on those points, here is my point of view regarding a few:
Trying to merge what doesn't need to, can increase complexity of the resulting component.
Can be a waste of time. If the component is working, why separate prematurely? Nothing is gained by it and complexity is increased. |
Hi guys! Sorry for not being very talkative lately on the subject. |
@aristidesfl Like this (?): Create components when neededWhy?Vue.js is a component framework based. Not knowing when create components can lead to issues like:
How?
|
@aristidesfl That's the basic/first approach anyone would have I guess. Not a bad one, it just have couple of problems:
@shershen08 I agree with that.
@shershen08 I think it's the same problem here, the approach isn't wrong, but I believe it's just a bad idea from an architecture point of view. You might have to rethink a lot around the component you are creating. @pablohpsilva I agree with the Why? part. I'm not a fan of the last two points of How?:
@pablohpsilva On this one you're right on the last part, but to me the first sentence is a worst case scenario.
@pablohpsilva Same here, waiting makes it harder and longer because you might have to review the parents & children and even the internal logic of all portion of code you want to replace by this component. Every time this new component occurs. Maybe there are different ways to think about it... How?
Rules
This is just my two neurons brain's ideas about it. Feel free to tell me I'm partially or entirely wrong! Hope to read you soon ! ;) |
@Elfayer I think this is good enough. Great job in my opinion! What do you guys think? @aristidesfl @shailendher @uonick @DannyFeliz |
Should we consider this valid? |
Hello @Elfayer ! @xiaofuzi @wysxhlyy @sqrthree @kciter @shershen08 could you guys translate this new section for the community? |
Translate the 'Create components when needed' part. pablohpsilva#39
@pablohpsilva Sorry, I missed this message until just now. I have created a PR #46 for this. |
This question comes regularly to head for any web component interface.
We learned that a component should be self sufficient and reusable.
The problem is:
It's always complicated to find the right balance.
I wonder if there are key points/ideas that can help bring better web component interfaces.
Imagine a page having the following specifications:
Search field
I think the search field could be a component and assume that it is reusable.
Just so you get an idea of what I have in mind:
It could also be emitting a
search
event to inform the parent of any search trigger, instead of having a prop.Filter toolbar
This component could allow sorting (date, specific data, ...) or even different layouts.
It will have to be strongly coupled to the Result list component. Since it filters the result list.
Should Filter toolbar and Result list components be as one?
Otherwise I'd be creating a component that only works properly with only one of my component library.
Result list
This is just a
v-for
of anything actually.So basically it shouldn't require a component.
But note that the list could be paginated, infinite scrolled, etc.
So maybe there should be some kind of list component?
Something like:
Conclusion
Note the above is just an example!
Feel free to compare the idea to any other situation.
I would like to hear about other's experience on separating components, building pages.
I hope we can find some best practices or key points on that matter.
The text was updated successfully, but these errors were encountered: