I love my MVC …

If this was a comics style blog it would start like this:

They both stood there, the clean and virtues super-hero MVC and his arch-enemy the dirty and corrupt spaghetti-design-pattern… they were both aware that only one of them will prevail.

The fact is that real life is more complicated than that, writing code is an on-going process and sometimes you need to “get things done now” instead of “get things done right”. The important thing is to keep in mind the important notions  that lays behind MVC.

So who is this super-hero? From Wikipedia: Model-View-Controller (MVC) is a design pattern used in software engineering. In complex computer applications that present lots of data to the user, one often wishes to separate data (Model) and user interface (View) concerns, so that changes to the user interface do not impact the data handling, and that the data can be reorganized without changing the user interface. The Model-View-Controller design pattern solves this problem by decoupling data access and business logic from data presentation and user interaction, by introducing an intermediate component- the Controller.

While MVC might take a little more time to design, the notion of decoupling presentation, logic and data layers is imperative. Code that has been written this way can easily be changed without enforcing changes on other layers of code. Because it is a well known fact of life that things always change, agile code makes our life easier and simpler. It is also usually makes the code more comprehensible.

On the other hand you have spaghetti code, it is takes no planning at all but changing it is a nightmare. Moreover, spaghetti code is incomprehensible and as the saying goes: “Always write your code as if the person who will maintain it is a violent psychotic who knows where you live.”

So keep your layers decoupled and live longer and happier.

BTW: if you don’t know which song was playing while I wrote this blog see the title or click here.

Share the love...Tweet about this on TwitterShare on LinkedInShare on Google+Share on Facebook

Amir Shevat

Amir Shevat is the global Startup Outreach lead in Google Developer Relations (g.co/launch). Previously, Amir Led Google Campus Tel Aviv and was the co founder of several startups.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *