Avonelle's Tech Blog

Go Back

Separating Out Your Business Logic using ASP.NET Web Forms

These days almost all of the development work I do is with ASP.NET Web Forms. I’m a big fan of Web Forms – it is a technology that has helped me productively build applications for my customers for the last 10 years. However, one negative thing about Web Forms is that many of your business rules are embedded in the page markup as validation controls. Yuck.

Fortunately Peter Blum has developed a technology that solves this problem. He calls it Peter’s Business Logic Drive UI (BLD), and I’m currently using it on my latest project. BLD lets you define your business rules in separate classes, which are then used by the presentation layer to create a UI that includes the appropriate user interface, complete with validation controls that match the business rule logic.

Frankly my description of the product doesn’t do it justice, so if you are interested in this, you should definitely read more about it at Peter’s site, PeterBlum.com. But I do want to add a few remarks about it.

First, Peter’s documentation and support are second to none. You might expect that since his business is just him, the support would suck, but in fact, Peter provides terrific email support and has for years. And his documentation is outstanding. BLD’s PDF documentation is currently over 2,000 pages. Wow.

Second, if you decide to give BLD a spin, expect that it will take you some time to learn. I was already familiar with Peter’s validation controls, but that really didn’t prepare me for how different developing using this approach is. But once you get the basics under your belt, you won’t want to go back.

Third, you might find that using a code generation tool like CodeSmith or T4 to get your business rule classes started will help a lot. In my case, I use CodeSmith to generate my initial BLD classes from my database tables. My CodeSmith templates use some simple logic for adding business logic attributes. For example:

  • Date fields add the attribute for date types so the UI shows a date picker
  • if the column name includes “email” it adds an attribute so that email validation rules are included
  • If the column name includes “phone” it adds an attribute so that phone formatting and validation rules are included
  • etc.

Other than Peter’s website and documentation, there isn’t a lot of information about BLD online. Since Google/Bing tend to be the first place I look when I’m stuck, this is limiting my options. So I’ll be adding stuff I learn about BLD here, so at least they’ll be captured by the magic of the internet, even if only for me.

Posted by Avonelle on Thursday, January 17, 2013.

Facebook Twitter