1 Confessing our Infancy
At the very beginning we should perform when documenting common web programming problems is admit that we are relatively new to this game. Web sites and applications are rapidly evolving and grow more advance everyday.
While the web is growing at a gigantic pace there are definite standards and techniques that are coming to maturity. For example, the basic design of portal sites such as Google has settled into an established pattern.
2 Web Programming Application Levels
One of the most exciting and difficult aspects of web programming is that it requires expertise on many different levels. Web master need skills in user interface design, human machine interaction, information design, scripting, code library development, database design and database queries. These can be organized and categorized in this diagram:
- User Interface
- Human Computer Interaction
- Information Design
- Scripting
- Code Library Development
- Database Queries
- Database Design
Any structure for describing patterns in web programming will need to be capable of explaining the design considerations across any or all of these levels. Web developers face them many or all of these levels.
3 Common Problems and Techniques
3.1 Form Using
Form is used to capture the problem of getting and verifying input from a user. It is at the core of all web applications and there are many different approaches for solving this problem available to the web developer.
The basic method and constructs for prompting the user remain the same regardless of the actual content being entered. All forms must:
- Display an empty form to the user
- Verify the data entered is valid and display an error if it is incorrect
- Perform the required action using the data
Forms can be implemented using either a single or multiple page design. The single page technique utilizes a self-referring script to display and process the form. Multi-page forms take the user through a series of pages to enter, confirm and submit the data.
Developer should use both client-side and server-side validation in their form using. The other important area to consider when thinking about form design is the reporting mechanism for invalid data. Some people like to display the form with the input highlighting any errors. This makes it simple for the user to find and fix problems in the data. Others prefer to keep the page and application design as simple as possible by reporting errors on a separate page. The user then needs to either go back to the original form using the back button on their browser or they may be presented with a link to a page which will contain their entered data.
3.2 Navigation
Meaningful, clean, structured navigation and information design is one of the most important aspects of web design. There needs to be a consistent look and feel throughout the site. Any User needs to be able to immediately recognize their location in the site as a search engine referral can throw them anywhere.
There are three major navigation designs employed on the web today.
- Single level navigation has a list of top level areas within the site.
- Multi-level navigation breaks the site into a hierarchy. The user can then drill down through these levels to find the desired content. All levels of the hierarchy are displayed as part of the navigation at all times. As such the hierarchy is usually only two levels deep to keep the display simple.
- Dynamic multi-level navigation also uses a hierarchy except here the next level of navigation is not shown to the user until they have selected the parent.
3.3 Database Handling
The best way to access a database is a fundamental problem for web developers. In fact, it’s so common that we could easily forget to consider it as being a problem we need to solve. Most people access databases through specific functions, class or an abstracted database wrapper.
Many web applications and forms revolve around letting the user insert new information into the database and edit existing entries. The data being used is irrelevant to the solutions employed making this a good candidate for a pattern.
3.4 Authentication
Any request to a web site is authenticated at one of the following levels:
- None – we do nothing to record or track the request
- Visitor – we track this anonymous person across numerous sessions at the site
- User – we have information about the person and require them to authenticate
These levels of authentication are related and have similar implementations. They should be considered together as we need to know the authentication level of any request to the site.
3.5 Error Handling
Fixing errors before they confuse users is vital. Logging and notifying the maintainers of these errors is equally important to prevent them happening again.
Another good error handling problem to consider is keeping the site alive even if components are off-line. For example, if the database is being backed up and thus read-only can we continue to serve database requests without trying to write. Or if the database is offline completely can we continue to show pages that do not really need to use the database.
3.6 E-commerce
E-commerce is an interesting problem because it requires the form and authentication problems above to be solved. The challenge is to build a pattern for e-commerce that is not dependent on a particular implementation of forms or authentication.
4 Categorizing the Application Levels affected by each Problem
Placing problems into their levels will help us to understand which problems are specific to web programming.
4.1 Form Using
All form processing is done through a user interface interaction with the user. This results in calls to the high-level functions implemented in the code libraries. As such, form processing is limited to all of the front-end levels.
4.2 Navigation
Single and multi-level navigation is limited to the user interface and human computer interaction levels.
Dynamic multi-level navigation requires knowledge of the users current location and the ability to generate navigational menus. Backend libraries will also be required to generate these menus. Whether these should be part of a pattern for multi-level navigation or just listed as a collaborator is open to debate.
4.3 Database Handling
Database wrapper code lives in the code library and database query levels. It actually only needs to know about simple database queries since most are just passed through the wrapper class.
Formalizing the process of inserting and editing data into the database requires the use of all levels. We need to design the database to facilitate this type of data entry. The user interface must be developed to make the process clear.
Trying to encapsulate database rows as objects or items is limited to the backend levels. The front-end has access to this data through the API developed for the items.
4.4 Authentication
User level authentication requires interaction with the person through the front-end. It also requires backend functions to verify and process the information arising from this interaction. It uses all levels of web programming.
All other forms of authentication require no interaction with the user. They are completely contained in the backend levels.
4.5 Error Handling
Errors must be reported to the user and detected at all levels of the application. Error handling code uses all levels.
4.6 E-commerce
E-commerce requires interaction with the user and backend processing of the data. It requires all levels.