Welcome to the End to End .NET Application Day

Download Report

Transcript Welcome to the End to End .NET Application Day

Designing the End to End .NET Application
Hans Verbeeck
[email protected]
Developer Consultant
Microsoft EMEA
Agenda




A usecase driven approach
From Use Case to data model to physical database design
Demo
Choices to make up front





Type of client
Partitioning of the application
Host for the middle tier
Data carrier
Conclusions
2
Why analize?



Analyze the Business Problem
Understand the Business Logic
Consider Enterprise Issues
3
UML – Unified Modelling Language
9 types of diagrams









Class (Package) diagrams
Use Case diagrams
Statechart diagrams
Object diagrams
Sequence diagrams
Collaboration diagrams
Activity diagrams
Component diagrams
Deployment diagrams
4
Use Cases are...


Textual description of a general interaction with
the system
Services or functions provided by the system to its
users
USE CASES
List Available
Products
User
ACTORS
Raise Purchase
Order
Process Order
Vendor
System
SYSTEM BOUNDARY
5
Applied Use Cases

Actors are our user roles
Browser
 Reporter
 (data) Admin
 Buyer
+ External systems offering their shopping catalogs
through Web Services


Use Cases

Course grained in design
6
Football247.net use case diagram
Browse
Football
Data
Shopping
Buy
Browser
Authenticatio
n
User
Maintenace
…
Game
Reporting
Reporter
Import Football
Data
Game
Maintenance
Administ
rator
7
Agenda




A usecase driven approach
From Use Case to data model to physical database design
Demo
Choices to make up front





Type of client
Partitioning of the application
Host for the middle tier
Data carrier
Conclusions
8
Beyond the Use Case

Pick most important Use Case first


Browse Football Data
Most of the Football247.net web site is served by this use
case



+90% of operations will be read operations
Example:
A user browses to the homepage of the football247.net site. He
takes a look at the league table for the Premier League. He clicks
on his favorite team and sees the upcoming games, he continues
by looking at the results for the past games and finally he checks
the news about the team
Our reasoning: When a Browser clicks on a team he’s most likely
interested in different kinds of information about the team
9
Football247.net
Football247.Common
Application
Architecture
.Core
.Datasets
Solution
Structure
System
Architecture
Football247.Presentation
.Administrator, .Reporter
User Tier
.WebSite
.WinControls
.WebControls
.Facades
Football247.Business
Business Tier
.Facades
.Host
.Services
Football247.Data
Data Tier
.DataAccess
10
The Façade Pattern
Provides a simple interface to a complex system
Façade
Client
1
 Uses
*
Facade
11
The BrowserFacade
Our Façades are Use Case Façades
«Façade»
BrowserFacade
+GetFutureGamesByDivisionID(in divisionID : int, in numberOfDays : int) : FutureGameData
+GetLiveGamesByDivisionID(in divisionID : int) : LiveGameData
+GetPastGamesByDivisionID(in divisionID : int, in numberOfDays : int) : PastGameData
+GetGameDetailsByID(in gameID : int) : GameDetailData
+GetDivisions() : DivisionData
+GetDivisionByID(in divisionID : int) : DivisionData
+GetTeamsByDivisionID(in divisionID : int) : TeamData
+GetTeamDetailsByID(in teamID : int, in pastNumberOfDays : int, in futureNumberOfDays : int) : TeamDetailData
+GetPlayersByTeamID(in teamID : int) : PlayerData
+GetPlayerByID(in playerID : int) : PlayerData
+GetNewsItemByID(in newsItemID : int) : NewsData
+GetNewsByDivisionID(in divisionID : int, in numDays : int) : NewsData
+GetDivisionalTablesByDivisionID(in divisionID : int) : DivisionalTableData




GetDivisions() : DivisionData
GetTeamsByDivisionID(in divisionID : int) : TeamData
...
GetTeamDetailsByID(...) : TeamDetailData
12
Sequence Diagrams
Use them to get an idea of methods and data involved in
more complex operations
reporterFacade
gameServices
PostGameEvents
(GameEventData)
Validate
(EventType)
gameEvent
TypeValidator
If it’s a goal event
then the game’s score
Should be updated
in the same transaction
OK
X
gameEvents
DataAccesor
AddGameEvent
(GameEventData)
X
game
DataAccesor
GetGameByID(ID)
GameData
UpdateGame(GameData)
X
X
X
13
Designing Datasets
GetTeamsByDivisionID(in divisionID : int) : TeamData
GetTeamDetailsByID(...) : TeamDetailData
«Dataset»
TeamData
+Teams
«DataTable»
Teams
+TeamID
+TeamName
«Dataset»
TeamDetailData
+Teams
+Players
+NewsItems
+FutureGames
+PastGames
«DataTable»
Teams
+TeamID
+OfficialTeamID
+TeamName
+StadiumName
+City
+DivisionID
+Trainer
+LogoUri
+DivisionName
«DataTable»
Players
+PlayerID
+PlayerNumber
+PlayerName
+PlayerPosition
+GoalsScored
+Age
+Nationality
+PictureUri
14
Agenda




