SlideShare une entreprise Scribd logo
1  sur  62
Building an enterprise application with Silverlight and NHibernate Gill CleerenMicrosoft Regional Director/MVP ASP.NETVisugUsergroup lead - Ordina www.snowball.be Bart Wullems MCT, MCPD Application Architect Ordina bartwullems.blogspot.com
Agenda Building the foundation CQRS OData NHibernate Building the front-end in Silverlight MVVM What is MVVM? Why and why not The parts of MVVM Implementing MVVM principles Demo Finding your VM using MEF Commanding Communication between VMs
Scenario:  Planning your vacation  with NHibernate and Silverlight
Building the foundation
Bye bye 3-tier
What is CQRS?
CQS Defined Bertrand Meyer (via Wikipedia) “Command Query Separation” “every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, asking a question should not change the answer.”
CQRS defined Meyer:  Separate command methods that change state from query methods that read state. Greg Young:  Separate command messages that change state from query messages that read state. Can have significant architectural implications
Welcome CQRS
Queries Simple Query Layer Simple views or sprocs or selects from denormalized tables Simple DTOs, no mapping needed Don’t go through the Domain Model, as it pollutes it ViewModel per query perhaps Why should the data come across 5 layers through 3 model transformations to populate a screen? (Udi) Synchronous, no messaging needed
Commands Commands capture intent, DTOs don’t CustomerDTOvsCustomerChangedAddressCommand Handler per command Can be validated outside of domain entities This is why domain entities are never invalid, commands that would produce invalid state are rejected
Commands Separate Data Modification Make preferred Change address A generic DTO could do these things, of course, but after the fact, how do you know what actually happened? UI Implications Grid-like screens don’t work Commands require specific intent
How do we implementthis?
Implement the  query model usingodata
OData.org
A RESTful Interface for Data Just HTTP Data as resources, HTTP methods to act on it Leverage caching, proxies, authentication, … Uniform URL syntax Every piece of information is addressable Predictable and flexible URL syntax Multiple representations Use regular HTTP content-type negotiation AtomPub, JSON
Model and Operation Semantics Underlying data model Entity Data Model Entities Resources AssociationsLinks Operation semantics Mapping of HTTP methods GET  Retrieve resource POST Create resource PUT  Update resource DELETE Delete resource
WCF (Data) Services WCF Data Services	 WCF Services REST AtomPub OData SOAP WS-Security WS-*
WCF Data Services HTTP Data Services Runtime Reflection Provider .NET Classes [+ LINQ provider] Data Source(IQueryable)
oData and Silverlight Accessing Data Services Silverlight ClientHttp stack still an option Data Services Client more usable as it knows the details of the data service interface Features Full abstraction on top of the service – no need to deal with HTTP, serialization, etc Data as objects with automatic change tracking LINQ for queries Data-binding friendly interfaces Work same-domain and cross-domain
CQRS and OData OData 21
Demo UsingOData to implement the query part of CQRS 22
Implement the  domain model usingnhibernate
NHibernate Full-featured ORM solution Open source Based on Java’s Hibernate framework Uses XML(by default) to map tables/columns to objects/properties
NHibernate API
NHibernateQuickstart Create hibernate.cfg.xml or use app.config varcfg = newConfiguration();  cfg.Configure(); varsf = cfg.BuildSessionFactory(); using(var s = sf.OpenSession()) using(vartx = s.BeginTransaction())  {    var c = s.Get<Customer>(42); tx.Commit(); }
WhyNHibernate? EntityFramework GreatforRapidApplicationDevelopment Falls short forEnterpriseApplicationDevelopment NHibernate has	 More maturity More flexibility Betterextensibility
CQRS and NHibernate NHibernate NHibernate 29
Convention over Configuration FluentNHibernate http://fluentnhibernate.org Replaces XML mappingbyfluentmapping XML configurationbyfluentconfiguration Advantages Type safety Removestedious XML mappings Intuitive interface Conventions
AutomaticSession management DataContext per Request IServiceBus Request 1 Session 1 DB Session 2 Request 2
Demo Using NHibernate to implement the domain part of CQRS 32
Building the front-end in Silverlight
What is MVVM?
Understanding MVVM MVVM : is an architectural pattern created by John Gossman from WPF team is a variation of MVC pattern is similar to Martin Fowler’s PresentationModel pattern works because of Silverlight data Binding & commanding is typically used in WPF/SL-applications to leverage the power of XAML, so that Devs and Designers can work together easier 35
Understanding MVVM
Why and why not MVVM?
Why MVVM Better SoC (Seperation of Concerns) More maintainable Model never needs to be changed to support changes to the view ViewModel rarely needs to be changed to support changes to the view More testable  ViewModelis easier to unit test than code-behind or event driven code Eliminates the need to do code behind which leaves the UI all in XAML  38
Why MVVM Because the framework (SL & WPF) have the power to support it Databinding/DataContext Increases the "Blendability" of your view
Why not MVVM ,[object Object],Message to community is not clear!! ,[object Object]
Too much code neededINotifyPropertyChanged Commands 40
The parts of MVVM
What we all do… All UI code in code-behind View XAML Data Model Code-Behind Event Handlers
The MVVM way View XAML Code-Behind Change notification Data-binding and commands View Model Data Model State + Operations
The parts of MVVM ,[object Object]
ViewModel knows Models
But not vice versa.View ViewModel Model 44
The View ,[object Object],represents the user interface that the user will see. can be a user control or Data Template shouldn't contain any logic that you want to test should be kept as simple as possible. 45
The ViewModel ,[object Object]
Connector between View and Model
Make VM as testable as possible46
The Model ,[object Object]
No reference to ViewModel47
Where to start? BING (or google is fine as well ) MVVM Light Toolkit Prism Caliburn 48
Demo Let’s take a look at an MVVM implementation 49
Implementing MVVM principles
View model base class Implements INotifyPropertyChanged Contains base code for all VMs to re-use 51
Demo BaseViewModel 52
Which comes first... 2 options:  View first ViewModel first 53
ViewFirst Based on XAML mostly The View has a relationship to its ViewModel (usually through data binding). DataContext={Binding ...} Available at design time (Blend support) 54 View <UserControl.DataContext>     <dive:PageViewModel /> </UserControl.DataContext>
ViewModel First The ViewModel creates the view  usually through an IoCcontaineror MEF	 55 View Model public MyViewModel(IMyViewmyView) { myView.Model = this; }
How to implement this? Locator pattern Implemented through a class that contains all VMs as static properties An instance is then made available as Resource All Views can bind, no code needed in View  Clean way  Not good since all VMs need to be known upfront Property for each available VM Difficult if application is MDI-like (more than one instance available) 56

