SlideShare una empresa de Scribd logo
1 de 69
Glass V4, More Info For
Your Solution
Mike Edwards
Glass
@mikeedwards83
@glasslu
Sitecore User Group Conference 2015 1
Glass V4, More Info For
Your Solution
Modeling
Mike Edwards
Glass
@mikeedwards83
@glasslu
Sitecore User Group Conference 2015 2
Hello!
Sitecore User Group Conference 2015 3
Mike
Edwards
Sitecore MVP
@mikeedwards83
@glasslu
Modelling
Sitecore User Group Conference 2015 4
NOT THIS KIND
Modelling
Sitecore User Group Conference 2015 5
THIS KIND
Modelling
• Different Patterns
• Common Mistakes
• Techniques
Sitecore User Group Conference 2015 6
Common Patterns
• Active Record
• Data Mapping
• Wrapping
Sitecore User Group Conference 2015 7
Active Record Pattern
In software engineering, the active record pattern is an
architectural pattern found in software that stores in-memory
object data in relational databases. The interface of an object
conforming to this pattern would include functions such as
Insert, Update, and Delete.
- Wiki, Martin Fowler
Sitecore User Group Conference 2015 8
Active Record Pattern
Sitecore User Group Conference 2015 9
The Example
Active Record Pattern - Pro’s
Simple to use:
Sitecore User Group Conference 2015 10
Active Record Pattern - Pro’s
Simple to pass around:
Sitecore User Group Conference 2015 11
Hidden side effects:
Active Record Pattern - Con’s
Sitecore User Group Conference 2015 12
Surprise!!
Pointless
Active Record Pattern - Cons
Coupled to data source:
Sitecore User Group Conference 2015 13
Active Record Pattern - Con’s
Complex:
Sitecore User Group Conference 2015 14
Active Record Pattern - Con’s
Hard to test:
Sitecore User Group Conference 2015 15
How do we
mock this??
Ask the FakeDB
Guys
Data Mapper Pattern
Data Mapper is a Data Access Layer that performs bidirectional
transfer of data between a persistent data store (often a
relational database) and an in memory data representation (the
domain layer). The goal of the pattern is to keep the in memory
representation and the persistent data store independent of
each other and the data mapper itself.
- Wiki, Martin Fowler
Sitecore User Group Conference 2015 16
Data Mapper Pattern
Sitecore User Group Conference 2015 17
The Example
Data Mapper Pattern
Sitecore User Group Conference 2015 18
The Example
Data Mapper Pattern
Sitecore User Group Conference 2015 19
The Example
Data Mapper Pattern
Simple Models
Sitecore User Group Conference 2015 20
Data Mapper Pattern - Pro’s
Easy Testing
Sitecore User Group Conference 2015 21
Data Mapper Pattern - Pro’s
Clear Separation
Sitecore User Group Conference 2015 22
My World Their World
Data Mapper Pattern - Pro’s
Store Anywhere
Sitecore User Group Conference 2015 23
Data Mapper Pattern - Pro’s
Clear Control
Sitecore User Group Conference 2015 24
Hello!!
Data Mapper Pattern - Con’s
Map Unused Data
Sitecore User Group Conference 2015 25
Data Mapper Pattern - Con’s
Expensive Upfront
Sitecore User Group Conference 2015 26
Data Mapper Pattern - Con’s
Disconnection from source
Sitecore User Group Conference 2015 27
Where the hell did you
come from?
Wrappers Models
Wraps the underlying data source and converts the data on
demand. The internal model contains a reference to the original
data source which it uses to perform data conversion.
Sitecore User Group Conference 2015 28
Wrappers Models
Sitecore User Group Conference 2015 29
Wrappers Models - Pro’s
Cheap Up Front
Sitecore User Group Conference 2015 30
No work done here!
Only accessed properties
require conversion.
Wrappers Models - Pro’s
Hidden State Changes
Sitecore User Group Conference 2015 31
What happens if this
changes
Wrappers Models - Pro’s
Hidden State Changes
Sitecore User Group Conference 2015 32
Are these the same?
Wrappers Models - Con’s
Testing Difficulty
Sitecore User Group Conference 2015 33
Can’t test because
of this.
Have to write
data conversion code
Need to understand
this
Wrappers Models - Meet my partner
Coupling
Sitecore User Group Conference 2015 34
I ask for this
Wrappers Models - Meet my partner
Coupling
Sitecore User Group Conference 2015 35
I get this
Common Problems
• Anemic domain model
• Bloated domain model
• Skinny domain model
• Indiscreet domain model
Sitecore User Group Conference 2015 36
Anemic Domain Model
Anemic domain model is the use of a software domain model
where the domain objects contain little or no business logic
(validations, calculations, business rules etc).
- Wiki, Martin Fowler
Sitecore User Group Conference 2015 37
Anemic Domain Model - Example
Sitecore User Group Conference 2015 38
Feed Me!!
Anemic Domain Model
Sitecore User Group Conference 2015 39
Bloated Domain Model
A Bloated Domain Model is the use of a software domain model
that contains a large number of properties that are never access
or required by the application.
- Mike E
Sitecore User Group Conference 2015 40
Bloated Domain Model
Sitecore User Group Conference 2015 41
Bloated Domain Model
Fixed
Sitecore User Group Conference 2015 42
Skinny Domain Model
A Skinny Domain Model is the use of a software domain model
that contains one or very few properties.
- Mike
Sitecore User Group Conference 2015 43
Skinny Domain Model
Skinny Domain model
Sitecore User Group Conference 2015 44
Skinny Domain Model
Fixed
Sitecore User Group Conference 2015 45
USE THE RAW API!
Indiscreet Domain Model
A Indiscreet Domain Model is the use of a software domain
model that exposes all it’s properties publically even if they
should or should not be accessed by external code.
- Mike E
Sitecore User Group Conference 2015 46
Indiscreet Domain Model
Sitecore User Group Conference 2015 47
Indiscreet Domain Model
Fixed
Sitecore User Group Conference 2015 48
Techniques
Sitecore User Group Conference 2015 49
• Interface Models
• Template Models
• Rendering Models
• MVC
• MVP
Interface Models
Sitecore User Group Conference 2015 50
Domain models defined using interfaces only. Interface are
dynamically implemented at run time using a proxy framework.
Interface Models
Sitecore User Group Conference 2015 51
Interface Models
• Multiple Inheritance
• Very little code
• Often Anemic
• Indiscreet
Sitecore User Group Conference 2015 52
Interface Models
Sitecore User Group Conference 2015 53
Spoofing Logic
Template Models
Sitecore User Group Conference 2015 54
Template Models
• Code generation friendly
• Easy to sync
• Bloated
• Indiscreet
• Anemic
Sitecore User Group Conference 2015 55
Rendering Models
Sitecore User Group Conference 2015 56
Rendering Models
• Use case specific
• Minimum number of properties
• Custom methods
• Model explosion
• Magic Properties Problem
• Skinny
Sitecore User Group Conference 2015 57
MVC Models
Model–view–controller (MVC) is a software architectural
pattern for implementing user interfaces. It divides a given
software application into three interconnected parts, so as to
separate internal representations of information from the ways
that information is presented to or accepted from the user.
- - Wiki
Sitecore User Group Conference 2015 58
MVC Models
What do we pass to the view?
Sitecore User Group Conference 2015 59
MVC Models
The View Model
• Explicitly defines the contract
• Easy to expand
• Use convention
• Separates Domain from View
Sitecore User Group Conference 2015 60
MVC Models
Sitecore User Group Conference 2015 61
Easy to find
MVC Models
Sitecore User Group Conference 2015 62
Easy to identify!
And don’t forget MVP!
MVP is a user interface architectural pattern engineered to
facilitate automated unit testing and improve the separation of
concerns in presentation logic.
- Wiki
Sitecore User Group Conference 2015 63
MVP
Sitecore User Group Conference 2015 64
MVP is similar to MVC
Sitecore User Group Conference 2015 65
MVP or MVC?
Sitecore User Group Conference 2015 66
Finished!!
Questions?
Sitecore User Group Conference 2015 67
68
Find Me:
Sitecore User Group Conference 2015 68
Mike
Edwards
Sitecore MVP
@mikeedwards83
@glasslu
mike@glass.lu
[Reserved for sponsor logo’s]
Sitecore User Group Conference 2015 69Sitecore User Group Conference 2015 69
Thank you

