Skip to Content

Who should read this?

First and foremost, if you don’t know what a design pattern is, then this blog is most certainly targeted at you.

Secondly those who don’t really understand the Model View Controller (MVC) design pattern should also keep on reading.

What is the MVC?

My intention was never to write a blog on what it is or how to implement it.  There is heaps of content on the internet and also on SCN.  A simple search and you can find tons of stuff out there.  It’s been around for ages, in fact it’s older than me, so it’s pretty old.

Here are some of my favourites:

http://blog.codinghorror.com/understanding-model-view-controller/

http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller

Where are you going wrong?

I’ve worked at quite a few clients over the years and it never ceases to amaze me at the number of developers unaware of MVC & it’s importance to SAP frameworks.  Even more horrifying is the number of developments/extensions I have seen that break this pretty straight forward design pattern. 


The most classic example of this is those who code business logic within the UI (a view). This results in two very frustrating outcomes

  • Data input via other views (i.e. via middleware) will not have the same business validation logic and as result the application data may be corrupted
  • Validation logic has been duplicated in multiple views. Maintainance requires double the effort and if not managed could result in inconsistencies.

.

Why should I learn it?

It’s the same pattern that keeps cropping up again and again and it does not appear to be going away any time soon…

Framework MVC Links
BSP Model View Controller (MVC) – Business Server Pages – SAP Library
ABAP WebDynpro Web Dynpro and the Model View Controller Design – SAP NetWeaver Composition Environment Library – SAP Library
OpenUI5 OpenUI5 SDK – Demo Kit
Introduction to UI5 – MVC 1 – YouTube
Introduction to UI5 – MVC 2 – YouTube

So if you don’t know MVC, you really can’t say you know these frameworks and even worse are potentially using them incorrectly.

Many non SAP programming languages incorporate frameworks built on this concept and the sooner you spot it the easier it will be for you to adopt a particular framework and the less likely you are to fall into one of the pitfalls described in previous section.

Cleaner Code

The ability to have a clean separation of code, that promotes code reuse is fantastic.  So much so that I find myself using this priniciple even when writing ABAP reports.  The ability to plug in different views makes it quick to extend the logic to expose the report data as an e-mail, alv, file download, etc.  And is abundantly clear to anyone maintaining it on where to make changes.

One final note

Please, please, please.  If you don’t understand it and before you attempt to create or extend any more content, take some time out to learn this pattern.  Your collleagues, your employers and everyone who works with your code will forever appreciate it.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Christian Punz

    the most important design pattern in the world!!!

    and yes, every single technique needs it’s particular design pattern as well but on top of all of them there has to be the (design thinking of) MVC.

    br

    christian

    (0) 
  2. Hai Wang

    Thinking in MVC  is not only way that make you having a clear mind. but also is the best way for studying another  complicated system development (eg. Mac OS X and PTC windchill ) . 

    (0) 

Leave a Reply