Contenu connexe

Tendances

ASP .NET MVC Introduction & Guidelines
ASP .NET MVC Introduction & Guidelines  ASP .NET MVC Introduction & Guidelines
ASP .NET MVC Introduction & Guidelines Dev Raj Gautam
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
Architecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsArchitecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsGunnar Peipman
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overviewSergey Seletsky
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performancerudib
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantNitin Sawant
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentationBhavin Shah
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCAnton Krasnoshchok
 
Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Shiju Varghese
 
Head first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rttHead first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rttLanvige Jiang
 
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5Aaron Jacobson
 
What's new in asp.net mvc 4
What's new in asp.net mvc 4What's new in asp.net mvc 4
What's new in asp.net mvc 4Simone Chiaretta
 
Setup ColdFusion application using fusebox mvc architecture
Setup ColdFusion application using fusebox mvc architectureSetup ColdFusion application using fusebox mvc architecture
Setup ColdFusion application using fusebox mvc architectureMindfire Solutions
 

Tendances (20)

ASP .NET MVC Introduction & Guidelines
ASP .NET MVC Introduction & Guidelines  ASP .NET MVC Introduction & Guidelines
ASP .NET MVC Introduction & Guidelines
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
Architecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsArchitecting ASP.NET MVC Applications
Architecting ASP.NET MVC Applications
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overview
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performance
 
ColdFusion 11 New Features
ColdFusion 11 New FeaturesColdFusion 11 New Features
ColdFusion 11 New Features
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0
 
Head first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rttHead first asp.net mvc 2.0 rtt
Head first asp.net mvc 2.0 rtt
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
MVC 6 Introduction
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
 
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
Discuss About ASP.NET MVC 6 and ASP.NET MVC 5
 
