Tài liệu Design and Implementation Guidelines for Web Clients- P1 pdf

258 588 1
Tài liệu Design and Implementation Guidelines for Web Clients- P1 pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. © 2003 Microsoft Corporation. All rights reserved. Version 1.0 Microsoft, MS-DOS, Windows, Windows NT, Windows Server, Active Directory, MSDN, MSN, Visual Basic, Visual C#, and Visual Studio are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. 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 iv Contents 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 Contents v 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 [...]... 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... components forms the presentation layer of the application The presentation layer interoperates with the business and data access layers to form the overall solution The following section outlines the typical responsibility for each kind of component in the presentation layer and explains the benefits for dividing the presentation layer as described 6 Design and Implementation Guidelines for Web Clients... 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... create, manage, and synchronize threads in your code 4 Design and Implementation Guidelines for Web Clients 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,”... (http://msdn.microsoft.com/library /default.asp?url=/library/en-us/dnbda/html/uip.asp) 2 Design and Implementation Guidelines for Web Clients How To Use This Guide This guide addresses specific goals of presentation layer component design This guide provides prescriptive recommendations and code samples that enable you to use design patterns and Microsoft NET Framework programming idioms effectively in the presentation... that user interface components can invoke to receive data they must render to affect the state for the process 8 Design and Implementation Guidelines for Web Clients To help you separate the tasks performed by user interface process components from the tasks performed by user interface components, follow these guidelines: ● Identify the business process or processes that the user interface process helps... assist rendering and data capture in the user interface The User Interface Process Application Block provides a template implementation for user interface process components For more information about how to use this block, see Chapter 2, “Using Design Patterns in the Presentation Layer.” Additional Information For more information about the full range of available patterns & practices guides and application... /library/default.asp?url=/library/en-us/dnbda/html/BOAGag.asp) ● Web Service Façade for Legacy Applications This guide defines best practices for interfacing with COM-based applications by using XML Web services created using ASP.NET and the Microsoft NET Framework For more information about this guide, including download information, see Web Service Façade for Legacy Applications on MSDN (http://msdn.microsoft.com... globalization and localization ● Formatting data and displaying it in useful visual styles ● Browsing, searching, and organizing displayed data Common user interface choices include: ● Console applications – This approach is suitable for simple utilities that can easily be controlled from a command line ● Windows Forms-based applications – Windows Forms-based user interfaces are the preferred choice for rich... 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® . between forms in the presentation layer and coordinate background tasks such as state management and handling of concurrent user activities. Design and Implementation. /default.asp?url=/library/en-us/dnbda/html/uip.asp). 2 Design and Implementation Guidelines for Web Clients How To Use This Guide This guide addresses specific goals of presentation layer component design.

Ngày đăng: 14/12/2013, 13:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan