Elegant web forms: wrap up and example

Elegant web forms: wrap up and example

To conclude the series on elegant web forms, I will walk you through a full example of a simple company and contact management tool. The app in itself doesn’t do much, but it serves to illustrate the points mentioned in the previous posts.

The example I’m using has a list of companies on the left and a list of contacts on the right, in other words, a simple master-detail view. To create, delete and associate companies and contacts I won’t be using any postbacks but will do everything with jQuery and the aforementioned AJAX-methods and web services. In the complete app, there’s not a single form.

Conclusion

The difference is that we don’t send all our data over the wire, but limit the transfer to just necessary items and we don’t mix UI code with business logic. (In this example there’s no business logic, but it’s obvious that it should go into the Person and Company classes.)

All in all, my opinion is that, whether you’re using ASP.NET Web Forms, MVC, plain old JavaScript and HTML or whatever other language, it’s not the tool which determines how elegant your code is, it’s the developer who writes it. It’s certain that ASP.NET MVC will encourage you from the start to write better code whereas ASP.NET Web Forms is aimed at RAD and as such will encourage you to do things the “quick” way, without thinking about consequences.

However, if you stand still for a moment, you will see that it still offers you the possibility to do things right and it allows you to create clean, fast and loosely coupled web apps, just as MVC does.

With the advent of .NET 4.5 which has a lot of good stuff coming for Web Forms as well as for MVC, it should even get easier to create slick apps for the web.

I hope you enjoyed the series and picked up some hints along the way. If you have any questions, feel free to contact me either through the comments section here or via the contact form.