What's new in asp.net mvc 4
What's new in asp.net mvc 4What's new in asp.net mvc 4
What's new in asp.net mvc 4
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
ASP.NET MVC for Begineers
ASP.NET MVC for BegineersASP.NET MVC for Begineers
ASP.NET MVC for Begineers
 
Setup ColdFusion application using fusebox mvc architecture
Setup ColdFusion application using fusebox mvc architectureSetup ColdFusion application using fusebox mvc architecture
Setup ColdFusion application using fusebox mvc architecture
 

En vedette

Unit Testing MVVM in Silverlight
Unit Testing MVVM in SilverlightUnit Testing MVVM in Silverlight
Unit Testing MVVM in SilverlightTimmy Kokke
 
Real-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFReal-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFPaul Stovell
 
MVVM+MEF in Silvelight - W 2010ebday
MVVM+MEF in Silvelight - W 2010ebdayMVVM+MEF in Silvelight - W 2010ebday
MVVM+MEF in Silvelight - W 2010ebdayRicardo Fiel
 
NHibernate for .NET
NHibernate for .NETNHibernate for .NET
NHibernate for .NETGuo Albert
 
NHibernate (The ORM For .NET Platform)
NHibernate (The ORM For .NET Platform)NHibernate (The ORM For .NET Platform)
NHibernate (The ORM For .NET Platform)Samnang Chhun
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

En vedette (7)

Unit Testing MVVM in Silverlight
Unit Testing MVVM in SilverlightUnit Testing MVVM in Silverlight
Unit Testing MVVM in Silverlight
 
Real-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPFReal-world Model-View-ViewModel for WPF
Real-world Model-View-ViewModel for WPF
 
MVVM+MEF in Silvelight - W 2010ebday
MVVM+MEF in Silvelight - W 2010ebdayMVVM+MEF in Silvelight - W 2010ebday
MVVM+MEF in Silvelight - W 2010ebday
 
Adopting MVVM
Adopting MVVMAdopting MVVM
Adopting MVVM
 
NHibernate for .NET
NHibernate for .NETNHibernate for .NET
NHibernate for .NET
 
NHibernate (The ORM For .NET Platform)
NHibernate (The ORM For .NET Platform)NHibernate (The ORM For .NET Platform)
NHibernate (The ORM For .NET Platform)
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similaire à Building an enterprise application with Silverlight, NHibernate and CQRS

Mvvm pattern
Mvvm patternMvvm pattern
Mvvm patternmsarangam
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET WebskillsCaleb Jenkins
 
Presentation Model
Presentation ModelPresentation Model
Presentation ModelAlex Miranda
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC StructureDipika Wadhvani
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Svetlin Nakov
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 daysUdaya Kumar
 
Portable Class Libraries and MVVM
Portable Class Libraries and MVVMPortable Class Libraries and MVVM
Portable Class Libraries and MVVMAndreas Kuntner
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP DevelopersEdureka!
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobilenaral
 
WPF with MVVM: From the Trenches
WPF with MVVM: From the TrenchesWPF with MVVM: From the Trenches
WPF with MVVM: From the TrenchesBrent Edwards
 
Which is better asp.net mvc vs asp.net
Which is better  asp.net mvc vs asp.netWhich is better  asp.net mvc vs asp.net
Which is better asp.net mvc vs asp.netConcetto Labs
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesAaron Jacobson
 
Introduction to mvc architecture
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architectureravindraquicsolv
 
ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1Gaurav Arora
 
Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1Gaurav Arora
 

Similaire à Building an enterprise application with Silverlight, NHibernate and CQRS (20)

Mvvm pattern
Mvvm patternMvvm pattern
Mvvm pattern
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Fundaments of Knockout js
Fundaments of Knockout jsFundaments of Knockout js
Fundaments of Knockout js
 
Presentation Model
Presentation ModelPresentation Model
Presentation Model
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
Architectural Patterns and Software Architectures: Client-Server, Multi-Tier,...
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 days
 
Portable Class Libraries and MVVM
Portable Class Libraries and MVVMPortable Class Libraries and MVVM
Portable Class Libraries and MVVM
 
Spring Framework-II
Spring Framework-IISpring Framework-II
Spring Framework-II
 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
 
