Possibly the most important design pattern of them all (MVC)
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:
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…
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.
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.
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.
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 ) .