Más contenido relacionado

La actualidad más candente

Wavemaker RAD for the Cloud with CloudJee - Future Direction 2014
Wavemaker RAD for the Cloud with CloudJee - Future Direction 2014Wavemaker RAD for the Cloud with CloudJee - Future Direction 2014
Wavemaker RAD for the Cloud with CloudJee - Future Direction 2014
Francisco Gonçalves
 
End to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) EuropeEnd to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) Europe
Alexandre Morgaut
 

La actualidad más candente (14)

Build HTML5 Sites/Apps with Kendo UI Core
Build HTML5 Sites/Apps with Kendo UI CoreBuild HTML5 Sites/Apps with Kendo UI Core
Build HTML5 Sites/Apps with Kendo UI Core
 
Wavemaker RAD for the Cloud with CloudJee - Future Direction 2014
Wavemaker RAD for the Cloud with CloudJee - Future Direction 2014Wavemaker RAD for the Cloud with CloudJee - Future Direction 2014
Wavemaker RAD for the Cloud with CloudJee - Future Direction 2014
 
SSR with React - Connecting Next.js with WordPress
SSR with React - Connecting Next.js with WordPressSSR with React - Connecting Next.js with WordPress
SSR with React - Connecting Next.js with WordPress
 
WaveMaker Next: Webinar - Presentation
WaveMaker Next: Webinar  - PresentationWaveMaker Next: Webinar  - Presentation
WaveMaker Next: Webinar - Presentation
 
