Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Katan
Active Participant

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...

FrameworkMVC Links
BSPModel View Controller (MVC) - Business Server Pages - SAP Library
ABAP WebDynproWeb Dynpro and the Model View Controller Design - SAP NetWeaver Composition Environment Library - SA...
OpenUI5OpenUI5 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.

2 Comments