Horizontal and Vertical Coupling

One aspect of the default ASP.NET 2.0 project model I really like is how the code-beside file and the declarative markup file compile at the same time.

The compilation model produces a comfortable coupling between the declarative markup and the class in the code-beside file. This is ‘vertical coupling’. The ASP.NET runtime can generate strongly typed properties for the code-beside class via the magic of partial classes.

Web Application Projects for Visual Studio 2005 delivers the ASP.NET 1.1 code-behind model for ASP.NET 2.0. Many applications will have an easier migration path to 2.0 with WAP.

One problem I watch for with the old compilation model is unwanted coupling between types in the code-behind files. This is ‘horizontal coupling’. Instead of using a layer of indirection, like an interface, base class, delegate, or event, types in the code-behind files can reference each other directly and produce brittle code.

Horizontal coupling is bad. Vertical coupling is good.

posted on Friday, March 10, 2006 8:39 PM by scott

Comments

Sunday, March 12, 2006 7:09 AM by Keyvan Nayyeri

# re: Horizontal and Vertical Coupling

Neat;
Thank you very much Scott for pointing to this helpful tip ;)
Sunday, March 12, 2006 8:35 PM by Christopher Steen

# Link Listing - March 12, 2006

Debugging AJAX apps, part 5 - XmlHttpRequest in IE /
FireFox [Via: Rumen Stankov ]
Debugging AJAX...