Sunday 23 September 2018

Separation of concerns with MERN?

So I'm working on trying to teach myself how to not suck with the MERN stack. Already have a lot of good experience with React, trying to get a good handle on the back end. I've made a couple of apps that work great, but the code looks like garbage since there's a thousand different things going on at once in the same file.I'm used to separating out files with React so everything has one or two jobs and that's it - makes it easy to read and manage if stuff needs to change. So, along a similar vein, is there a general practice for separation of concerns with Express / MongoDB handling / etc, or is it more of a 'however the project requirements shape it' kind of thing?As an example - currently in this project I'm using Express, Mongoose, Body-Parser, and Passport. Is there a particular way that I should be handling these libraries in order to separate everything out appropriately? Everything is in one file (minus Routes) and works like a charm but it's also, to put it bluntly, an unreadable clusterfuck, so I'm trying to do this right. If there's any advice, thoughts, or resources that anybody thinks would help, I'd greatly appreciate it. Alternatively if there's any must-read books or must-watch lessons on this, I'm down for it. Thanks!

Submitted September 23, 2018 at 10:39PM by WaifuCannon

No comments:

Post a Comment