DEV Community

Cover image for Understanding MVC-Services for Frontend: VanillaJS

Understanding MVC-Services for Frontend: VanillaJS

Carlos Caballero on October 10, 2019

Introduction This post is the first in a series of three posts that will understand how the MVC architecture works to create frontend ap...
Collapse
 
webdevken profile image
Web Dev Ken

I just stumbled upon your post and carefully studied your code. I think your code is well structured and organized, from the folder structure to the code itself. The namings are good that not even code documentation is needed. I enjoyed reading your code!

However, I would like to add some further thoughts to it. These are by no means criticism:

  • In the User class, the member function uuidv4 could be outsourced in order to use it for future use cases
  • I see you always map the users list in all cases, having a small number it probably doesn't affect the performance, but once 10000 users or more are stored, it might lead to some performance hickups, especially when getting to the limits of the local storage
  • There are no tests, e.g. there are no unit tests for the controller or the service
Collapse
 
webdevken profile image
Web Dev Ken • Edited

Another remark is that the id in the user class gets always re generated, even after reading an existing user from the local storage. So you can't rely on a particular user in this case.

Collapse
 
mdhesari profile image
Mohammad Fazel

Awesome, thank you

Collapse
 
carlillo profile image
Carlos Caballero

You're welcome!

Collapse
 
lmuzquiz profile image
lmuzquiz

Thanks Carlos. Does the first and seconb post of this series could also apply for a Vue app instead of angular or would you change anything?

Collapse
 
carlillo profile image
Carlos Caballero

The second part is exactly equal in Vue and Angular. If there is very interesting, then I could to do a fourth part using Vue!

Thanks for your words!