End to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) EuropeEnd to-end W3C - JS.everywhere(2012) Europe
End to-end W3C - JS.everywhere(2012) Europe
 
From Web App Model Design to Production with Wakanda
From Web App Model Design to Production with WakandaFrom Web App Model Design to Production with Wakanda
From Web App Model Design to Production with Wakanda
 
Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_
 
iOS团队开发实践经验
iOS团队开发实践经验iOS团队开发实践经验
iOS团队开发实践经验
 
Geek night micro front ends
Geek night   micro front endsGeek night   micro front ends
Geek night micro front ends
 
Java in azure dev ops
Java in azure dev opsJava in azure dev ops
Java in azure dev ops
 
Tanner Ellen - Forcelandia 2016 - Dev Stack.pptx
Tanner Ellen - Forcelandia 2016 - Dev Stack.pptxTanner Ellen - Forcelandia 2016 - Dev Stack.pptx
Tanner Ellen - Forcelandia 2016 - Dev Stack.pptx
 
Java 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
Java 8: Nashorn & avatar.js di Enrico Risa al JUG RomaJava 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
Java 8: Nashorn & avatar.js di Enrico Risa al JUG Roma
 
ExtJS: La piattaforma vincente (tools)
ExtJS: La piattaforma vincente (tools)ExtJS: La piattaforma vincente (tools)
ExtJS: La piattaforma vincente (tools)
 
JavaFX and HTML5 - Like Curds and Rice
JavaFX and HTML5 - Like Curds and RiceJavaFX and HTML5 - Like Curds and Rice
JavaFX and HTML5 - Like Curds and Rice
 

Similar a SUGCON 2015 Modelling

Software Factory Tools Partner Day Final
Software Factory Tools Partner Day FinalSoftware Factory Tools Partner Day Final
Software Factory Tools Partner Day Final
Lek Pongpatimet
 

