GithubHelp home page GithubHelp logo

Comments (12)

Elfayer avatar Elfayer commented on May 9, 2024 1

Hi guys!

Sorry for not being very talkative lately on the subject.
I'm currently in holidays and will take time to look into your answers (which seems very interesting) later this week or next week when I'm back to my office.

from vuejs-component-style-guide.

pablohpsilva avatar pablohpsilva commented on May 9, 2024 1

@Elfayer I think this is good enough. Great job in my opinion!

What do you guys think? @aristidesfl @shailendher @uonick @DannyFeliz

from vuejs-component-style-guide.

pablohpsilva avatar pablohpsilva commented on May 9, 2024

Hello @Elfayer !! I'm super glad to see your help.
Once again I'm gonna thank you for your help: Thank you! :D

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
@vilaboim @shailendher @aristidesfl @uonick @shershen08

from vuejs-component-style-guide.

franciscolourenco avatar franciscolourenco commented on May 9, 2024

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.

from vuejs-component-style-guide.

shershen08 avatar shershen08 commented on May 9, 2024

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.

from vuejs-component-style-guide.

pablohpsilva avatar pablohpsilva commented on May 9, 2024

Hello everyone!
@Elfayer sorry for taking so long to reply.
I strongly agree with all of you. There's no guarantee of knowing exactly when a new component should be created.

What do you think about the following:


Create components when needed

Why?

Vue.js is a component framework based. Not knowing when create components can lead to issues like:

  • If the component is too big, it probably will be hard to (re)use and maintain;
  • If the component is too small, your project gets flooded, harder to make components communicate;

How?

  • Separate components candidates by its functionality;
  • Candidates that looks the same and does the almost the same thing should be merged in one mutable component (e.g.: an <ul> and <ol> components);
  • Complex components can be created. During the development of your application, if the complex component can be broken in more components, do it;
  • Check old components to see if they could be separated in more components;
  • Create component when there's a need for it. A component not well implemented nor designed should not be a component.
  • In general, wait until the code grows to see if some can be reused. Once it can, design your component.

from vuejs-component-style-guide.

franciscolourenco avatar franciscolourenco commented on May 9, 2024

Assuming you are open for discussion on those points, here is my point of view regarding a few:

Candidates that looks the same and does the almost the same thing should be merged in one mutable component (e.g.: an <ul> and <ol> components);

Trying to merge what doesn't need to, can increase complexity of the resulting component.

Check old components to see if they could be separated in more components;

Can be a waste of time. If the component is working, why separate prematurely? Nothing is gained by it and complexity is increased.

from vuejs-component-style-guide.

pablohpsilva avatar pablohpsilva commented on May 9, 2024

@aristidesfl

Like this (?):


Create components when needed

Why?

Vue.js is a component framework based. Not knowing when create components can lead to issues like:

  • If the component is too big, it probably will be hard to (re)use and maintain;
  • If the component is too small, your project gets flooded, harder to make components communicate;

How?

  • Separate components candidates by its functionality;
  • Complex components can be created. During the development of your application, if the complex component can be broken in more components, do it;
  • Create component when there's a need for it. A component not well implemented nor designed should not be a component.
  • In general, wait until the code grows to see if some can be reused. Once it can, design your component.

from vuejs-component-style-guide.

Elfayer avatar Elfayer commented on May 9, 2024

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.

@aristidesfl That's the basic/first approach anyone would have I guess. Not a bad one, it just have couple of problems:

  • You lose time since you could have done it right the first time.
  • You might refactor this component multiple times before getting it right.
  • You might have to rethink every parents/children since the inputs/outputs have to be the same for this new component everywhere it is used. You now know the uses of this new component you want to build, but I'd think more of it as OUT of the project: what it should do, how it should work, how do you want it to be used.

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.

@shershen08 I agree with that.

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.

@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?:

  • Create component when there's a need for it. A component not well implemented nor designed should not be a component.

@pablohpsilva On this one you're right on the last part, but to me the first sentence is a worst case scenario.

  • In general, wait until the code grows to see if some can be reused. Once it can, design your component.

@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?

  • Always remember to build your components for your project needs, but you should also try to think of them being able to work out of it. If they can work out of your project, such as a library, it makes them a lot more robust and consistent;
  • It's always better to build your components as early as possible since it allows you to build your communications (props & events) on existing and stable components.

Rules

  • First, try to build obvious components as early as possible such as: modal, popover, toolbar, menu, header, etc. Overall, components you know for sure you will need later on. On your current page or globally;
  • Secondly, on each new development, for a whole page or a portion of it, try to think before rushing in. If you know some parts of it should be a component, build it;
  • Lastly, if you're not sure, then don't! Avoid polluting your project with "possibly useful later" components, they might just stand there forever, empty of smartness. Note it's better to break it down as soon as you realize it should have been, to avoid the complexity of compatibility with the rest of the project;

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 ! ;)

from vuejs-component-style-guide.

Elfayer avatar Elfayer commented on May 9, 2024

Should we consider this valid?
Where should we add it?
At the very end?

from vuejs-component-style-guide.

pablohpsilva avatar pablohpsilva commented on May 9, 2024

Hello @Elfayer !
I was waiting on others opinion but I think its very good as it is.
Can you make a PR for it (and add your github/twitter at the end of the file)?


@xiaofuzi @wysxhlyy @sqrthree @kciter @shershen08 could you guys translate this new section for the community?

from vuejs-component-style-guide.

linhe0x0 avatar linhe0x0 commented on May 9, 2024

@pablohpsilva Sorry, I missed this message until just now. I have created a PR #46 for this.

from vuejs-component-style-guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.