Enterprise Application Development with Microsoft .NET
Download
Report
Transcript Enterprise Application Development with Microsoft .NET
Introduction to Microsoft
.NET Enterprise Library
(Patterns and Practices)
Zaw Moe Tun
Myanmar Information Technology
Agenda
■ Technology Review
■ N-tier Application Architecture
■ Microsoft .NET Technology Overview
■ Enterprise library
■ Demos
■Q&A
Technology Review
Program
Data
Stand Alone System
Technology Review
Query Execute
Record set Returns
Programs
Database
Server
Client Server Architecture ( 2-tier)
Technology Review
Web-based users
Presentation
Web Server
Business Logics
Business
Data Sources
Data Access
Web Application Architecture (n-tier)
Typical Roles of each Tier
■ Presentation
● Rendering, acquisition and validation.
● Interpret gestures.
■ Business
●
●
●
●
●
Stateless components
Implement short-lived business activities
Enforce policy
Aggregate data from data sources and services
Represent data in business-relevant schemas
■ Data Access
● Stateless encapsulation of data access and transformation logic
● Provides wrappers for calling stored procedures.
Benefits of N-Tier
Architecture
■ Scalability and Performance
● Can use different machines for each tier.
● Can also use multiple machines per tier.
■ Maintainability and Stability
● Highly specialized components.
● Separation of concerns.
■ Flexibility
● Supports reuse.
● Interchange components with same interface
● Loosely coupled -> flexible deployment
Beyond N-Tier
Rich Clients/Smart Client
Web-based users
Business Components
Web Server
Data Sources
Internal Services
Process Orchestration
Service Ifaces & Agents
Services
Business to Business
.NET N-Tier Technology
Tools - Visual Studio.NET
Presentation Layer
ASP.NET Web Forms
Win Forms
Mobile Forms
Business Objects
.NET Components
COM+ for Transactions
Back-End Access
ADO.NET
ASP.NET Web Services
.NET Remoting
Foundation - .NET Framework
.NET Technology Overview
Next generation of
Microsoft development platform
.NET Framework
■ The .NET Framework is an Integral
Windows component that supports
building and running the next generation of
applications and XML Web services
■ Well, Microsoft equivalent to J2EE
Two Main Components
■ The .NET Framework has two main
components:
● The common language runtime (CLR)
■ The foundation of the .NET Framework
■ Manages code at execution time, providing core
services such as memory management, thread
management and etc’
● The .NET Framework class library
■ The class library is a comprehensive, objectoriented collection of reusable types that developer
can use to develop applications
Modern Software
Challenges
■ Heterogeneous client platform
● Personal Computer, PDA, Mobile Phone
● Global Audience
■ Communication
● Different type of network (Internet, intranet)
● Different type of protocol (TCP/IP, HTTP, WAP, SOAP, etc…)
■ Security
● Information is transmitted via public network
■ Scalability
● Must be able to perform within expected performance
■ Reliability
● 24/7 availability
Why Process Model ?
Waterfall and spiral models
MSF Process Model
■ The MSF Process Model combines the best principles of the
waterfall and spiral models.
■ It combines the waterfall model’s milestone-based planning and
resulting predictability with the spiral model’s benefits of feedback
and creativity.
MSF Process Model
MSF Versioned Release
Role Combination
MSF Process Model and UML Views
Tradeoff Triangle
What is Rapid Development
■ Rapid development is a
generic term that means the same thing as
'speedy development' or 'shorter
schedules.' It means developing software
faster than you do now."
Enterprise Library blocks
Introducing “Enterprise
Library”
■ Library of reusable software assets to
address common enterprise development
challenges
■ Part of the patterns & practices guidance
library
■ Strong focus on consistency, extensibility,
ease of use and integration
Consistency
■ Design and implementation principles
■ Configuration
■ Documentation
■ Tests
■ Tooling
■ Samples
■ Operational requirements
■ Installation procedures
Extensibility
■ Extending existing blocks
● Pluggable providers
■ Modifying existing blocks
● Design documentation and Unit Tests included
■ Guidelines how to create new blocks
●
●
●
●
Design patterns and principles
Hooking into config tool
Documentation guidelines and templates
Testing requirements
Ease Of Use
■Configuration
tooling
■Simplified
installation and
deployment
■Improved
documentation and
samples
Integration
■ Packaged as a library
● Not a Framework: does not prescribe an
architecture
■ Blocks are designed to work well together,
but they can still be used individually
● Loose coupling between blocks
■ Configuration understands how to use
blocks together in application
● Blocks used as providers for other blocks
Enterprise Library v1
Exception
Handling
Caching
Security
Data
Access
Crypto
Config
Tooling
Config
Run-Time
Logging &
Instrumentation
Interdependece of application
blocks
Data Access Application
Block
■ Provides simplified access to the most common
data access operations
■ Aim was to keep much of the simplicity of the
original DAAB blocks, but to provide additional
features requested by customers
■ Notable new features:
● Support for multiple database types through a factory
(SQL Server, Oracle and DB2 out of the box). This
provides consistent and portable code (caveats
apply!)
● Connection strings are stored and managed in
external configuration
Data Access Application
Block Design for
Simplified Data Access
■ Uniform methods of data access make code easier to
understand, more predictable and easier to maintain
■ Data Access is simplified
● Housekeeping actions are performed automatically
● Complex actions are encapsulated and exposed as simple methods
■ All interactions happen through the abstract base Database
class
●
●
●
●
●
●
ExecuteDataSet()
LoadDataSet()
ExecuteReader()
ExecuteScalar()
ExecuteNonQuery()
UpdateDataSet()
■ Note: each method has multiple overloads
Data Access Application
Block Design Overview
dataconfiguration.config
1.0
Client Code
Configuration
Application
Block
Data Access Application Block
CreateDatabase()
Invoke Operations on db instance
Database
factory
Database
MS SQL
Database
MS SQL
Command
Oracle
Database
Parameter
Cache
DB2
Database
Database
Command
Wrapper
Create Complex Commands
Oracle
Command
DB2
Command
Configuration Application Block
■ Allows applications to easily read and write configuration
data from configurable storage locations
■ Used by all blocks in Enterprise Library, can also be
used by customer blocks, frameworks and applications
■ Includes two parts:
● Configuration Runtime, which applications use at runtime to
access configuration data
● Configuration Designtime, which provides nodes that are used
by the configuration tool to give a simple design-time experience
■ Configuration can be encrypted and individual elements
can be masked in the tool
■ Enterprise Library will include standalone and Visual
Studio-integrated versions of the configuration tool
Configuration Application
Block Design Overview
Other Application
Client Code
Blocks
Client Code
App.Config /
Static Facade
Custom config
Configuration
Manager
Web.Config
<config file
for section>
Configuration
Cache (hashtable)
Configuration
Builder
IStorageProviderWriter:
IStorageProviderReader
Configuration
Context
XmlFileStorageProvider
Configuration
Dictionary
ITransformer
XmlSerializerTransformer
Configuration Application Block
Exception Handling
Application Block
■ Facilitates consistent exception handling
behavior at logical boundaries of an application
■ Allows the creation of “exception policies” which
dictate which actions should be taken for specific
exception types at the logical boundary
● Example: All security exceptions arising from the
business layer need to be logged, and the messages
sanitized before being propagated to the caller
■ Actions are extensible; we provide Logging,
Wrapping one exception with another, and
Replacing one exception with an other
■ Block has little in common with the existing
EMAB which was primarily used to log
exceptions
Exception Handling
Application Block Design Overview
exceptionhandling
configuration.config
1.0
Client Code
Configuration
Application
Block
HandleException(“policyname”)
Exception Policy
IExceptionHandler
Each Policy Entry
has set of handlers
Each Policy has different
exceptions
Exception Policy
Entry
Wrap
Handler
Logging
Handler
Logging
Application
Block
dataconfiguration.
1.0
config
Replace
Handler
Custom
Handler
Logging & Instrumentation
Application Block
■ Allows applications to log business and
operations data to various destinations, which
are externally configurable
■ Replaces the Enterprise Instrumentation
Framework and the existing Logging Application
Block
■ Configuration specifies which messages go
where, and how they are formatted
■ Formatters and sinks are extensible. We provide
sinks for Event Log, Database, Text File, MSMQ,
E-mail, WMI and Windows Event Tracing
Logging and Instrumentation
Design Overview
1.0
logging
configuration.config
Client Code
Configuration
Application
Block
Add Logging
Details
Logging and Instrumentation
Application Block
Write()
Logger
EventLog
Sink
LogEntry
ILogDistribution
Strategy
LogWriter
Strategies implement
ILogDistribution interface
Email
Sink
Msmq
Sink
MSMQ
Distribution Strategy
LogDistributor
MSMQLogDistributor
MSMQ
FlatFile
Sink
InProc
Distribution Strategy
WMIlog
Sink
Database
Sink
ILogSink
Sinks implement
ILogSink interface
Caching Application Block
■ Provides a flexible and extensible caching
mechanism that can be used at all layers of an
application
■ Supports backing stores that persist cache data
into a database or isolated storage, so the data
can survive app restarts
■ Can be used in ASP.NET apps, although the
ASP.NET cache is preferred for simple scenarios
■ Supports similar scenarios to the original
caching block, but with a revised architecture to
make it more thread- and exception-safe
Caching Application Block
Design Overview
securityconfigura 1.0
tion.config
Client Code
Configuration
Application
Block
Create
Instance
Add/Retrieve
CacheManager
Factory
Base
BackingStore
Null
BackingStore
(for memory)
Database
BackingStore
Cache Application Block
Cache
Manager
Background
Scheduler
Cache
Expiration
Task
Scavenge
Task
IsolatedStorage
BackingStore
dataconfiguration.config
1.0
Data Access
Application
Block
Cryptography Application Block
■ Provides a simplified approach to implementing
common cryptography scenarios
■ Includes modules for symmetric cryptography
and hashing
■ Each module supports pluggable algorithms and
key stores
● Supports all .NET crypto algorithms out of the box, or
developers can implement their own
■ Algorithms and keys can be managed through
the configuration tool
Cryptography Application Block
Design Overview
securitycryptography
configuration.config
1.0
Client Code
Configuration
Application
Block
Cryptography Application Block
Cryptographer
EncryptSymmetric/DecryptSymmetric
CreateHash/CompareHash
Hash
ProviderFactory
Symmetric
ProviderFactory
IHash
Provider
ISymmetricCrypto
Provider
DpapiSymmetric Crypto
Provider
KeyedHash
Algorithm
Provider
HashAlgorithm
Provider
DpapiSymmetric
Cryptographer
DpapiSymmetric Crypto
Provider
Symmetric
Cryptographer
Security Application Block
■ Provides a simple API and pluggable
implementations of core security primitive
operations
■ Covers 5 security areas: Authentication,
Authorization, Roles, Profile and Security
Caching
■ Each module supports extensible plug-in
providers. In general we supply plug-ins for
common Microsoft infrastructure (AD, AzMan) as
well as a light-weight database implementation
■ Developers can build their own plug-ins to
interface with existing security solutions
Security Application Block
Role-based Security:
Principals and Identities
Application Security Context
Authentication
Credentials
Principal
Module(s)
(username, password)
Roles
Identity
IPrincipal
• Windows
• Identity
• Forms
• IsInRole()
• Passport
GenericPrincipal
WindowsPrincipal
Custom Principal
• Identity
• Identity
• Identity
• IsInRole()
• IsInRole()
• IsInRole()
• custom methods
Some Reference Applications
■ Task Vision
■ Infragistics (Third Party Tools)
Reference website
■ http://www.windowsforms.net/Applications/
application.aspx?PageID=20&tabindex=8
■ http://msdn.microsoft.com/library/default.a
sp?url=/library/enus/dnpag2/html/ehab.asp
■ http://www.gotdotnet.com/workspaces/wor
kspace.aspx?id=295a464a-6072-4e2594e2-91be63527327
Conclusion
■ Software Engineer's capability depends on
● what he/she has in his/her toolkit
● His/her ability to apply the right tools for the
right purpose