Title: Architecture and Design and a touch of implementation for 'NET
1Architecture and Design (and a touch of
implementation)for .NET
Keith Pleaskeithp_at_guideddesign.com
2Agenda
- Motivation
- An Architectural Framework
- Where Design Patterns fit it
- Microsofts Patterns Practices
- Microsofts Application Blocks
- What this means to you
3Problem Statement
- Unsuccessful IT projects - CIO Survey
- 73 of IT projects considered failures
- Not on time or budget, dont meet requirements
- 50 of time considered churn time
- Unproductive time, not directly related to
deliverable - Lack of standard target architectures
- Disconnect between dev and operations
4Goals Of ArchitectureThe Customer Perspective
- To let the business missions, strategies, and
processes guide the use of information technology - To allow for the rapid adoption of new
technologies for the competitive advantage of the
enterprise - To provide for the rapid development and
deployment of customized solutions - To enable repeatable, predictable, maintainable
results
5Why Should You Care?
- The computing industry is maturing
- Maturity leads to commoditization
- Commoditization pushes down the stack to the
lowest cost producer - To stay ahead, must add value thats difficult to
commoditize
6Can We Learn From Other Industries?
- Architecture from other domains
- Physical architecture
- Manufacturing
- Bottom line We have no protection
7Architectural Framework
8Relating Theories
Zachman
- Data
- Application
- Deployment
- Infrastructure
B - A - I - T
D- A - D - I
Layers
- Business
- Application
- Information
- Technical
9Architectural Framework
10Business Architecture
11Information Architecture
12Technology Architecture
13Application Architecture
14Design Patterns
15What Is A Pattern?
Context
Problem
Solution
16Patterns
- Provide reuse and repeatability
- Design and Architectural
- eCommerce Application
- Model-View-Controller (MVC)
- Fiefdoms / Emissaries
- Data Access Layer
- Class Factory
- N-tier Design
17Singleton Pattern
- Context
- Control access to a class by controlling its
instantiation process - Problem
- Certain types of data need to be globally
accessed and maintained - This data is often unique in the system
- E.G. counter class
18Singleton Pattern
19Singleton Pattern
public class Counter private static Counter
_instance null private Counter() public
static Counter getInstance() if
(_instancenull) _instance new
Counter() return _instance //...
functions provided by Counter
20Layered Architecture Pattern
- Context
- You are designing a complex enterprise
application composed of a large number of
components across multiple levels of abstraction - Problem
- How do you structure an application to support
such operational requirements such as
maintainability, reusability, scalability,
robustness and security?
21Layered Architecture Pattern
- Forces
- Changes in one part of the app should have
minimal impact to other parts - Separation of concerns is desirable
- Portions of the app should be reusable
- Strong cohesion, loose coupling is desired
- Portions of the app will be maintained and
evolved independently
22Layered Architecture Pattern
- Solution
- Compose the solution into a set of layers. Each
layer should be cohesive and at roughly the same
level of abstraction. Each layer should be
loosely coupled to the layers underneath.
23Layered Architecture Pattern
Users
UI Components
UI Process Components
Service Interfaces
Business Workflows
Business Components
Business Entities
Data Access Components
Service Agents
Data Sources
Services
24Command Pattern
- A request object
- Allows creating requests of unspecified
application objects - Common examples
- A request created by a menu item selection
- A request that pastes text from the clipboard
into a document - Execution macros
25Model-View-Controller Pattern
- Separates the modeling of the domain, the
presentation, and the actions based on user input
into three separate classes - Model - manages the behavior and data of the
application domain, responds to requests for
information about its state, and responds to
instructions to change state. - View - manages the display.
- Controller - interprets the user input, informing
the model and/or the view to change as
appropriate.
Controller
Model
View
26M-V-C in ASP.NET
- Separates the code, the presentation, and actions
- Model Code-behind
- View - HTML
- Controller ASP.NET engine (page controller)
Controller
Model
View
27Broker Pattern
- Problem
- How can you structure a distributed system so
that application developers dont have to concern
themselves with the details of remote
communication? - Forces
- Distributed communication complexity
- Deployment Flexibility
- Specialized Skills
- Solution
- Use the Broker pattern to hide the implementation
details of remote service invocation by
encapsulating them into a layer other than the
business component itself
28Broker (Continued)
- Discussion Points
- Location Transparency
- Server Lookup
- Broker as Intermediary
- Security Concerns
- Benefits
- Separation of Concerns
- Complexity Management
- Flexibility
- Liabilities
- Performance
29MicrosoftPatterns Practices
30Patterns PracticesProduct Model
31The Pattern Graph
32Constraining The Graph
OLTP
Object Oriented
Layered Architecture
Tiered Distribution
33Pattern Clusters
Security
34Web Presentation Cluster
Design
Intercepting Filter
Page Cache
MVC
Front Controller
Page Controller
Implementation
Implementing MVC with ASP.Net
Implementing Page Cache with ASP.Net
Implementing Intercepting Filter with ASP.Net
Implementing Front Controller with ASP.Net
Implementing Page Controller with ASP.Net
35Page Controller
- How do you best structure the controller for
moderately complex Web applications so that you
can achieve reuse and flexibility while avoiding
code duplication? - MVC focuses primarily on the separation between
model and view - Many dynamic Web pages involve similar steps
verifying user authentication, extracting query
string parameters etc. - Testing user interface code is time-consuming
36Implementing Page Controller in ASP.NET
- Benefits
- Simplicity
- Leverages Frameworkfeatures
- Increased reuse
- Liabilities
- One controller per page
- Deep inheritance trees
37Front Controller
- How do you best structure the controller for very
complex Web applications so that you can achieve
reuse and flexibility while avoiding code
duplication? - Page controller can lead to overburdened base
classes - Inheritance hierarchy is static
- Might need to coordinate processes across pages
- Might deal with dynamic navigation paths, e.g. a
Wizard that includes optional pages
38The Deployment Problem
39Deployment Cluster
Deployment
Application
Infrastructure
Tiered Distribution
Layered Application
Deployment
Rich Client
DNA
.Net App
IDC
EDC
DDC
Ext. Ent
Rich Client
Complex Web
Simple Web
40Deployment Patterns
Simple Web App
Complex Web App
Ent. Smart Client
Extended Enterprise
Web Clients
Web Clients
Smart Clients
UIC
UIP
Web Farm
Web Farm
UIC
SI
SA
UIP
BC
Application Farm
DAC
BC
DAC
Database Clusters
Database Clusters
41Deployment Cluster
Deployment
Application
Infrastructure
Business Component
Clustering
Zone
Policies
Load Balancing
Entity
Process
Utility
Failover
Policy Store
PEP
Software
Hardware
42MicrosoftApplication Blocks
43EULA and Support Model
- Source Code only VB.NET and C
- No binaries - As is EULA
- Customizations OK
- Redistribution repackaging OK
- Support
- PSS sign-off
- PSS Training
- Consistency in recommendations
- Escalation procedures, bug reporting
- GotDotNet Community
44Application Blocks for .NET
Presentation Services
Operational Management
Security
Communication
Sample App E-Commerce Application
User Interface Process (UIP)
Exception Mgmt
Caching
Enterprise Instrumentation
Business Services
Configuration
Data Aggregation
Service Integration
Data Services
Application Authorization
Persistent Asynchronous Invocation
Data Access (SQL, plan Oracle, OleDB)
Services
Data Sources
Operational Guides
Team Dev Build Scripts (Partner)
Shipped
In Beta
In Development
45Data Access Application Block
- Simplifies calling ADO.NET SqlClient
-
- Simplifies returning many formats
- Get DataSets, DataReaders, Scalars, XmlReaders
all in one line of code - Simplifies calling with many sources
- Connections, Conn. Strings, SQL Transactions
- Plays well with COM
- Best practices performance
- Nile benchmarks (internal competitive)
dr SqlHelper.ExecuteReader(
CONN_STRING,SaveCustomer", John , Doe )
46Data Access Application Block
47Choosing a DAAB Method
- Then choose target data source
- Connection String
- SqlConnection
- SqlTransaction
- First, choose the response format
- Int
- DataSet
- SqlDataReader
- Object
- XmlReader
- and finally, what type of parameters you want to
send - Value Array
- SqlParameter Arrays
- No Parameters
SqlHelper
SqlHelper.ExecuteDataset(
SqlHelper.ExecuteDataset(connectionstring
SqlHelper.ExecuteDataset(connectionstring,
CommandType.StoredProcedure, CustomersGetByPlan
et, Earth)
48Data Access Application Block
demo
49Data Access Application Block
- Parameter Caching
- Caches Stored Procedure Parameters
- Avoids 2 roundtrips
- Cache can be loaded manually (enforcing type
manually) or automatically on the fly - Important Links
- .NET Data Access Architecture Guidehttp//msdn.mi
crosoft.com/library/en-us/dnbda/html/daag.asp - GotDotNet Workspace
- http//www.gotdotnet.com/Community/Workspaces/Work
space.aspx?idc20d12b0-af52-402b-9b7c-aaeb21d1f431
50DAAB Tips
- Privatize functions you dont need
- Things you can add
- Connection String Mgmt
- Batch Updates
- Typed Datasets
- Next rev
- Instrumentation, etc.
51ExceptionManager
- Simplifies managing Exceptions
-
- Pluggable Publishers of exception info
- Event Log as default.
- Filters for routing / verbosity
- Adds troubleshooting information
- Persists Exception Chain
- Plans to extend with Enterprise Instrumentation Fx
try catch( Exception ex )
ExceptionManager.Publish (ex )
52Exception Management
53Exception Mgmt App Block
- Runtime flexibility, pluggable design
ltconfigurationgt ltconfigSectionsgt ltsection
name"exceptionManagement" type"
Microsoft.ApplicationBlocks.ExceptionManagement .
ExceptionManagerSectionHandler, Microsoft.Applica
tionBlocks.ExceptionManagement" /gt
lt/configSectionsgt ltexceptionManagement
mode"on/off"gt ltpublisher mode"on/off"
assembly"AssemblyName"
type"TypeName" excludeType,Type"
includeType,Type"
exceptionFormat"xml" customattr "value" /gt
lt/exceptionManagementgt lt/configurationgt
54User Interface Process Block
- Facilitates developing complex UI control
- Helps you implement the MVC pattern
- Describe your UI flow as XML
- Reuse controller logic for Windows Web
- Take care of state management
- Start, pause and resume user tasks without having
your code notice
55A User Interface Process
- A User Interface Process represents a use case
- You can draw it as a flow between views
- The UIP Block uses XML config to manage flow
ltnavigationGraph iViewManager"WinFormViewManager
" name"Shopping" state"State"
statePersist"SqlServerPersistState" startView"c
art"gt ltnode view"cart"gt ltnavigateTo
navigateValue"resume" view"browsecatalog"
/gt ltnavigateTo navigateValue"checkout"
view"checkout" /gt ltnavigateTo navigateValue"fail
" view"error" /gt lt/nodegt ltnode
view"browsecatalog"gt ltnavigateTo
navigateValue"addItem" view"cart"/gt ltnavigateTo
navigateValue"fail" view"error"
/gt lt/nodegt ltnode view"error"gt ltnavigateTo
navigateValue"resume" view"cart"
/gt lt/nodegt ltnode view"checkout"gt ltnavigateTo
navigateValue"passCheckout" view"congrats"
/gt ltnavigateTo navigateValue"failCheckout"
view"checkout" /gt lt/nodegt ltnode
view"congratulations"gt ltnavigateTo
navigateValue"resume" view"cart"
/gt lt/nodegt lt/navigationGraphgt
browsecatalog
addItem
fail
resume
ltnode view"browsecatalog"gt ltnavigateTo
navigateValue"addItem" view"cart"/gt ltnavigateTo
navigateValue"fail" view"error" /gt lt/nodegt
congrats
error
resume
resume
fail
passCheckout
cart
checkout
checkout
failCheckout
56UIP In Your Application
Your ASP.NET Pages
WebFormView
ControllerBase
Persistence Providers - SQL Server - Encrypted
SQL Server - Memory - ASP.NET Session - Custom
Your Controller Class
State Persistence Provider
MyFunc() //do cool code //more good
stuff
Biz Components
Biz Components
DALC
DALC
Data Access
57UIP Code
- Writing Controllers
- Inherit your class from ControllerBase
- Use the State object to hold your process data
- Use the NavigateValue property to set your output
- Interact with your business layers
- Writing Views
- Inherit your page from WebFormView
- Inherit your Form from WinFormView
- Use the MyController property to access the
controller - UIP sets the reference for you
58User Interface Process Block
demo
59Configuration Management AB
- Secure configuration in multiple sources
- Helps maintain application configuration
- Pluggable Storage
- Pluggable Signing Encryption
- Caching of config data for performance
60Using the Config Management AB
- Write your application as usual
- Specify config for the config
- Where config section stored, encrypted or not,
caching policy - Includes utilities QuickStarts for encryption
ltconfigSection nameYourAppConfigSection"gt
ltconfigProvider assembly"Microsoft.ApplicationB
locks.ConfigurationManagement.Storage.XML, Versio
n1.0.0.4,Cultureneutral, PublicKeyToken3325ee11
de9ffa0a" type"Microsoft.ApplicationBlocks.Conf
igurationManagement.Storage.XmlFileStorage"
signed"false" refreshOnChange"true"
encrypted"false" /gt ltconfigCache
enabled"true" locationPath""
locationType"Memory" refresh"1 "
signed"true" encryptedfalse"
/gt lt/configSectiongt
61Configuration Mgmt Design
Configuration Manager
Caching Service
Your Application
Application XML Configuration File (holds config
for config)
Configuration Storage Providers - XML File -
SQL Server - Registry - Custom
Configuration Section Handlers
Configuration Section Handlers
Configuration Section Handlers
Data Protection Providers - DPAPI - BCL - Custom
62Updater Application Block
- V Next of the popular GotDotNet Application
Updater - Securely pull assemblies and files
- Pluggable download mechanism
- Includes BITS - Background Intelligent Transfer
System - Run custom actions post deployment
- Downloads validated using RSA or custom validation
63Using the Updater AB
Poll Download
Application Update
Update Controller (Application or separate EXE)
Updater Application Block
Controller XML Configuration File
File Copy
Manifest
Application
64Upcoming Application Blocks
- Other blocks in development
- Caching, Asynch Invocation, Aggregation
- Available July
- Get beta blocks on GotDotNet workspaces
- Get the code
- Get samples
- Get extra plug-ins
65Summary
- Where are we in the cycle?
- Where do you fit in?
- Where should you make your investment?
66References
- A Pattern Language Towns/ Buildings/
Construction Alexander (1977) - Design Patterns Elements of Reusable
Object-Oriented Software Gamma, et al (1995) - Pattern-Oriented Software Architecture A System
of Patterns (1996) - Pattern-Oriented Software Architecture Volume 2
Patterns for Concurrent and Networked Objects
(2000) - Patterns of Enterprise Application Architecture
Fowler (2003) - AntiPatterns Brown, et al (1998)
67MSDN Architecture Webcasts
- Architecting applications to leverage existing
code - VS.NET Enterprise Architect
- XML Web Services inside Microsoft
- The role of virtualization in XML Web Services
- J2EE the .NET Platform within the Software
Fortress - Microsoft TerraServer Architecture
- Autonomous Computing Fiefdoms and Emissaries
- Building Interoperable Web Services
- .NET Interoperability with J2EE
- Architecting Interoperable Web Services using .NET
68MSDN Architecture Webcasts
- Design choices performance in distributed .NET
apps - Some architectural patterns for the enterprise
- Architecting a .NET distributed application
- ASP.NET Mobilizing Your Desktop Web Applications
- .Net and J2EE interoperability
- SQLXML XML Technology for SQL Server
- XML Web Services Security
- Legacy Enterprise Application Integration
- ASP.NET Patterns and Idioms
- An overview of Architecture
- .Net and J2EE interoperability update
- .NET Architecture Center Overview
69MSDN Architecture Webcasts
- The Future of XML Web Services
- Networking in the Microsoft Systems Architecture
- An Overview of Microsoft Systems Architecture
- Customizing the Microsoft Systems Architecture
- Security in the Microsoft Systems Architecture
- Web Service Architecture - Deciphering WS-
protocol - Using Patterns to Build Business Applications
- Distributed LOB app design using Application
Blocks