SlideShare a Scribd company logo
Object Oriented
Views
Aki Salmi
@rinkkasatiainen
I like to do
crazy stuff
codefreeze.fi
experimental coding
Programmer
@Ambientia
skype: rinkkasatiainen
twitter: @rinkkasatiainen
web: rinkkasatiainen.fi
email: aki.salmi@iki.fi
Goal for this talk
is to
Initiate discussion
anyone @
Socrates 2014
Content
• Background
• A way to solve
• Discussion
• Open Space: Mob Programming?
Very Brief Background
• Confluence plugin
• real production code (used by
thousands, daily)
We have all seen
Controllers like
This
/INDEX
(1 of many actions)
Params
Service
“DAO”
“or not DAO”
DAO-DAO-DAO
Service
Service
Domain
Service
Render
Not that, not today
Let’s assume we’re
working with thin
controllers
Have we seen
views like
this
Only today: logic in a view
So how then?
How about Code I’ve
written myself?
Not much better
A Deeper Dive
Params
BUILD
CONTEXT
GET MODEL
RENDER
OR RENDER
But there is a catch
Render Many Blogs
Or 1, or 0
... based on object
types
Build a ‘different’
domain entity?
Build
‘real’
Domain
Build
‘real’
Domain
Build a ‘different’
Context
BUILD
context
Diff
context
no
context
Render ‘different’
template
Templ_0
Templ_1
Templ_n
Seems like a
violation of SRP
(Single Responsibility Principle)
What did we see
• build parameters
• build context (on 2 places)
• build domain
• render different data, differently,
based on the domain entity
Visually
Controller
HTTP GET
Domain
View 0 View 1 View N
It works
..sort of
• most of the bugs I introduced, were
on this behavior of the system.
• This class
• Concepts introduced by this class
• Integration with Confluence API
• especially ‘null’s
What IF
Controller
HTTP GET
Domain
View 0 View 1 View N
What IF...
C’s responsibility
• Given a set of parameters...
• Build Model (service / repository)
• Render Template with model given
• and let other’s to figure out which
is the view to render
Decorate / Exhibit
Controller
HTTP GET
Domain
View
Exhibit
1) build model
2) render
3) exhibit
View tmpl
4) render
How does it work
few design decision
done by me
• avoid nulls
• separate Read Model from Write Model
• 1st class collections
• Separated Query and Command
Controller (sort of CQRS)
Domain Entity: Group
<if> ReadOrWriteModel
<if> ReadModel <if> WriteModel
GroupEntity GroupDescrGroupList
Domain Entity: Group
<if> ReadOrWriteModel
<if> ReadModel <if> WriteModel
GroupEntity GroupDescrGroupList
Domain Entity: Group
GroupEntity
* immutable
* final private prop
* behavior rich
GroupDescriptor
* public properties
* tiny behavior
AGroupThatDoes
NotExistYet
AGroup
Domain Entity: Group
<if> ReadOrWriteModel
<if> ReadModel <if> WriteModel
GroupEntity GroupDescrGroupList
Domain Entity: Group
GroupList
* behavior: iterate
Introducing Exhibits
• Introduced by Avdi Grimm
• sort of presenter-decorator
Exhibit Characteristics
• Wraps a single model instance
• Is a true Decorator
• Brings together model and context
• Encapsulates the decision about how
to render an object
• May modify the behavior of an object
Exhibit B
Exhibit A
Exhibit visually
Model object
Exhibits: Group
<if> Exhibit
+ renderBody()
GroupListExh GroupList
GroupExhibit
GroupEntity
EditGroupExh GroupDesc
GroupWPicture
Exhibits: Group
GroupListExh ListView
GroupExhibit GroupView
EditGroupExh EditGroup
GroupWPicture GPictureView
REST view
HTTP PATH Contr#Action Domain Class
GET /foo(.:format) foos#index FooList
POST /foo(.:format) foos#create FooDescriptor
GET /foo/new foos#new FooDescriptor
GET /foo/:id/edit foos#edit FooDescriptor
GET /foo/:id foos#show FooEntry
PATCH/PUT /foo/:id foos#update FooDescriptor
DELETE /foo/:id foos#delete FooDescriptor
Creating exhibits
the ruby way 1/2
Avdi Grimm: Object on Rails, Listing 76
Creating exhibits
the ruby way 2/2
Avdi Grimm: Object on Rails, Listing 77
Creating exhibits
the Java 8 way 1/N
Time for some code
Confluence plugin
Velocity templates
View
Controller
Exhibit A
Exhibit B
Exhibit C
Exhibit D
Decorate / Exhibit
Controller
HTTP GET
Domain
View
Exhibit
1) build model
2) render
3) exhibit
View tmpl
4) render
And visually
Surroundings
Exhibit templates
RemotePictureExhibit ||
DefaultPictureExhibit
UserProfileExhibit
Could be composite
Did it work -
in retrospect
• No issues in production with this
code
• It is not, by far, easy to grasp. Without
someone explaining
What I did not show
• transformations of domain entities:
• Request -> Write -> Persistence
• Persistence -> Write (-> Read)
• Composite Exhibit - how to show 0, 1
or many concepts, dynamically,
based on the ModelObject rendered
What could I experiment
• Capabilities for exhibits
• Capability.mobile
• Capability.REST
• Capability.json
Thanks!
Questions?
skype: @rinkkasatiainen
twitter: @rinkkasatiainen
email: aki.salmi@iki.fi

