Thoughts on Technology, Methodology and Programming.

Archive for March, 2007

Why abstracting presentation logic is critical!

Posted by Marcus Wyatt on 13 March 2007

I’ve been listening to the Design Patterns Bootcamp podcast where they discussed the Model-View-Controller and Presenter patterns. In the podcast they pointed to “Should validation be in the UI or in business objects” post by Rockford Lhotka. He made the following comments that really struck a nerve with me:

In any case, I do focus greatly on keeping code out of the UI. There’s nothing more expensive than a line of code in the UI – because you _know_ it has a half-life of about 1-2 years. Everyone is rewriting their ASP.NET 1.0 UI code to ASP.NET 2.0. Everyone is tweaking their Windows Forms 1.0 code for 2.0. And all of it is junk when WinFX comes out, since WPF is intended to replace both Windows and Web UI development in most cases. Thus code in the UI is expensive, because you’ll need to rewrite it in less than 2 years in most cases.

Code in a business object, on the other hand, is far less expensive because most business processes don’t change nearly as fast as the UI technologies provided by our vendors… As long as your business objects conform to the basic platform interfaces for data binding, they tend to flow forward from one UI technology to the next. For instance, WPF uses the same interfaces as Windows Forms, so reusing the same objects from Windows Forms behind WPF turns out to be pretty painless. You just redesign the UI and away you go.

I completely agree with Rocky and believe that development teams that doesn’t abstract their presentation logic out of their code behind of their pages or winforms, will unfortunatly not be able to compete with teams that have. This would be due to the low velocity at which they can produce new functionality with new technology, due to their tight coupling of UI and presentation logic. By abstracting your presentation logic away from the presentation medium (i.e. webforms or winforms) you would be able to replace the presentation medium very easily when a new technology (i.e. WPF) arrive. This will allow you to upgrade your application and take advantage of the new functionality by re-using your existing presentation logic.

What do you think?


Currently listening to: Timo Maas – Killin’ Me


Posted in Development, OO | 1 Comment »