Mvc part 1
Mvc part 1Mvc part 1
Mvc part 1
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
WPF with MVVM: From the Trenches
WPF with MVVM: From the TrenchesWPF with MVVM: From the Trenches
WPF with MVVM: From the Trenches
 
Which is better asp.net mvc vs asp.net
Which is better  asp.net mvc vs asp.netWhich is better  asp.net mvc vs asp.net
Which is better asp.net mvc vs asp.net
 
Technoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development servicesTechnoligent providing custom ASP.NET MVC development services
Technoligent providing custom ASP.NET MVC development services
 
Applied MVVM in Windows 8 apps: not your typical MVVM session!
Applied MVVM in Windows 8 apps: not your typical MVVM session!Applied MVVM in Windows 8 apps: not your typical MVVM session!
Applied MVVM in Windows 8 apps: not your typical MVVM session!
 
Introduction to mvc architecture
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architecture
 
ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1
 
Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1
 

Plus de bwullems

GraphQL - A love story
GraphQL -  A love storyGraphQL -  A love story
GraphQL - A love storybwullems
 
ElasticSearch - Search done right
ElasticSearch - Search done rightElasticSearch - Search done right
ElasticSearch - Search done rightbwullems
 
Techorama - Evolvable Application Development with MongoDB
Techorama  - Evolvable Application Development with MongoDBTechorama  - Evolvable Application Development with MongoDB
Techorama - Evolvable Application Development with MongoDBbwullems
 
Git(hub) for windows developers
Git(hub) for windows developersGit(hub) for windows developers
Git(hub) for windows developersbwullems
 
Javascript omg!
Javascript omg!Javascript omg!
Javascript omg!bwullems
 
Tfs Monitor Windows Phone 7 App
Tfs Monitor Windows Phone 7 AppTfs Monitor Windows Phone 7 App
Tfs Monitor Windows Phone 7 Appbwullems
 
Caliburn.micro
Caliburn.microCaliburn.micro
Caliburn.microbwullems
 
Convention over configuration in .Net 4.0
Convention over configuration in .Net 4.0Convention over configuration in .Net 4.0
Convention over configuration in .Net 4.0bwullems
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overviewbwullems
 

Plus de bwullems (9)

GraphQL - A love story
GraphQL -  A love storyGraphQL -  A love story
GraphQL - A love story
 
ElasticSearch - Search done right
ElasticSearch - Search done rightElasticSearch - Search done right
ElasticSearch - Search done right
 
Techorama - Evolvable Application Development with MongoDB
Techorama  - Evolvable Application Development with MongoDBTechorama  - Evolvable Application Development with MongoDB
Techorama - Evolvable Application Development with MongoDB
 
Git(hub) for windows developers
Git(hub) for windows developersGit(hub) for windows developers
Git(hub) for windows developers
 
Javascript omg!
Javascript omg!Javascript omg!
Javascript omg!
 
Tfs Monitor Windows Phone 7 App
Tfs Monitor Windows Phone 7 AppTfs Monitor Windows Phone 7 App
Tfs Monitor Windows Phone 7 App
 
Caliburn.micro
Caliburn.microCaliburn.micro
Caliburn.micro
 
Convention over configuration in .Net 4.0
Convention over configuration in .Net 4.0Convention over configuration in .Net 4.0
Convention over configuration in .Net 4.0
 
Visual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 OverviewVisual Studio 2010 and .NET 4.0 Overview
Visual Studio 2010 and .NET 4.0 Overview
 

Dernier

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 

