Website architecture is backwards

Nov 20, 2007

Any application ever build have an architect designing it. That architect could be a software architect, lead developer or just a regular code monkey and probably all of them at some point or the other. The point is that someone has made a lot of important decisions on how an application is structured. For me, that’s the best part of the project life cycle – the challenge to make qualified decisions that has to withstand time and changes.

For a regular component library, business- or data logic layer, service endpoints etc. this is very challenging but there is a lot of written material you can look to for help until you get it down. Dare I mention design patterns? In my experience, the initial design and architectural phase of a component or class library project is highly prioritized by managers and project leads. That’s good, because if the overall architecture is wrong, the project will ultimately fail.

ASP.NET web projects are a little different when it comes to architecture. First of all, the initial architecture doesn’t get as highly prioritized as it needs. Secondly, there are very different rules that apply to web projects. They are hard to impossible to unit test without spending and insanely amount of time writing click-test scripts etc. The output also varies from browser to browser, which can cause trouble for even the most experienced web developer and ultimately prolong the development.

When the ASP.NET developers start hammering on their keyboards things start to get complicated again. For every little feature there has to be made decisions to optimize the implementation. If you are adding a business object to your business layer it is much simpler. You “just” need to create a class derived from your business base class, add some properties and persist its state to the data base. I’m simplifying this but a lot of times that’s all you need to do if you have a decent base class. That’s because the architecture was done up front.

A new feature to a web project on the other hand, needs much more architecting by the individual developer. Will you use user controls, server controls and AJAX? If you use AJAX, will it be most optimal to use Prototype with an HttpHandler, ASP.NET AJAX or client-callbacks? Will you lazy load your page/control and what about caching? Will you store state in ViewState, session or the cache? How will you handle exceptions since you can’t bubble them up the stack and what about usability and accessibility? Will you use a Repeater or manually write out HTML to a PlaceHolder and what do you do to mitigate SQL injection and cross site scripting attacks? These decision and many more have to be made for every new feature.

It seems that the ASP.NET architecture is backwards from conventional software architecture. You spend fewer hours up front but for every little feature you need to spend a lot of time architecting. It’s totally opposite from conventional development in that regard and it leaves the decisions in the hand of the developers instead of the architect. The more time you get from management to architect your ASP.NET project, the more control you’ll have over the end result implemented by the developers, but in the end it might just be enough with thorough guidelines and accept that a lot of decisions are left in the hands of the developers.

I’ve done both conventional architecture and ASP.NET architecture over the years and my experience tells me that ASP.NET is more prone to diversity in implementation because of all the decisions that are left with the developers. Maybe it’s just the nature of web development.

* Only $4.95/month ASP.NET & Windows 2008 + IIS 7 Hosting! FREE SQL Included

Comments (6) -

Jakob Andersen
Jakob Andersen Denmark
11/20/2007 10:27:22 PM #

Nice to hear some thoughts about architecture, i hope im allowed to comment a bit on your thoughts Smile

It sounds to me like what you are describing here is not just about ASP.NET development, the same thing goes for every other UI you would have to make for applications, of course in webdevelopment you have additional challenges like browser compability but again these are not unique, you have some of the same issues with applications for mobile devices to take an example(screen oriantation, different models, limited displaysize etc.) So your statements are true but in my opinion they apply to coding the UI-experience in general and not only to ASP.NET.

The other thing that strikes me as being a bit odd is that you mention the word "feature" and saying that a lot of choices have to be made in implementing them in an ASP.NET project, the things you speak about is mostly implementation details and yes in some cases the choice of technology will have impact of the functionality of the solution, but i sure hope you have some idea of the functionality before you start making your technology choices Smile and in many cases this will help you make the right choice based on the constraints (most often budget/deadline/performancerequirements/etc. for the feature at hand).

Your statement about architecture not being prioritized in web projects is again a bit weird for me to hear. Most of the webapplications being developed today has a lot of businesslogic in them aswell, so (for me at least) its natural to do the classic approach of having a business layer(and datalayer) which is designed more or less like you would do in any other project type. So the same amount of architectural thoughts goes into these layers as in any other application. So whats left, the UI and yes as i said before UI development can be tideous and seem un-architeched(is that a word?) but again not only on the web platform.

Regarding testability and your envy-like cry out for something like the backend developers design patterns you actually have a choice, going for MVC makes testing some what easier than the eventdriven model in ASP.NET and hey isn't MVC an architectural pattern that actually includes the UI Wink

Dan
Dan United States
11/20/2007 11:40:21 PM #

Seems funny that you talk of the dangers of the MS MVC stuff just a few posts ago, then voice a few of the very same concerns that are driving talented people away from WebForms and toward MVC frameworks like monorail or ruby on rails.

Good ASP.NET architecture will be practiced by more and more people once so many quit trying to use a desktop client model on the web.  It's not at all the same, and WebForms tries to hide some of that difference.  MVC frameworks, on the other hand don't hide it - and help foster more thought around design concerns.  At least in my opinion.

Mads Kristensen
Mads Kristensen Denmark
11/21/2007 6:10:06 AM #

@Jakob
I think you're right that this goes for most UI development, but that you call it implementation details is just not true. Agreed, it is details about the implementation but it is much more than that as well. You can choose from a variety of different technologies and techniques and you have to step up and look at the bigger picture before making those decisions. Future proofing as much as possible, making it flexible etc. That's architecture, but granted, in a smaller scale.

@Dan
Yes, the MVC framework will help with this to some extend and I look forward to that. If you've read my post called "Dangers of the MVC framework" you will also read that it isn't the framework itself that's the danger, it's the community divide and the workforce gap it might carry with it. Not the MVC framework itself.

Jakob Andersen
Jakob Andersen Denmark
11/21/2007 6:35:02 AM #

@Mads
I didn't mean to say the choices of implementation techniques were not important. But often these are driven by the functionality of the features so i don't see much of a problem here.

A follow up question, are you using a three layered architecture in your web projects, and how is the architectural considerations in the lower layers any different from developing a these layers in other contexts?

Mads Kristensen
Mads Kristensen Denmark
11/21/2007 3:14:08 PM #

@Jakob
I use a three tier presentation layer and then comes the business, data and other possible layers beneath that. I don't consider business and datalogic layers to be part of a web project (presentation layer) even though they are in the same solution in Visual Studio. The business and data layers are the core foundation and the website is "just" a presentation on top of that.

The difference is that lower layers are much stricter architected whereas the website is much looser and a lot of the functionality is architected by the developers as they go along. Adding a feature to a web project is totally open for interpretation from the developer, while a new business class is developed under some very clear rules.

Hank
Hank United States
12/3/2007 3:01:51 AM #

I dunno about that Mads.  If you have a tight reign over your developers, I don't think that the web based code should be any more loose than the underlying business classes.  I will agree that left to their own devices, 3 different web developers will code the ui of the same page 3 different ways, but if you set your design rules out on the table beforehand, and then police them with peer reviews etc, taking the web as seriously as the BL/DL code, it should all be cool.

Web UI tech changes far more rapidly than the code and theory of the BL/DL, and as such, your UI should be looked upon as the most dispensible layer.  I think that if you code it with the notion that you will be throwing it away every 18 months, it forces you to architect the entire solution with an eye tword making the ui as stupid as possible from a code perspective, a layer that simply stitches together the elements of the underlying logic.  Any intelligence that you add to a disposable ui will just have to be re-written in the future, no-one like to do that.

Comments are closed

About the author

Mads Kristensen

Mads Kristensen
Program Manager at the Microsoft Web Platform team and founder of BlogEngine.NET.

More...

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.