A usecase driven approach
From Use Case to data model to physical database design
Demo
Choices to make up front





Type of client
Partitioning of the application
Host for the middle tier
Data carrier
Conclusions
15
Visio for Enterprise Architects
Use Case
Façade
DataSet
DataTable
16
Agenda




A usecase driven approach
From Use Case to data model to physical database design
Demo
Choices to make up front





Type of client
Partitioning of the application
Host for the middle tier
Data carrier
Conclusions
17
Web Forms or Windows Forms
Do you want thin, thick, fat, rich, dumb, smart,
Windows or Internet?
Web Forms
User
Experience
Deployment
Updating
Security
Mobile
Relatively hard to make
web pages dynamic with
DHTML.
Easy. Only on server.
Windows Forms
Dynamic, responsive UI.
End users love it.
Can be deployed through
web server..NET Framework
required on client.
Shadow copying
prevents restarts of the
web application
Authorized actions
depend on zone.
Can update on web server.
Microsoft Mobile Internet
Toolkit
.NET Compact Framework
Reach Rich
Authorized actions depend
on zone. Code Access
Security.
18
Football247.net clients
Business
Presentation
admin
reporter
browser
WS
Façade
(asmx)
WIN
Service
ASP
.NET
UI
(aspx)
Data
WS
Façade
or
Biz
Services
D
A
L
S
P
ES
Façade
19
Agenda




A usecase driven approach
From Use Case to data model to physical database design
Demo
Choices to make up front





Type of client
Partitioning of the application
Host for the middle tier
Data carrier
Conclusions
20
Partitioning a distributed application



Deployment
Security
Scalability / Performance
21
Partitioning for deployment
How many physical tiers must be supported?

Possible deployment scenarios






Stand alone application (single box)
Distributed application
Hosted stand alone application
Hosted distributed application
Design Patterns make abstraction of component location
and inter-component-communication
Football247.net is designed for flexible deployment
22
Partitioning for deployment
one, two, three-tier
Businessbox
Single
Presentation
admin
reporter
browser
WS
Façade
(asmx)
WIN
Service
ASP
.NET
UI
(aspx)
+ Easy to admin
+ Most hosting companies offer this
+ Performance might benefit from nonetwork-hops
Data
WS
Façade
or
Biz
Services
D
A
L
S
P
ES
Façade
- Scalability: can only scale up
- Security: if this machine is
compromised, everything is
23
Partitioning for deployment
one, two, three-tier
Business
Web Server as application
server
Presentation
admin
reporter
browser
WS
Façade
(asmx)
WIN
Service
ASP
.NET
UI
(aspx)
+ Performance: minimized network hops
+ More options for security and
scalability
Data
Database
Server
WS
Façade
or
Biz
Services
D
A
L
S
P
ES
Façade
- Scalability: UI and middle-tier must scale
together
- Security: when web server is
compromised, the hacker can
access data access code
24
- cost
Partitioning for deployment
one, two, three-tier
Presentation
Web Server
admin
reporter
browser
Business
Application
Server
WS
Façade
(asmx)
WIN
Service
ASP
.NET
UI
(aspx)
+ Scalability: web farms
+ Security: DMZ
+ Middle tier is a resource to be used by
many different clients
Data
Database
Server
WS
Façade
or
Biz
Services
D
A
L
S
P
ES
Façade
- Perf: network hops
- Complexity: Web Server is not in
corporate domain
- cost
25
Partitioning for security


Keep most complex deployment scenario you need to
support in mind
Football247.net

Web Server in DMZ + Application Server + Database Server


Single box at hosting company


DMZ: Not in domain so no integrated Windows authentication
Not in a Windows Domain
Decision: Custom Authentication



Pluggable architure
Ready for future technologies (WS-Security)
Runs in any deployment scenario
26
Custom HTTP Handler unpacks
credentials, raises event in
global.asax which creates and
caches principal.
Authentication and authorization
Based on role, one of
.NET role
four connectionstrings
based
security
is used(browser,admin,
Business
Data
reporter, default).
User supplies
User
Presentation
ID and Password
admin
reporter
browser
WS
Façade
(asmx)
WIN
Service
WS
Façade
<
/>
Biz
User or
ID and Services
Password travel in
/> SoapHeaders
<
User ID and
ASP
Password
.NET travel in
UI
SoapHeaders
(aspx)
D
A
L
S
P
ES
Façade
27
Partitioning for Scalability / Performance
Never believe anything anyone says about perf


Test performance yourself
Performance tests should
model real world scenarios




