DEV Community

Rupesh Krishna Jha
Rupesh Krishna Jha

Posted on

What are the best practices for MEAN stack web development ?

Top comments (11)

Collapse
 
sagarb3 profile image
Sagar Bhattacharya
  1. Following a good style-guide

  2. Keeping the code functional and simple

  3. Understanding the difference between arrow function , function with function keyword , a basic understanding of this.

  4. Be aware of the event the node or web environment provide

  5. Avoiding duplicate code as much as possible , even if you feel you are duplicating code try to create a common service and as soon as you done with that remove duplicate code.

  6. Proper Error Handling on priority

  7. Understanding critical points of memory leak

  8. If their are some tasks like cron-jobs if possible run them as a separate micro-service called jobs totally outside of the application scope

  9. Use observables and behaviour subject for handling event change and try to avoid timeout as much as possible

  10. Divide the project into modules and identify the scope of services

  11. Learn aggregation.

  12. Learn about capped and ttl collection

  13. Proper Index Creation is must for giving performance boost

  14. Config must be properly developed

  15. Caching should be learnt on priority and various caching strategy available analysed

  16. Don't block the event loop.

  17. Refactor your code , avoid duplicates and write unit test cases

  18. Learn basics about ec2-instances , remote deployment , linux environment , docker.

  19. Git skills are a must

  20. Learn to create local packages and use them

  21. Learn about creating micro-services

  22. Please try and keep upgrading the node , angular version

  23. MongoDb atlas must be given a try

Collapse
 
rupeshiya profile image
Rupesh Krishna Jha

Thanks a lot @sagar for this awesome guide !!

Collapse
 
sagarb3 profile image
Sagar Bhattacharya

MongoDb is a real dbms , it's non-relational and have bson based structure , it has support for lookups , aggregation , indexing ( Select , Insert , Update and Delete ) and with latest stream api it now also supports triggers , and the whole benefit of mongo is of not having a fixed structure and it's flexibility. We cannot compare orange and apple and say one is not a fruit based on the other one's definition

Collapse
 
rupeshiya profile image
Rupesh Krishna Jha

thanks @artemix , Since I don't have much experience with RDBMS so can you please share some resource where I can read the code of the project implemented with RDBMS like MySql etc. and can learn from those projects .

Collapse
 
larswaechter profile image
Lars Wächter

I find this quite helpful:
github.com/i0natan/nodebestpractices

Collapse
 
rupeshiya profile image
Rupesh Krishna Jha

It's awesome @Lars
Thanks for sharing.

Collapse
 
thespiciestdev profile image
James Allen

On the subject of replacing parts of MEAN, also replace Express with Nestjs (it wraps Express under-the-hood, but aligns with your Angular code!)

Collapse
 
sagarb3 profile image
Sagar Bhattacharya

I tried nestjs , but felt it restricts a user into learning nest and it's pattern, while express gives a user a freehand into understanding nodejs , nest is more like angular styled nodejs which seems very restrictive on the server side and I felt not much of an advantage

Thread Thread
 
thespiciestdev profile image
James Allen

While Nestjs is a framework and it does have its own approach to things, you can still interface directly with the underlying express instance.

I suggest exploring dependency injection on your server side, it was the 2nd reason I chose to start with Nestjs (1st again being it aligns so well with my Angular code!)

Collapse
 
rupeshiya profile image
Rupesh Krishna Jha • Edited

Thanks @james ,I will definately give it a try .

 
rupeshiya profile image
Rupesh Krishna Jha

Thanks a lot @artemix for sharing this resources !!