Dernier (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 

Building an enterprise application with Silverlight, NHibernate and CQRS

  • 1. Building an enterprise application with Silverlight and NHibernate Gill CleerenMicrosoft Regional Director/MVP ASP.NETVisugUsergroup lead - Ordina www.snowball.be Bart Wullems MCT, MCPD Application Architect Ordina bartwullems.blogspot.com
  • 2. Agenda Building the foundation CQRS OData NHibernate Building the front-end in Silverlight MVVM What is MVVM? Why and why not The parts of MVVM Implementing MVVM principles Demo Finding your VM using MEF Commanding Communication between VMs
  • 3. Scenario: Planning your vacation with NHibernate and Silverlight
  • 7. CQS Defined Bertrand Meyer (via Wikipedia) “Command Query Separation” “every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, asking a question should not change the answer.”
  • 8. CQRS defined Meyer: Separate command methods that change state from query methods that read state. Greg Young: Separate command messages that change state from query messages that read state. Can have significant architectural implications
  • 10. Queries Simple Query Layer Simple views or sprocs or selects from denormalized tables Simple DTOs, no mapping needed Don’t go through the Domain Model, as it pollutes it ViewModel per query perhaps Why should the data come across 5 layers through 3 model transformations to populate a screen? (Udi) Synchronous, no messaging needed
  • 11. Commands Commands capture intent, DTOs don’t CustomerDTOvsCustomerChangedAddressCommand Handler per command Can be validated outside of domain entities This is why domain entities are never invalid, commands that would produce invalid state are rejected
  • 12. Commands Separate Data Modification Make preferred Change address A generic DTO could do these things, of course, but after the fact, how do you know what actually happened? UI Implications Grid-like screens don’t work Commands require specific intent
  • 13. How do we implementthis?
  • 14. Implement the query model usingodata
  • 16. A RESTful Interface for Data Just HTTP Data as resources, HTTP methods to act on it Leverage caching, proxies, authentication, … Uniform URL syntax Every piece of information is addressable Predictable and flexible URL syntax Multiple representations Use regular HTTP content-type negotiation AtomPub, JSON
  • 17. Model and Operation Semantics Underlying data model Entity Data Model Entities Resources AssociationsLinks Operation semantics Mapping of HTTP methods GET  Retrieve resource POST Create resource PUT  Update resource DELETE Delete resource
  • 18. WCF (Data) Services WCF Data Services WCF Services REST AtomPub OData SOAP WS-Security WS-*
  • 19. WCF Data Services HTTP Data Services Runtime Reflection Provider .NET Classes [+ LINQ provider] Data Source(IQueryable)
  • 20. oData and Silverlight Accessing Data Services Silverlight ClientHttp stack still an option Data Services Client more usable as it knows the details of the data service interface Features Full abstraction on top of the service – no need to deal with HTTP, serialization, etc Data as objects with automatic change tracking LINQ for queries Data-binding friendly interfaces Work same-domain and cross-domain
  • 21. CQRS and OData OData 21
  • 22. Demo UsingOData to implement the query part of CQRS 22
  • 23. Implement the domain model usingnhibernate
  • 24. NHibernate Full-featured ORM solution Open source Based on Java’s Hibernate framework Uses XML(by default) to map tables/columns to objects/properties
  • 26. NHibernateQuickstart Create hibernate.cfg.xml or use app.config varcfg = newConfiguration(); cfg.Configure(); varsf = cfg.BuildSessionFactory(); using(var s = sf.OpenSession()) using(vartx = s.BeginTransaction()) {   var c = s.Get<Customer>(42); tx.Commit(); }
  • 27. WhyNHibernate? EntityFramework GreatforRapidApplicationDevelopment Falls short forEnterpriseApplicationDevelopment NHibernate has More maturity More flexibility Betterextensibility
  • 28.
  • 29. CQRS and NHibernate NHibernate NHibernate 29
  • 30. Convention over Configuration FluentNHibernate http://fluentnhibernate.org Replaces XML mappingbyfluentmapping XML configurationbyfluentconfiguration Advantages Type safety Removestedious XML mappings Intuitive interface Conventions
  • 31. AutomaticSession management DataContext per Request IServiceBus Request 1 Session 1 DB Session 2 Request 2
  • 32. Demo Using NHibernate to implement the domain part of CQRS 32
  • 33. Building the front-end in Silverlight
  • 35. Understanding MVVM MVVM : is an architectural pattern created by John Gossman from WPF team is a variation of MVC pattern is similar to Martin Fowler’s PresentationModel pattern works because of Silverlight data Binding & commanding is typically used in WPF/SL-applications to leverage the power of XAML, so that Devs and Designers can work together easier 35
  • 37. Why and why not MVVM?
  • 38. Why MVVM Better SoC (Seperation of Concerns) More maintainable Model never needs to be changed to support changes to the view ViewModel rarely needs to be changed to support changes to the view More testable ViewModelis easier to unit test than code-behind or event driven code Eliminates the need to do code behind which leaves the UI all in XAML 38
  • 39. Why MVVM Because the framework (SL & WPF) have the power to support it Databinding/DataContext Increases the "Blendability" of your view
  • 40.
  • 41. Too much code neededINotifyPropertyChanged Commands 40
  • 42. The parts of MVVM
  • 43. What we all do… All UI code in code-behind View XAML Data Model Code-Behind Event Handlers
  • 44. The MVVM way View XAML Code-Behind Change notification Data-binding and commands View Model Data Model State + Operations
  • 45.
  • 47. But not vice versa.View ViewModel Model 44
  • 48.
  • 49.
  • 51. Make VM as testable as possible46
  • 52.
  • 53. No reference to ViewModel47
  • 54. Where to start? BING (or google is fine as well ) MVVM Light Toolkit Prism Caliburn 48
  • 55. Demo Let’s take a look at an MVVM implementation 49
  • 57. View model base class Implements INotifyPropertyChanged Contains base code for all VMs to re-use 51
  • 59. Which comes first... 2 options: View first ViewModel first 53
  • 60. ViewFirst Based on XAML mostly The View has a relationship to its ViewModel (usually through data binding). DataContext={Binding ...} Available at design time (Blend support) 54 View <UserControl.DataContext> <dive:PageViewModel /> </UserControl.DataContext>
  • 61. ViewModel First The ViewModel creates the view usually through an IoCcontaineror MEF 55 View Model public MyViewModel(IMyViewmyView) { myView.Model = this; }
  • 62. How to implement this? Locator pattern Implemented through a class that contains all VMs as static properties An instance is then made available as Resource All Views can bind, no code needed in View  Clean way Not good since all VMs need to be known upfront Property for each available VM Difficult if application is MDI-like (more than one instance available) 56
  • 64. How to implement this? MEF Based on Import: class says it needs an instance of a specific type Export: class says it wants to be made available for composition Composition: MEF links imports and exports together Can create one shared instance or dynamic number thereof Solves earlier problem Easy for testing and mocking 58
  • 66. Commanding Instead of having event handlers in code-behind, we use commands SL4 has the ICommand interface Execute method CanExecuteproperty CanExecuteChangedevent Way to create commands: Write ICommand implementation Create instance on VM Bind Command property of control to this instance 60
  • 67. Commanding Commanding is supported on ButtonBase Button, HyperlinkButton Not on others like ComboBox SelectionChanged Can be solved with event triggers Can be added on every event Part of System.Windows.Interactivity Can be bound to every control
  • 69. Communication 63 View Model View Model View Model View Model View Model View Model View Model View Model
  • 70. Communication 64 View View XAML XAML Code-Behind Code-Behind View Model Data Model View Model State + Operations Data Model State + Operations Message Publish messages View XAML Code-Behind Subscribe to messages Event Aggregator View Model Message State + Operations
  • 71. Communication VM’s need to be able to talk to each other, eg: send messages to each other Not a good idea to have each VM reference all other VMs Solution: Event Aggregator/mediator/messenger VM can register to receive messages of a certain type (for example string messages) Another VM can register with the same messenger to send messages This allows both VMs to communicate with each other without tight coupling 65
  • 73.
  • 74. In View’s constructor, check DesignerProperties.IsInDesignToolUnit testing VMs can easily be unit-tested Silverlight Unit Testing Framework ships with Silverlight 4 Can be used from the browser No real way to integrate with automated testing (MSBuild) yet 67
  • 76. Summary CQRS Gives the necessary level of scalability and maintainabilityforenterpriseapplications oData is greatfor the query part NHibernate rocks for the command part MVVM Create better testable applications Works for both Silverlight and WPF

Notes de l'éditeur

  1. Gill
  2. Gill
  3. Gill
  4. TraditionalN-tierleavestoomuchquestionsunansweredHow to handle the gap betweenvisualization and domain specification(how do youchangeyourrich domain model intosomethingthatcanbevisualized) Most business logicgotscatheredaround
  5. Ons query model tonen(is ook opgebouwd met nHibernate)DataServiceKey attribuutTravelPlannerQueryContextTravelPlannerQueryServiceDataServiceKey even aanpassen naar CityNameAantal voorbeeld urls tonen:/Cities/Cities(‘Paris’)/Cities(‘Paris’)/CityNameCities(‘Paris’)/name/$value/$metadataLinqPad tonen voor complexe gevallen