Breaking the Rules of the MEAN Stack

If you were learning to program back in the old days then you remember that the LAMP stack was all the rage. Linux, Apache, MySQL, and PHP. Everything you needed to create a great web application. Can you believe that Facebook started out as a simple LAMP stack application? Now that the MEAN stack is all the rage I want to make sure you’re not putting together SPA’s using that stack as prescribed because “that’s how it’s done”. Remember, the one rule trumps all others is that you use the right tool for the job. I’ll explain here what the MEAN stack is, how it’s used, and how to know when to break the rules.

These days single page apps (SPA’s) are all the rage and so LAMP became lame and everyone started learning the MEAN Stack. MongoDB, Express, Angular.js, and Node.js. This stack allowed developers to build rich back-end web APIs with the added bonus of making it super easy to build single page applications quickly using Angular.js and AJAX requests,

Everyone knows you should use the right tools for the job so remember that the LAMP and MEAN stacks should be taken more like suggestions rather than hard and fast rules. Your mileage may vary, see official contest rules, no purchase necessary for entry, and so on… Anyway, on with the MEAN stack:

MongoDB is a schema-less NoSQL (non-relational) database. This means that you can use it to store data that doesn’t conform to a specific schema and can make schemas up on the fly. Each record you save can have different keys and values.

Express is a Node.js framework for building web applications quickly. No need to worry about how you’ll handle requests and responses. Just use Express and focus on building out your app. Express is like the Sinatra of the Node world.

Angular is a front-end JavaScript framework that allows you to build single page apps. It was one of the first of it’s kind along with Ember.js and others. These days we have more options like the newer React framework. If you plan to build a single page app then you can swap this out with React, Ember, or another front-end JavaScript framework. There are more than enough frameworks for us to choose from these days. We really are spoiled for choice.

Node.js is the JavaScript language running on the back-end. Chrome’s V8 JavaScript engine was ripped out of the Chrome browser and used as the basis for Node’s runtime engine. Node.js is exactly the same as JavaScript with the only difference being that it gets run on the server side and it comes with some features that browser-based JS doesn’t come with (like the module features, the process object, access to the OS and file system, and more).

The MEAN stack is the new hot thing right now. But all good developers know that while you should definitely try out as many new things as possible, nothing lasts forever and the MEAN stack’s time started running out the moment it became a thing like so many other tech stacks before it (remember Nginx, Rails, Rack, and Unicorn?). Be ready to learn ask the next stack when it comes out but don’t jump in right away if you’re unsure. Watch it a while. The MEAN stack is a great example of why.

Like we talked about the MEAN stack includes Mongo, Express, Angular, and Node. The name came about before best practices and competing technologies came out. As far as I’m concerned the “M” and the “A” are now stand-ins for any database and front end JS framework respectively. I’ve built “MEAN” apps that used MySQL and React instead of Mongo and Angular. I’ve also built apps that used both Mongo and MySQL with React (a MMERN stack if you will).

Coding is a science, sure but not an exact one. There are the people who use your app to consider. Those people don’t care about the code – they just want it to work. So if we go back to the old adage “use the right tool for the job” we find that if your proficient enough in programming you can bend the rules of these prescribed stacks so long as they make sense to you.

A Node app doesn’t require you to use MongoDB just because it was marketed toward JavaScript developers. Look at your data. Is it relational? Then use a relational database like Postgres or MySQL. If not then go ahead with MongoDB.

Rules are made to be broken. It just takes a master of those rules to know when it’s time to break them.

Web development

« Getting a Job as a Developer DNS for beginners or How do I connect a domain to my website? »