As the Web has become a more integral part of everyday life and business, web sites have matured from small, static sites into rich, data-driven, complex applications. Several technologies, including dynamic scripting technologies, like Active Server Pages and Perl, have aided along the way, making the Web a more viable application medium. This book focuses on using Active Server Pages to quickly and easily build powerful and dynamic web sites.
Although the server-side tools for building web sites have experienced a nice maturation, the processes used for building these sites have not. What, specifically, is Active Server Page design? What is currently wrong with ASP design? Why hasn’t the art of designing ASP pages advanced? What can be done to improve ASP design? The first three questions will be answered in this chapter. The last one, however, is a meaty one; it is addressed in this chapter, and answered over the next seven chapters.
This chapter not only addresses these questions, but also introduces functions and programming styles that will be used extensively throughout this book.
Designing a single ASP page is trivial. The challenges involved in designing ASP pages arise when large web sites with hundreds of web pages are being crafted. These large web sites are, in their own rights, full-scale applications. Therefore, before we examine Active Server Page design, we will first take a step back and discuss application design. As we’ll see shortly, application design is a long, arduous process, involving much more than simply punching out code.
Imagine that you have just been assigned the task of creating a new program that will be deployed to all of the employees in your company. This program will allow the users to query a centralized database and place the results into a number of formats that correspond to various interoffice forms your company uses. What do you do first? How do you get started?
Designing, coding, testing, and deploying an application is known as application development . Temporally, it can be viewed as the time span from when the program was first conceptualized to when its first stable version was available for use. (Of course, application development does not end with the first, stable release of a product. Rather, it continues as long as updates and enhancements of the given product are being made.) An entire branch of the computer science discipline is dedicated to studying various application-development methodologies. While there are a number of different methodologies, they all usually share a certain number of phases, which include:
In classical software development, developers usually follow this flow, working on the application’s design before moving on to writing the actual code. For example, large software companies draft very detailed plans for their software projects before a developer writes a single line of code.
With the Web, the design stage usually focuses on the aesthetics of the web site, such as the look and feel of each web page. This makes sense, since in the Web’s earlier days, the vast majority of web sites were static, their usefulness and allure directly dependent upon their HTML design. As the Web matures, though, and web sites become more dynamic, it is important that adequate time be spent on the design of the scripts that run a site.
Simply put, the design phase in web site development focuses too much on the layout and HTML issues and too little on the programmatic side. That’s not to say that HTML design is unimportant: it is very important. The end users benefit directly from the HTML design. Imagine a site that had terrible HTML design, a site cumbersome to navigate and difficult to use. Chances are, after one visit to this site, you’d not come back.
Script design, on the other hand, benefits the developers directly, and the end users indirectly. For example, if your dynamic web site contains robust, easy-to-update scripts, the developers will directly benefit from reduced time spent in the coding phase when a new feature needs to be added. The end users will indirectly benefit from such well-designed scripts, since the less code a developer has to write, the less buggy her code will be. Additionally, well-designed scripts require less maintenance time, making it easier to add new functionality to existing scripts. (The benefits of code reuse and robust scripts are discussed in more detail next, in Section 1.2). Since both HTML design and script design are important, it is essential that adequate time be spent on both.
Since ASP pages are scripts, ASP design is the art of crafting robust, reusable code. Good design requires planning, documentation, and above all, patience. Before you begin writing code for a particular ASP page, think of what the script needs to accomplish. Is it similar to the functionality of other ASP pages on the site? Have you created a page with similar functionality in a past project? How can you build this page so that it can be easily reused in future projects?