webuild-community / federated-blog

A federated blog platform built for WeBuild Community
https://read.webuild.community/
58 stars 34 forks source link

Is this better than using switch? #77

Closed 0xlkda closed 3 years ago

huytd commented 3 years ago

Looks good but I have a concern about simplicity. It might make the code shorter but maintainability is also a critical part, personally, I want to write simple code that allows any developer at any level could understand at the first glance.

0xlkda commented 3 years ago

Yes, simplicity is pure gold but using object literals make it easy to test and more performance O(n) vs O(1). In another situation it's better to manage state at 1 place rather than 4 places

huytd commented 3 years ago

Maybe we can apply this technique in some other place of the code, I think there is a lot of other place that need this in the codebase rather than this simple component.

0xlkda commented 3 years ago

If it is good enough for this simple component then we can merge it then incrementally update another component when we have time, no problem. 👍

0xlkda commented 3 years ago

any update?

lqt93 commented 3 years ago

Thank you for your suggestion but as @huytd said above, this component is quite simple and doesn't need to have more efforts on it at the moment. In addition, using object literal like that might cause unexpected mistakes in case the component has its params changes. It can be said that, we will choose a safe style of code rather than a fancy one. To clarify the way we write code, I think we would make a code style convention in this project soon.

I will close this PR here. If you have any ideas to help us work better please feel free to open an issue and we can discuss more. And there are still lots of issues need to take care, I hope that you can help us by taking one of them.