Building State of the art presentation tiers Nauzad Kapadia [email protected].

29
Building State of the art presentation tiers Nauzad Kapadia [email protected]

Transcript of Building State of the art presentation tiers Nauzad Kapadia [email protected].

Page 1: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Building State of the art presentation tiers

Nauzad [email protected]

Page 2: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Key Objectives

• Importance of the presentation tier and overview of technologies available

• Guidelines for designing presentation tiers

• Discuss the issues commonly faced in presentation tiers

• Present solutions and workarounds

Page 3: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Importance of the presentation tier

Page 4: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

ASP.Net

Silverlight

Flash

Windows Presentation Foundation

Windows Forms

Flex

HTML 5

User Experience

Silverlight OOBXBAP

Page 5: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

The MVVM Pattern

View

• Contains the User Interface

• The Face of the application

View Model

• Drives the View

• Provides all the data required by the view, in the format that it requires

Model

• Provides the business logic for the PT

• Acts like a gateway between the PT and the middle -tier

Page 6: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Testability

• Problem–What is the easiest way to test my

presentation tiers

• Solution– Use the MVVM pattern

Page 7: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Separation of concerns and reuse

• Problem–Want to free the UI from the logic that

drives it– Re-use of presentation tiers in different

environments with minimal effort

• Solution– Use the MVVM pattern.

Page 8: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

DEMOApplication design using the MVVM pattern

Page 9: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Caching - guidelines

• Carefully choose the right data for caching

• Chose the appropriate location for the cache

• Design a cache refresh and updation strategy

Page 10: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Caching

• Problems– How do I synchronize my cache across

multiple servers across a farm– How do I cache data on the client in a

non-obstructive manner

• Solutions– Use Velocity® for web-farm level

cachine– Use the IsolatedStorage area on the

client-side

Page 11: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

DEMOUsing the Isolated Storage Area

Page 12: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Validation guidelines

• Design a non-intrusive, but fool-proof validation strategy

• Display error messages prominently• Do not perform excessive validations

Page 13: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Validation

• Problem– How do I provide some generic rules which can

be re-used in multiple places– How do I centralize all my validation logic for a

single entity– How do I control when the validation rules are

fired

• Solutions– Use Validation Rules for generic validations– Use IDataErrorInfo for centralizing validation logic– Use ErrorProvider pattern for more control

Page 14: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

DEMOIDataErrorInfo and ErrorProviders

Page 15: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Exception Management guidelines

• Design a centralized exception management strategy

• Log Exceptions• Display appropriate and generic error

messages• Do not use exceptions to control

program flow• Do not re-throw the same exception

Page 16: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

// BAD WAY// ... search for Productif ( dr.Read() ==0 ) // no record found, ask to create{

//this is an example of throwing an unnecessary exception because//nothing has gone wrong and it is a perfectly acceptable situationthrow( new Exception(“Product Not found"));

}

// GOOD WAY// ... search for Productif ( dr.Read() ==0 ){ // no record found, ask to create

return false;}

Page 17: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Navigation guidelines

• Allow navigation within your application to happen in a easy consistent manner

• Consider access rules and security trimming while implementing navigation

• Navigation elements should reflect the state of the application.

Page 18: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Navigation

• Problem– How do I keep my UI controls and

navigation elements in sync with the current state of my application

• Solution– Use the Controller Pattern– Use the Commanding Pattern

Page 19: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

DEMOThe Commanding Pattern

Page 20: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Localization guidelines

• Build localization support right in the beginning

• Design the UI keeping in mind that string sizes may vary significantly for the same content in different languages

Page 21: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Localization

• Problem– How do I localize my UI in multiple

languages– How do I facilitate the addition of

“language packs” to my application

• Solutions– Use .resx files

Page 22: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

DEMOLocalizing applications

Page 23: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Composite application guidelines

• Decide how modules will fit into the overall application

• Decide how to discover modules• Decide on a DI container• Determine the communication

strategy between modules

Page 24: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

Composite Applications

• Problem– How do I build a modular application– How do I discover modules at runtime– How do I enable loosely coupled

communication between modules

• Solutions– Use PRISM– Use a Dependency Injection framework

like MEF or Unity

Page 25: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

DEMODI using MEF

Page 26: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

UI Responsiveness guidelines

• Do not block the UI thread ever• Show the progress of a long running

operation• Consider giving the user the chance

to cancel a long running operation• Reduce the start-up time of modules• Pre-initialize commonly-used

modules and views

Page 27: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

UI Responsiveness

• Problem– How do I ensure that my UI is not blocked during

a long running operation– How do I allow the user the cancel a long-running

operation– How do I improve the responsive-ness of my UI

• Solution– Use background threads for long running

operations– Use Task Parallel Library or ThreadPools– Use Caching

Page 28: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

ResourcesSoftware Application

Developers

http://msdn.microsoft.com/

Infrastructure Professionals

http://technet.microsoft.com/

msdnindia technetindia @msdnindia @technetindia

Page 29: Building State of the art presentation tiers Nauzad Kapadia nauzadk@quartzsystems.com.

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.

The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and

Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.