Monolithic vs Modular

Robert Lin
4 min readNov 3, 2016

--

Now that we’ve begun to learn JavaScript and Node.js, it’s time to look into the terms “monolithic” and “modular” in regards to frameworks and libraries. An example of a monolithic framework is Angular.js by Google. An example of a modular framework is Ampersand.js. Let’s begin with some comparisons between the two that can help us distinguish the differences in what they provide.

A brief description:

Monolithic: a monolithic framework typically provides a tightly coupled codebase that makes a lot of assumptions about how the code interacts with each other. It usually includes everything you would need to get a web application up and running quickly.

Modular: as you can guess a modular framework is more minimal and only provides the barebones functionality and structure for your application. Generally only has one “responsibility”. The code is more loosely couple where each part of code communicates in a more or less standard interface.

What does tight or loose coupling mean? Coupling refers to how much code relies on each other, their independence from other code. Tightly coupled code has a higher interdependency but offers more coordination (as the code “knows more” about each other). Loosely coupled code, as you can imagine, has lower interdependency, but offers less coordination (not necessarily worse by any means). What this means is that loosely coupled code rarely needs to be changed because it’s written and designed to interact with other parts of code on a very independent level. It also means that changes to certain code will have less effect on other parts, one of the advantages of modular frameworks.

So much JavaScript

Advantages/Disadvantages:

Monolithic: as mentioned before, a monolithic framework may be easier to hit the ground running quickly. It makes many assumptions and provides standardized code that interacts very well within its own codebase. Its tighter structure allows for that.

However, you have less control over how you want your code to look or what you want it to do. That is, a monolithic framework is very “opinionated” in how something should be done. It’s more rigid. Debugging becomes more difficult with a monolithic framework as well. The code is an inherent part of the framework. Replacing it with a workaround can be very expensive and risky as you have to understand the codebase extremely well. Long term maintenance becomes an issue as you either have to replace the entire framework if it’s not fitting your needs (of something such as scalability) or find developers who either know the language of your specific framework or have to be taught entirely. Because replacing your entire framework likely comes with a lot issues, you may just be stuck with what you have.

Modular: modular frameworks provide code that is more reusable and it fits the definition of modularity perfectly. The code is organized independently and can be easily swapped in and out. If certain code is broken, you don’t have to spend a lot of time searching for the bug as it’s easier to locate the source. Having a spread out distribution of code allows for better maintainability in the long run. If there is something that does not work as you like, you can swap in another framework that suits your needs. You have more control over your codebase.

A disadvantage of using modular frameworks is that it may be harder initially to get your project started. Modular frameworks don’t provide enough out-of-the-box to build a web app right away.

When you choose a framework, you make a large, long term commitment. You sign up to learn about the framework’s various inner workings and strange behaviors. You also sign up to a period of ineffectiveness whilst you’re getting to grips with things. If the framework turns out to be the wrong bet, you lose a lot. But if you pick and choose from libraries, you can afford to replace one part of your front end stack whilst retaining the rest. — Jimmy Breck-McKye, The State of JavaScript in 2015,

In the short term, a monolithic framework can provide you everything that you need to start fast. It could be advantageous to have a working application out early. If your app is small, monolithic can be the way to go. However, in the long term, if you foresee larger growth and scaling, it seems utilizing modular frameworks to build an application is the better choice, providing you more choice and maintainability.

Source: “Monolithic vs. modular — what’s the difference?” — joepie91 (https://gist.github.com/joepie91/7f03a733a3a72d2396d6)

--

--

Robert Lin

Currently a Full Stack Web Development Student at Flatiron School. An avid problem solver looking to build web applications of the future!