Monolithic vs Modular

Monolithic vs Modular

It is very easy to develop a complete app all in one file. Of course it’s a very bad practice and it should (must) be avoided. But it is not because you create tons of files and classes that you gain anything in your app. Of course you now have tons a small classes and you have now very small pieces of code which is a good starting point. Unfortunately it’s like building a huge castle made out of small bricks but all your bricks are fully glued and thus all your code will move in one piece (once you have build your castle you will have to move it all at once).

What about building a nice one piece castle

It could be a very good situation if your intention is to have only one big castle that will stay there forever, without changing and all the users will have to adapt themselves to the castle. But as we all know, some users will start to want new features. One way of handling that is to rebuild the castle once in a while, from scratch. That’s good if your competitors are bad and if your customers are ready to wait but in our time of fast moving this is generally the sign that you will die. You could also wait for the competition to start building a new castle and at the right time attack this castle and buy it as your new castle. This is not really different from starting from scratch except you kill one of your competitor at the same time.

Be smart, anticipate

The real smart guy will think upfront and start envisioning potential changes. But for those changes to be easy to handle, one has to think about the architecture of the castle before building it and think about this architecture as something modular. The good way of doing that is to define the correct granularity and abstraction inside your architecture and reinforce that architecture inside all the app. Then adding a new feature to the castle becomes easy, fast and you even become fast enough to concretely kill the competition before it even starts.

Define your architecture and apply it all the time to every parts of your code.