You are on page 1of 19

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 Services Domain Objects Repository Database

Domain Objects
Repository

Silverlight Client

Application Server

Silverlight 3-tier Architecture


UI Services Domain Objects Repository Database

Domain Objects
Repository

Silverlight Client

Application Server

Database Server

Silverlight 4-tier Architecture


UI Services Services Database

Domain Objects

Domain Objects

Domain Objects

Repository

Repository

Repository

Silverlight Client

DMZ Application Server

Application Server

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

Behavior

Data Access Code

State

Semi Object-Oriented Paradigm

Behavior

State

Data Access Code

Model-View-ViewModel aka Presentation Model


View
2-way through Data Binding

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!!

Not Quite UML..


UI module X UI Shell Unity UI module Y

Client Repository Model WCF Services

Unity Server Repository

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

You might also like