More Related Content

Similar to Object Oriented Views / Aki Salmi

Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cph
cyberswat
 
MongoDB Basics
MongoDB BasicsMongoDB Basics
MongoDB Basics
Sarang Shravagi
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
Marco Breveglieri
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developed
Alexander Makarov
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013
Brian Sam-Bodden
 
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
Prasoon Kumar
 
D7 entities fields
D7 entities fieldsD7 entities fields
D7 entities fields
cyberswat
 
Drupal as a Programmer-Friendly CMS at ConFoo
Drupal as a Programmer-Friendly CMS at ConFooDrupal as a Programmer-Friendly CMS at ConFoo
Drupal as a Programmer-Friendly CMS at ConFoo
Suzanne Dergacheva
 
Chris Lea - What does NoSQL Mean for You
Chris Lea - What does NoSQL Mean for YouChris Lea - What does NoSQL Mean for You
Chris Lea - What does NoSQL Mean for You
Carsonified Team
 
Javascript mynotes
Javascript mynotesJavascript mynotes
Javascript mynotes
AntoniaSymeonidou1
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesignMongoDB APAC
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
Emma Jane Hogbin Westby
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Acquia
 
Yii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toYii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading to
Alexander Makarov
 
Doing Drupal Multi-site without code
Doing Drupal Multi-site without codeDoing Drupal Multi-site without code
Doing Drupal Multi-site without code
el-studio.com
 
Look Again at the ZCA
Look Again at the ZCALook Again at the ZCA
Look Again at the ZCA
mikerhodes
 
Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7
Jay Epstein
 
Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7
Jay Epstein
 
Domain specific languages in eclipse with Xtext (Zeus, UGent)
Domain specific languages in eclipse with Xtext (Zeus, UGent)Domain specific languages in eclipse with Xtext (Zeus, UGent)
Domain specific languages in eclipse with Xtext (Zeus, UGent)
Sigasi
 

Similar to Object Oriented Views / Aki Salmi (20)

Drupalcon cph
Drupalcon cphDrupalcon cph
Drupalcon cph
 
MongoDB Basics
MongoDB BasicsMongoDB Basics
MongoDB Basics
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developed
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013
 
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
MongoDB Introduction talk at Dr Dobbs Conference, MongoDB Evenings at Bangalo...
 
D7 entities fields
D7 entities fieldsD7 entities fields
D7 entities fields
 
Drupal as a Programmer-Friendly CMS at ConFoo
Drupal as a Programmer-Friendly CMS at ConFooDrupal as a Programmer-Friendly CMS at ConFoo
Drupal as a Programmer-Friendly CMS at ConFoo
 
Chris Lea - What does NoSQL Mean for You
Chris Lea - What does NoSQL Mean for YouChris Lea - What does NoSQL Mean for You
Chris Lea - What does NoSQL Mean for You
 
Javascript mynotes
Javascript mynotesJavascript mynotes
Javascript mynotes
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
 
Forensic Theming - DrupalCon London
Forensic Theming - DrupalCon LondonForensic Theming - DrupalCon London
Forensic Theming - DrupalCon London
 
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2Ready. Set. Drupal! An Intro to Drupal 8, Part 2
Ready. Set. Drupal! An Intro to Drupal 8, Part 2
 
Yii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading toYii, frameworks and where PHP is heading to
Yii, frameworks and where PHP is heading to
 
Doing Drupal Multi-site without code
Doing Drupal Multi-site without codeDoing Drupal Multi-site without code
Doing Drupal Multi-site without code
 
Dojo training
Dojo trainingDojo training
Dojo training
 
Look Again at the ZCA
Look Again at the ZCALook Again at the ZCA
Look Again at the ZCA
 
Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7
 
Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7Building Websites of the Future With Drupal 7
Building Websites of the Future With Drupal 7
 
Domain specific languages in eclipse with Xtext (Zeus, UGent)
Domain specific languages in eclipse with Xtext (Zeus, UGent)Domain specific languages in eclipse with Xtext (Zeus, UGent)
Domain specific languages in eclipse with Xtext (Zeus, UGent)
 

Recently uploaded

top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 

Recently uploaded (20)

top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 

Object Oriented Views / Aki Salmi