Similar a SUGCON 2015 Modelling (20)

SUG Bangalore - Kick Off Session
SUG Bangalore - Kick Off SessionSUG Bangalore - Kick Off Session
SUG Bangalore - Kick Off Session
 
Sitecore MVC Advanced
Sitecore MVC AdvancedSitecore MVC Advanced
Sitecore MVC Advanced
 
Connecting the odds in the brave world! Sitecore Commerce Connect
Connecting the odds in the brave world!Sitecore Commerce ConnectConnecting the odds in the brave world!Sitecore Commerce Connect
Connecting the odds in the brave world! Sitecore Commerce Connect
 
O2 platform and ASP.NET MVC, by Michael Hidalgo
O2 platform and ASP.NET MVC, by Michael HidalgoO2 platform and ASP.NET MVC, by Michael Hidalgo
O2 platform and ASP.NET MVC, by Michael Hidalgo
 
Scribe online 03 scribe online cdk and api overview
Scribe online 03   scribe online cdk and api overviewScribe online 03   scribe online cdk and api overview
Scribe online 03 scribe online cdk and api overview
 
Blockchain, Integration, Serverless, Microservices - OOW / Code One 2018 Review
Blockchain, Integration, Serverless, Microservices - OOW / Code One 2018 ReviewBlockchain, Integration, Serverless, Microservices - OOW / Code One 2018 Review
Blockchain, Integration, Serverless, Microservices - OOW / Code One 2018 Review
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
Cloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a CacheCloud-native Data: Every Microservice Needs a Cache
Cloud-native Data: Every Microservice Needs a Cache
 
Accelerate Sitecore DevOps on Microsoft Azure
Accelerate Sitecore DevOps on Microsoft AzureAccelerate Sitecore DevOps on Microsoft Azure
Accelerate Sitecore DevOps on Microsoft Azure
 
AMIS Oracle OpenWorld en Code One Review 2018 - Blockchain, Integration, Serv...
AMIS Oracle OpenWorld en Code One Review 2018 - Blockchain, Integration, Serv...AMIS Oracle OpenWorld en Code One Review 2018 - Blockchain, Integration, Serv...
AMIS Oracle OpenWorld en Code One Review 2018 - Blockchain, Integration, Serv...
 
Sitecore mvc
Sitecore mvcSitecore mvc
Sitecore mvc
 
Icon solutions presentation - Pure Hybrid Cloud Event, 11th September London
Icon solutions presentation - Pure Hybrid Cloud Event, 11th September LondonIcon solutions presentation - Pure Hybrid Cloud Event, 11th September London
Icon solutions presentation - Pure Hybrid Cloud Event, 11th September London
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
Cloud-native Data
Cloud-native DataCloud-native Data
Cloud-native Data
 
Cloud-Native-Data with Cornelia Davis
Cloud-Native-Data with Cornelia DavisCloud-Native-Data with Cornelia Davis
Cloud-Native-Data with Cornelia Davis
 
Tutorial Expert How-To - Command Line Interface (CLI)
Tutorial Expert How-To - Command Line Interface (CLI)Tutorial Expert How-To - Command Line Interface (CLI)
Tutorial Expert How-To - Command Line Interface (CLI)
 
Cameo Workbench
Cameo WorkbenchCameo Workbench
Cameo Workbench
 
Sitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helixSitecore development approach evolution – destination helix
Sitecore development approach evolution – destination helix
 
Software Factory Tools Partner Day Final
Software Factory Tools Partner Day FinalSoftware Factory Tools Partner Day Final
Software Factory Tools Partner Day Final
 
.netcampus2015 office365dev
.netcampus2015 office365dev.netcampus2015 office365dev
.netcampus2015 office365dev
 

SUGCON 2015 Modelling

Notas del editor

  1. DO NOT REMOVE THIS SLIDE
  2. DO NOT REMOVE THIS SLIDE