Silverlight n-tier Architecture - WordPress.com · Silverlight n-tier Architecture Focus is...

Preview:

Citation preview

Silverlight n-tier Architecture

Thomas Juul, Senior Consultant, TENTEO

Show of Hands

How many of you do not write code on a daily basis?

Silverlight n-tier Architecture

Focus is Silverlight, but this architecture can also be applied to WPF, WinForms and to some extent ASP.NET

“If you get any group of architects into a room

and ask them to describe their ideal architecture,

each one will come up with a different answer”

Silverlight 2-tier Architecture

UI

Domain Objects

Repository

Silverlight Client Application Server

Services

Domain Objects

Repository

Database

Silverlight 3-tier Architecture

UI

Domain Objects

Repository

Silverlight Client

Services

Domain Objects

Repository

Application Server

Database

Database Server

Silverlight 4-tier Architecture

UI

Domain Objects

Repository

Silverlight Client

Services

Domain Objects

Repository

DMZ Application Server

Services

Domain Objects

Repository

Application Server

Database

Database Server

Walkthrough

• Write business logic once, reuse on server and client

• Loosely coupled UI

• Loosely coupled UI Communication

• Async network Communication

• Mock the Repository

• Testability

Where to place the business logic?

Two approaches

”True” Object-Oriented Paradigm

BehaviorData

Access

Code

State

”Semi” Object-Oriented Paradigm

Behavior State

Data

Access

Code

Model-View-ViewModel aka Presentation Model

2-way through Data Binding

View

ViewModel

Model

Complexity

N-tier design will increase complexity for small applications, but decrease complexity for large applications

Talk is cheap. Show me the code!!

WCF Services

Server Repository

Client Repository

UI Shell

UI module X

UI module Y

Unity

Model

Unity

Not Quite UML..

Best Practice / Our Practice...

• Do share the Business Logic (model)

• Do block the UI (area) when making service calls

• Do use SSL to secure data on the wire

• Do protect the WCF services with authentication

• Avoid the generated proxy

• Consider using prism for loosely coupled UI & Communication

• Consider using DI to manage dependencies / mock

• Consider to bundle the service calls

• Consider using compression

• Do use a framework to encapsulate logic like this

Frameworks functionality

Functionality that almost any Line-Of-Business application needs (silverlight or not)

- State tracking- Validations rules- Undo support- Full data binding support- Authorization - Authentication- Job scheduling- and more…

Frameworks

• CSLA.NET- http://www.lhotka.net/cslanet/

• RIA Services- http://code.msdn.microsoft.com/RiaServices

• PRISM-http://compositewpf.codeplex.com/

• Build-It-Yourself approach…

Questions

THOMAS JUUL

Senior Consultant, TENTEO

thomasj@tenteo.com

www.coreclr.dk

Recommended