Do nothing tests show only
the overhead
Real apps show overhead as
an often insignificant
percentage of the overall
work
Set the target based on
capacity planning
Test regularly to insure
you are hitting target
35
.aspx page
method
30
25
Serviced
Component (Lib)
20
Class Lib
R
P
S
15
10
Serviced
Component
(Server)
Web Service
5
0
28
Partitioning for Scalability / Performance
Designing for scalability – our choices

Stored Procedures & System.Data.SQLClient
+ performance
+ sp’s hide database details & protects database tables
+ one location for SQL coding
- portability

Web Services for Business components
+ easy of deployment (xcopy)
+ standards based
+ future ready
- performance

Optimized for reads
+ Reduced cross process / cross machine calls == better performance
+ user experience
- No true OO middle tier
29
Agenda




A usecase driven approach
From Use Case to data model to physical database design
Demo
Choices to make up front





Type of client
Partitioning of the application
Host for the middle tier
Data carrier
Conclusions
30
Options for hosting the Middle Tier


Web Services Façade
Enterprise Services Façade




Hosted by IIS, communication through Remoting
Loaded as Library Application in the Presentation Web
Services Façade or the ASP .NET Web Application
ServicedComponents are COM+ Server application
Windows Service
31
Options for hosting the Middle Tier
Web Services Façade
+ easy to deploy
+ easy to reuse
+ can publish in
Business
UUDI
Presentation
admin
reporter
browser
Data
WS
Façade
(asmx)
WIN
Service
ASP
.NET
UI
(aspx)
WS
Façade
Biz
Services
D
A
L
S
P
-Performance
-Always X-Process
32
ServicedComponents
Huge diference between Server and Library Applications
Server
Registration
COM Interop
Updating
Security
Needs to be registered
in COM+ catalog and
in the GAC
For every call
Disable, recycle,
update and re-enable
Runs with own identity
Library
COM+ catalog
Only when object is
instantiated
Shadow Copying
Runs in security context
of the caller
33
Options for hosting the Middle Tier
Enterprise Services Façade
+ can configure
remoting
+ performance
Business
Presentation
admin
reporter
browser
Data
WS
Façade
(asmx)
WIN
Service
ASP
.NET
UI
(aspx)
ES
Façade
hosted in
IIS
Biz
Services
D
A
L
S
P
-Registration
-Always X-Process
34
Options for hosting the Middle Tier
Enterprise Services Façade
Business
Presentation
Data
+ performance
admin
reporter
browser
WS
Façade
(asmx)
WIN
Service
ASP
.NET
UI
(aspx)
ES
Façade.
Library
app.
Loaded
on client
process
Biz
Services
D
A
L
S
P
-Registration
-Have to do authorization
and authentication in the
presentation tier
35
Options for hosting the Middle Tier
Enterprise Services Façade
+ COM+ services
+ DCOM has some
nice features
Business
Presentation
admin
reporter
browser
Data
WS
Façade
(asmx)
WIN
Service
ASP
.NET
UI
(aspx)
ES
Façade
hosted in
DLLHost
(server
app)
Biz
Services
-Registration (GAC)
-Always X-Process
-DCOM is COM interop
D
A
L
S
P
36
Agenda




A usecase driven approach
From Use Case to data model to physical database design
Demo
Choices to make up front





Type of client
Partitioning of the application
Host for the middle tier
Data carrier
Conclusions
37
Data carrier options
Chose based on programming model, performance
and maintainability




Datasets
Typed Datasets
XML
Collections
38
Data Carrier Options
Datasets

Pros

Disconnected model





Performance
Abstraction
XML aware
Databinding
Cons




Type checking at runtime
Diffgrams
XML overhead (even when used with remoting over
tcpchannel)
Risk to be tightly coupled to database schema
39
Data Carrier Options
Typed Datasets

Pros






Disconnected model
Designer to build XSD’s
Even better databinding
Design time type checking
Intellisense + readability of code
Cons





Deployment, versioning
Diffgrams
Overhead (8 – 10% slower)
Support in Compact Framework
Risk to be tightly coupled to database schema
40
Data Carrier Options
True XML

Pros



Standard
Flexible
Cons


Little Semantics
Custom XML Manipulation
41
Data Carrier Options
Collections

Pros




OO
Portable
Can databind if collection implements IBindingList
Cons


Code code code
Performance
42
Agenda




A usecase driven approach
From Use Case to data model to physical database design
Demo
Choices to make up front





Type of client
Partitioning of the application
Host for the middle tier
Data carrier
Conclusions
43
Conclusions



It’s better to use UML than not to use it
Starting with Use Cases makes sense
Make important choices upfront


Deployment
Security
44
Resources






In the pack you receive at the end of the day
Post-event CD
http://www.football247.net
Football247.Net Workspace on http://www.gotdotnet.com
http://www.rational.com/UML/
Building Secure ASP .NET Solutions
http://www.microsoft.com/downloads/release.asp?Release
ID=44047
45
© 2002 Microsoft Corporation. All rights reserved.
46