Design and Implementation Guidelines for Web Clients
About Design and Implementation Guidelines for Web Clients:
Excerpts from book:
Most, if not all, applications require some level of user interaction. In today’s distributed applications, the code that manages this user interaction is in the presentation layer.
Most simple presentation layers contain user interface components, such as Microsoft® Windows Forms or ASP.NET Web Forms. These components typically contain code to perform functions such as configuring the visual appearance of controls; accepting and validating user input; and acquiring and rendering data from data access logic components or business components.
The presentation layer can also include user interface process components. User interface process components perform presentation layer tasks that are not directly concerned with user interactions. For example, user interface process components orchestrate the flow of control between forms in the presentation layer and coordinate background tasks such as state management and handling of concurrent user activities.
Design and Implementation Guidelines for Web Clients provides advice on how best to implement logic in the presentation layer of a distributed application. This guide is designed to accompany the User Interface Process Application Block; this application block provides a template implementation for user interface process components. For more information about how and when to use this block, see Chapter 2, “Using Design Patterns in the Presentation Layer,” in this guide. For more information about the application block, including download information, see User Interface Process Application Block Overview on MSDN.
The information in this guide is organized into the following chapters:
* This chapter introduces the topics in this guide and provides guidance on basic terminology. It also notes the decisions the authors of this guide assume you have already made.
Additionally, this chapter summarizes the key messages that are documented in detail elsewhere in this guide and describes how this guide fits into the Microsoft patterns & practices family of documentation.
* Chapter 2, “Using Design Patterns in the Presentation Layer,” describes how to separate the responsibilities of components in the presentation layers by using common design patterns.
Design patterns help you get a clean separation between the code that presents data to the user and accepts user interactions and the code that orchestrates the flow of control between forms and handles issues such as state management, data access, and asynchronous behavior in the presentation layer. By partitioning your code in this way, you can reduce the coupling between the various parts of your application, and thereby make your code easier to change and extend as requirements evolve.
Chapter 2 introduces a template implementation of the key design patterns. The template is included in the User Interface Process Application Block. Chapter 2 describes how to use this block as the basis for your own user interface code, thereby realizing the benefits described in the previous paragraph.
* Chapter 3, “Building Maintainable Web Interfaces with ASP.NET,” describes how to make ASP.NET code easier to implement and maintain. This chapter describes how to use custom controls to share specific behavior across multiple controls and how to use common page layouts to ensure there is a common appearance across all the pages in your Web site. This chapter also describes how to use inheritance appropriately and effectively in Web applications in order to reuse controls in the presentation layer.
* Chapter 4, “Managing Data,” describes the correct way for components in the user interface (UI) to access, present, update, and validate data input, and how the UI participates in maintaining data integrity.
The first of these topics, “Accessing and Representing Data,” compares and contrasts various techniques for accessing data in the presentation layer. This topic describes the best way to represent data in disconnected and streaming applications and how best to use transactions in the presentation layer. This topic also describes the importance of a layered approach to data access and how to use message-driven techniques, data access logic components, and business objects to access data in specific scenarios.
The second topic in the chapter, “Presenting Data Using Formatters, Data Binding, and Paging,” describes how to use .NET Framework formatter classes, data binding techniques, and paging to display data to the user.
The third topic in the chapter, “Supporting Data Updates from the Presentation Layer,” describes how the presentation layer can participate in updates to data in a back-end data store such as a relational database. This topic describes how to create data maintenance forms that let users create, read, update, and delete data entities either individually or as part of a list. It also describes how to increase productivity by implementing metadata-based forms that are sufficiently flexible to handle data in any structure.
The final topic in the chapter, “Validating Data in the Presentation Layer,” describes scenarios where data validation is appropriate in the presentation layer.
The presentation layer is the first line of defense against accidental or malicious rogue data from the user. This topic describes how and when to use .NET Framework validator controls to validate the format and content of input data and includes strategies for handling validation failures.
* Chapter 5, “Managing State in Web Applications,” describes the types of state used in the presentation layer and offers guidance about how to manage state in applications written for the Web. Correct state management is critical to the scalability and availability of Web applications.
For Web applications, this chapter discusses the pros and cons of storing per-user session data in the in-process Session object, the state server-based Session object, or the SQL Server-based Session object. This chapter also discusses how to use cookies, hidden form fields, URL rewiring, and the ASP.NET ViewState property as alternative ways to maintain state between pages in an ASP.NET Web application. Finally, it discusses how to use the Application object to share state between all users and sessions of an application.
* Chapter 6, “Multithreading and Asynchronous Programming in Web Applications,” describes how to increase performance and responsiveness of the code in the presentation layer by using multithreading and asynchronous programming. This chapter describes how to use .NET Framework thread pools to simplify multithreaded code in your application. In situations where the thread pool is inappropriate, the chapter describes how to manually create, manage, and synchronize threads in your code.
This chapter also describes how and when to use asynchronous method invocation, by using delegates. Delegates represent method calls on objects; with delegates, you can start methods asynchronously by using the BeginInvoke and EndInvoke delegate methods.
* Chapter 7, “Globalization and Localization,” describes how globalization and localization requirements affect the development of your presentation layers. This chapter addresses how the .NET Framework uses cultures to define language-specific and country-specific issues, such as number formats and currency symbols; it also describes how and when it might be useful to define alternative cultures programmatically.
Additionally, this chapter describes how to format various .NET Framework data types appropriately, according to the current culture. As part of this discussion, it describes how to create custom resource files to hold language-specific string resources and images.
* Appendix A, “Securing and Operating the Presentation Layer,” describes how security and manageability considerations affect the design of presentation layer components.
This appendix reviews the importance of authentication and authorization in the presentation layer and the options available for performing these tasks in various circumstances. Additionally, it describes how to improve the security of communications using Secure Sockets Layer (SSL), Internet Protocol Security (IPSec), and Virtual Private Networking (VPN).
This appendix also describes operational management issues as they pertain to the presentation layer. It describes how to manage exceptions in the presentation layer; health monitoring; and performance monitoring.
* Appendix B, “How To Samples,” provides code samples to illustrate the various techniques described throughout this guide.
Most, if not all, applications require some level of user interaction. In today’s distributed applications, the code that manages this user interaction is in the presentation layer.
Most simple presentation layers contain user interface components, such as Microsoft® Windows Forms or ASP.NET Web Forms. These components typically contain code to perform functions such as configuring the visual appearance of controls; accepting and validating user input; and acquiring and rendering data from data access logic components or business components.
The presentation layer can also include user interface process components. User interface process components perform presentation layer tasks that are not directly concerned with user interactions. For example, user interface process components orchestrate the flow of control between forms in the presentation layer and coordinate background tasks such as state management and handling of concurrent user activities.
Design and Implementation Guidelines for Web Clients provides advice on how best to implement logic in the presentation layer of a distributed application. This guide is designed to accompany the User Interface Process Application Block; this application block provides a template implementation for user interface process components. For more information about how and when to use this block, see Chapter 2, “Using Design Patterns in the Presentation Layer,” in this guide. For more information about the application block, including download information, see User Interface Process Application Block Overview on MSDN.
The information in this guide is organized into the following chapters:
* This chapter introduces the topics in this guide and provides guidance on basic terminology. It also notes the decisions the authors of this guide assume you have already made.
Additionally, this chapter summarizes the key messages that are documented in detail elsewhere in this guide and describes how this guide fits into the Microsoft patterns & practices family of documentation.
* Chapter 2, “Using Design Patterns in the Presentation Layer,” describes how to separate the responsibilities of components in the presentation layers by using common design patterns.
Design patterns help you get a clean separation between the code that presents data to the user and accepts user interactions and the code that orchestrates the flow of control between forms and handles issues such as state management, data access, and asynchronous behavior in the presentation layer. By partitioning your code in this way, you can reduce the coupling between the various parts of your application, and thereby make your code easier to change and extend as requirements evolve.
Chapter 2 introduces a template implementation of the key design patterns. The template is included in the User Interface Process Application Block. Chapter 2 describes how to use this block as the basis for your own user interface code, thereby realizing the benefits described in the previous paragraph.
* Chapter 3, “Building Maintainable Web Interfaces with ASP.NET,” describes how to make ASP.NET code easier to implement and maintain. This chapter describes how to use custom controls to share specific behavior across multiple controls and how to use common page layouts to ensure there is a common appearance across all the pages in your Web site. This chapter also describes how to use inheritance appropriately and effectively in Web applications in order to reuse controls in the presentation layer.
* Chapter 4, “Managing Data,” describes the correct way for components in the user interface (UI) to access, present, update, and validate data input, and how the UI participates in maintaining data integrity.
The first of these topics, “Accessing and Representing Data,” compares and contrasts various techniques for accessing data in the presentation layer. This topic describes the best way to represent data in disconnected and streaming applications and how best to use transactions in the presentation layer. This topic also describes the importance of a layered approach to data access and how to use message-driven techniques, data access logic components, and business objects to access data in specific scenarios.
The second topic in the chapter, “Presenting Data Using Formatters, Data Binding, and Paging,” describes how to use .NET Framework formatter classes, data binding techniques, and paging to display data to the user.
The third topic in the chapter, “Supporting Data Updates from the Presentation Layer,” describes how the presentation layer can participate in updates to data in a back-end data store such as a relational database. This topic describes how to create data maintenance forms that let users create, read, update, and delete data entities either individually or as part of a list. It also describes how to increase productivity by implementing metadata-based forms that are sufficiently flexible to handle data in any structure.
The final topic in the chapter, “Validating Data in the Presentation Layer,” describes scenarios where data validation is appropriate in the presentation layer.
The presentation layer is the first line of defense against accidental or malicious rogue data from the user. This topic describes how and when to use .NET Framework validator controls to validate the format and content of input data and includes strategies for handling validation failures.
* Chapter 5, “Managing State in Web Applications,” describes the types of state used in the presentation layer and offers guidance about how to manage state in applications written for the Web. Correct state management is critical to the scalability and availability of Web applications.
For Web applications, this chapter discusses the pros and cons of storing per-user session data in the in-process Session object, the state server-based Session object, or the SQL Server-based Session object. This chapter also discusses how to use cookies, hidden form fields, URL rewiring, and the ASP.NET ViewState property as alternative ways to maintain state between pages in an ASP.NET Web application. Finally, it discusses how to use the Application object to share state between all users and sessions of an application.
* Chapter 6, “Multithreading and Asynchronous Programming in Web Applications,” describes how to increase performance and responsiveness of the code in the presentation layer by using multithreading and asynchronous programming. This chapter describes how to use .NET Framework thread pools to simplify multithreaded code in your application. In situations where the thread pool is inappropriate, the chapter describes how to manually create, manage, and synchronize threads in your code.
This chapter also describes how and when to use asynchronous method invocation, by using delegates. Delegates represent method calls on objects; with delegates, you can start methods asynchronously by using the BeginInvoke and EndInvoke delegate methods.
* Chapter 7, “Globalization and Localization,” describes how globalization and localization requirements affect the development of your presentation layers. This chapter addresses how the .NET Framework uses cultures to define language-specific and country-specific issues, such as number formats and currency symbols; it also describes how and when it might be useful to define alternative cultures programmatically.
Additionally, this chapter describes how to format various .NET Framework data types appropriately, according to the current culture. As part of this discussion, it describes how to create custom resource files to hold language-specific string resources and images.
* Appendix A, “Securing and Operating the Presentation Layer,” describes how security and manageability considerations affect the design of presentation layer components.
This appendix reviews the importance of authentication and authorization in the presentation layer and the options available for performing these tasks in various circumstances. Additionally, it describes how to improve the security of communications using Secure Sockets Layer (SSL), Internet Protocol Security (IPSec), and Virtual Private Networking (VPN).
This appendix also describes operational management issues as they pertain to the presentation layer. It describes how to manage exceptions in the presentation layer; health monitoring; and performance monitoring.
* Appendix B, “How To Samples,” provides code samples to illustrate the various techniques described throughout this guide.