Code Reusability in ASP.NET

Part II
Smart and Effective Data Access and Reporting
Chapter 5
Code Reusability in ASP.NET

So far in this book, we’ve built complex pages that employ sophisticated DataGrid and interoperable controls. Although the .NET Framework is a slim and elegant hierarchy of classes for building Web projects, many of you will end up with unwieldy blocks of code and layout information, and when the complexity of a software component grows beyond a certain threshold, reusability and encapsulation become serious issues. Years ago, someone coined a phrase to describe this programming phenomenon: spaghetti code.

Originally, spaghetti code referred to the messy tangle of lines of BASIC that resulted from unsparing use of GOTO statements and a modular programming style. It’s also an apt description of unstructured, overly complex ASP pages. One key to the ASP technology’s rapid adoption is the immediate interpretation and execution of the <%...%> script code within the flow of an ASP page. However, in the long run, it has also been the determining factor preventing the technology from scaling properly to meet the needs of sophisticated real-world projects.