Friday, October 22, 2010

Design and Implementation Guidelines for Web Clients


Contents
Chapter 1
The Presentation Layer 1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
How To Use This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Defining the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Defining User Interface Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Defining User Interface Process Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Chapter 2
Using Design Patterns in the Presentation Layer 11
In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Benefits of Using Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Using Design Patterns for the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Choosing Design Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Frequently Used Presentation Layer Patterns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Implementing Design Patterns by Using the User Interface
Process Application Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Design of the User Interface Process Application Block. . . . . . . . . . . . . . . . . . . . . . 26
Benefits of Using the User Interface Process Application Block . . . . . . . . . . . . . . . . 28
Building Applications with the User Interface Process Application Block . . . . . . . . . . 32
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Chapter 3
Building Maintainable Web Interfaces with ASP.NET 45
In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Creating New Web Server Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Creating and Using Web User Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Creating and Using Web Custom Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Defining Common Page Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Using a Common Set of Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Using Customizable Regions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Using Page Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Chapter 4
Managing Data 65
In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Accessing and Representing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Choosing the Representation Format for Data Passed Between
Application Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Working with Transactions in the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . 67
Determining Which Layers Should Access Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Presenting Data Using Formatters, Data Binding, and Paging . . . . . . . . . . . . . . . . . . . 75
Formatting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Paging Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Supporting Data Updates from the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . 77
Batching Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Using Optimistic Concurrency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Designing Data Maintenance Forms to Support Create, Read, Update,
and Delete Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Implementing Separate Forms for the List and Entity Display . . . . . . . . . . . . . . . . . 81
Validating Data in the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Why Validate? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Choosing a Validation Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Using Validation Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Handing Validation Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Chapter 5
Managing State in Web Applications 93
In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Understanding Presentation Layer State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Determining State Lifetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Determining State Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Determining State Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Planning State Management for Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Storing State in the Session Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Storing State in Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Storing State in Hidden Form Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Storing State in Query Strings (URL fields) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Storing State in ViewState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
Storing State in the Application Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Serializing State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Caching State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Chapter 6
Multithreading and Asynchronous Programming
in Web Applications 115
In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Multithreading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Using the Thread Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Synchronizing Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Using Asynchronous Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Using the .NET Framework Asynchronous Execution Pattern . . . . . . . . . . . . . . . . . 123
Using Built-In Asynchronous I/O Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Chapter 7
Globalization and Localization 133
In This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Understanding Globalization and Localization Issues . . . . . . . . . . . . . . . . . . . . . . . . 133
Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Using Cultures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Identifying the Current Culture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Using an Alternative Culture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Formatting Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Localizing String Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Localizing Numeric Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Localizing Date and Time Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Creating Localized Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Creating Custom Resource Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Appendix A
Securing and Operating the Presentation Layer 149
In This Appendix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Securing the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Achieving Secure Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Performing Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Performing Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Using Code Access Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Implementing Security Across Tiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Auditing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Performing Operational Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Managing Exceptions in the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Monitoring in the Presentation Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Managing Metadata and Configuration Information . . . . . . . . . . . . . . . . . . . . . . . . 162
Defining the Location of Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Deploying Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
Appendix B
How To Samples 165
In This Appendix:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
How To: Define a Formatter for Business Entity Objects . . . . . . . . . . . . . . . . . . . . . . 166
Defining the ReflectionFormattable Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Defining the CustomerEntity Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Defining the CustomFormatting Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
How To Perform Data Binding in ASP.NET Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . 171
Data Binding an Entity Object to Simple Controls . . . . . . . . . . . . . . . . . . . . . . . . . 171
Data Binding a Collection of Entity Objects to a DataList Control . . . . . . . . . . . . . . 177
Data Binding a Collection of Entity Objects to a DataGrid Control . . . . . . . . . . . . . 185
How To: Design Data Maintenance Forms to Support Create, Read, Update,
and Delete Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Defining Business Entities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Defining Data Access Logic Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Defining Business Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Designing CRUD Web Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
How To: Execute a Long-Running Task in a Web Application . . . . . . . . . . . . . . . . . . . . 215
Defining the Payment Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Defining the CCAuthorizationService Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Defining the ThreadResults Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Defining the Result Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
How To: Use the Trusted Subsystem Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
How To: Use Impersonation/Delegation with Kerberos Authentication . . . . . . . . . . . . 222
How To: Use Impersonation/Delegation with Basic or Forms Authentication . . . . . . . . 223
How To: Localize Windows Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
How To: Define a Catch-All Exception Handler in Windows Forms-based
Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Additional Resources 227


Download
Another Web Programming Books

1 comment:

  1. Hi,One of the most frustrating aspects of any badly designed website is not being able to find something that you feel is on the website, or worse you have seen on the Web Design Cochin before and just can't find now. The whole area of Information architecture (to give it its proper title), is vital to getting your website working.Thanks....

    ReplyDelete

Related Posts with Thumbnails

Put Your Ads Here!