SlideShare a Scribd company logo
1 of 42
Download to read offline
Action-Domain-Responder 
A Web-Specific Refinement Of Model-View-Controller 
! 
CoderFaire 2014 
@pmjones 
! 
http://pmjones.github.io/adr
Read These
About Me 
โ€ข 8 years USAF Intelligence 
โ€ข BASIC in 1983, PHP since 1999 
โ€ข Jr. Developer, VP Engineering 
โ€ข Aura project, Zend_DB, Zend_View 
โ€ข PHP-FIG, PSR-1, PSR-2, PSR-4 
โ€ข MLAPHP (http://mlaphp.com) 
โ€ข Super-Secret Startup (Tandum)
Overview 
โ€ข How we think of MVC versus its desktop origins 
โ€ข How ADR refines โ€œMVCโ€ for the web 
โ€ข How ADR relates to existing โ€œMVCโ€ alternatives 
โ€ข Address ADR comments and questions
โ€œYou Keep Using That Word โ€ฆโ€
Server-Side MVC 
โ€ข From all concerns combined (ball of mud) โ€ฆ 
โ€ข โ€ฆ to separation of concerns (input, business logic, presentation) 
โ€ข Oriented around HTTP (stateless shared-nothing request/response) 
โ€ข Google for โ€œmvc in (php | python | rails)โ€ 
โ€ข General consensus on components, not so much on collaborations
Server-Side MVC Collaborations 
โ€ข User Agent sends a Request 
โ€ข Router/Dispatcher invokes Controller 
โ€ข Controller manages flow, invokes Model(s) that encapsulate domain 
โ€ข Controller assigns values to View template 
โ€ข Controller invokes View and sets into Response (with headers)
โ€œโ€ฆ I Do Not Think It Means 
What You Think It Means.โ€
Smalltalk-80 MVC 
โ€ข Desktop graphical UI pattern 
โ€ข Separation of concerns (input 
management, internal representation of 
domain, presentation to user) 
โ€ข Interactive event-driven desktop 
(keyboard/mouse, in-memory) 
โ€ข Google for โ€œsmalltalk mvcโ€
Smalltalk-80 MVC Collaborations 
โ€ข Controller receives keyboard/mouse input 
events from User 
โ€ข Controller notifies View and Model, 
respectively 
โ€ข View and Model notify each other for updates 
โ€ข View updates are rendered on the screen 
โ€ข Hierarchical collection of interrelated MVC 
triads for each screen element
The Pit Web Of Despair
How To Describe Web UI Patterns? 
โ€ข Model 1: Sun JSP for page scripting (ball of mud) 
โ€ข Model 2 : Servlet for action (Controller) and JSP for template (View)
The Names Are The Same, 
But The Game Has Changed 
โ€ข Used the name MVC for Model 2 
โ€ข Subverted the collaborations 
โ€ข From event-driven to request/response (pages) 
โ€ข No more messaging interactions between triads 
โ€ข One collected set of interactions delivered
Are These The Same?
โ€œDear God, What Is That Thing?โ€ 
โ€ข The pattern name โ€œModel-View-Controllerโ€ has several meanings 
โ€ข Hard to determine exactly what collaborations to expect 
โ€ข Smalltalk-80 MVC relates more closely to client-side 
โ€ข Model 2 MVC relates more closely to server-side 
โ€ข Even more semantic diffusion since 2000: 
โ€ข https://www.google.com/search?q=mvc+diagram
Youโ€™re Trying To Kidnap 
What Iโ€™ve Rightfully Stolen
Toward A Web-Specific UI Pattern 
โ€ข Stop using in-memory desktop GUI patterns as server patterns 
โ€ข Entirely new name to break the association with โ€œMVCโ€ 
โ€ข Remember we are in a client/server (request/response) environment 
โ€ข Use existing server-side โ€œMVCโ€ as a basis 
โ€ข Refine the components and collaborations toward better practices
Refining the โ€œModelโ€ to โ€œDomainโ€ 
โ€ข The โ€œDomainโ€ has essentially identical responsibilities 
โ€ข Reminiscent of โ€œDomain Logicโ€ and โ€œDomain Driven Designโ€ 
โ€ข TransactionScript, DomainModel, TableModule, ServiceLayer 
โ€ข (ActiveRecord is a โ€œData Sourceโ€ pattern)
Refining the โ€œViewโ€ to โ€œResponderโ€ 
โ€ข Usually think of a View system as templates (screen elements) 
โ€ข Client receives HTTP response of both body and headers 
โ€ข This means the View in server-based MVC is not the template 
โ€ข The View in server-based MVC is the Response
Intermingled Presentation Logic 
โ€ข Template Views generally build HTTP body values 
โ€ข Remaining Controller logic manipulates HTTP header values 
โ€ข Presentation logic is mixed between Views and Controllers 
โ€ข Need a layer that is completely in charge of building the Response
โ€œResponderโ€ For Presentation 
โ€ข Responder layer handles setting headers, status, etc 
โ€ข Additionally uses templates for setting body content 
โ€ข Invoke a Responder for presentation of Response
Using Responders In Controllers 
โ€ข Remove Response presentation from all Controller action methods 
โ€ข index(), create(), read(), update(), delete() 
โ€ข Each action method has its own set of status codes and templates
One Responder Per Controller? 
โ€ข One Responder per Controller to cover all possible action methods? 
โ€ข No: inject one Responder per action method 
โ€ข But: injecting Responders that might not be needed
Refining the โ€œControllerโ€ To โ€œActionโ€ 
โ€ข Instead of a Controller with index(), create(), read(), etc. โ€ฆ 
โ€ข โ€ฆ one class per Action: IndexAction, CreateAction, ReadAction, etc. 
โ€ข Inject the individual Responder into the individual Action
โ€œLet me explain. 
No, there is too much. 
Let me sum up.โ€
Components 
โ€ข Domain is the logic to manipulate the domain, session, application, and 
environment data, modifying state and persistence as needed. 
โ€ข Responder is the logic to build an HTTP response or response description. It 
deals with body content, templates and views, headers and cookies, status codes, 
and so on. 
โ€ข Action is the logic that connects the Domain and Responder. It uses the request 
input to interact with the Domain, and passes the Domain output to the Responder.
Collaborations 
โ€ข Action feeds input from HTTP 
request to a Domain layer 
โ€ข Action feeds output from 
Domain layer to a Responder 
โ€ข Responder builds the HTTP 
response headers and body 
Controller 
Model View 
Action 
Domain Responder
Code Examples
About The Examples 
โ€ข Overly-simplified to highlight components and collaborations 
โ€ข Action is minimalist, almost trivial (micro-framework-ish) 
โ€ข Domain becomes much more robust 
โ€ข Responder has to determine presentation based on Domain values
โ€œIโ€™m Not The Real Dread Pirate Roberts.โ€
Is ADR Just Another Pattern โ€œIn Dragโ€? 
โ€ข EBI 
(Entity-Boundary-Interactor) 
โ€ข DCI 
(Data-Context-Interaction) 
โ€ข MVP 
(Model-View-Presenter) 
โ€ข MVVM 
(Model-View-ViewModel) 
โ€ข PAC 
(Presentation-Abstraction-Control) 
โ€ข RMR 
(Resource-Method-Representation)
Entity-Boundary-Interactor 
At best, ADR maps only roughly to EBI: 
! 
- the ADR Action and Responder elements may represent a web-specific 
EBI Boundary 
! 
- the ADR Domain element may represent an EBI Interactor 
element, encapsulating or otherwise hiding the EBI Entity 
elements from the ADR Action. 
! 
Alternatively, in ports-and-adapters or hexagonal architecture 
terms, it may be reasonable to think of the Action as a "port" 
through which an EBI Boundary is invoked as part of the ADR 
Domain. Finally, the Responder could be seen as an "adapter" 
back through which the application data is returned.
Data-Context-Interaction 
DCI is described as a complement to MVC, not a replacement for 
MVC. I think it is fair to call it a complement to ADR as well.
Model-View-Presenter 
(Supervising Controller, Passive View) 
- Model and the Domain map closely, as they do in MVC. 
! 
- Passive View does not map well to either Action or Responder; it might 
better be regarded as the response that gets returned to the client. 
! 
- Supervising Controller might map to Responder, in that it "manipulate[s] the 
view to handle more complex view logic". However, Responder is not 
responsible for interacting with the Domain, and it does not receive the client 
input, so does not seem to be a good fit for Supervising Controller. 
! 
- Alternatively, Supervising Controller might map to Action, but the Action is not 
responsible for manipulating the view (i.e. the response).
Model-View-ViewModel 
Maps only incompletely to ADR. 
! 
- The Model in MVVM maps closely to the Model in MVC and the Domain 
in ADR. 
! 
- Similarly, the View in MVVM maps closely to the View in MVC and the 
Responder in ADR. 
! 
- However, the ViewModel does not map well to a Controller in MVC or an 
Action in ADR.
Presentation-Abstraction-Control 
PAC is used as a hierarchical structure of agents, each consisting of a triad of 
presentation, abstraction and control parts. 
! 
The agents (or triads) communicate with each other only through the control 
part of each triad. 
! 
It completely insulates the presentation (view in MVC) and the abstraction 
(model in MVC). 
! 
This provides the option to separately multithread the model and view which 
can give the user experience of very short program start times, as the user 
interface (presentation) can be shown before the abstraction has fully 
initialized.
Resource-Method-Representation 
Resource <--> Domain 
Method <--> Action 
Representation <--> Responder 
! 
โ€œA Resource can be thought of as an object with private variables and public methods that 
correspond to HTTP methods. From an MVC point of view, a resource can be thought of as a 
model with a bit of controller thrown in." -- Mixing of concerns. 
! 
"The Representation is like a view in MVC, we give it a resource object and tell it to serialize 
the data into it's output format." -- No allowance for other HTTP responses. 
! 
ADR might be considered an expanded or superset variation of RMR, one where a Resource 
and an action one can perform on it are cleanly separated into a Domain and an Action, and 
where the Representation (i.e., the building of the response) is handled by a Responder.
โ€œI Would Not Say Such Things If I Were You!โ€
Criticisms 
โ€ข Isnโ€™t that a lot of classes? 
โ€ข Where does โ€œfeatureโ€ go in ADR? 
โ€ข Can I use it with โ€œlanguageโ€ ? 
โ€ข Can I use it on the client? 
โ€ข Omission of Request 
โ€ข Omission of Front Controller 
โ€ข The examples are too limiting 
โ€ข Youโ€™re forgetting โ€œpatternโ€
โ€œYouโ€™d Make A Wonderful Dread Pirate Roberts.โ€
Conclusion 
โ€ข MVC originated for in-memory desktop user interfaces 
โ€ข Did not translate to the web so well 
โ€ข Explored ADR as a way to refine MVC specifically for the web 
โ€ข Code, commentary, and criticism around ADR
Thanks! 
โ€ข http://pmjones.github.io/adr (ADR Paper) 
โ€ข http://mlaphp.com/ (Modernizing Legacy Apps in PHP) 
โ€ข http://paul-m-jones.com/ and @pmjones

More Related Content

What's hot

Jsf2 overview
Jsf2 overviewJsf2 overview
Jsf2 overview
musaibasrar
ย 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina
ย 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdev
damianofusco
ย 

What's hot (20)

Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
ย 
Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
ย 
Jsf2 overview
Jsf2 overviewJsf2 overview
Jsf2 overview
ย 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
ย 
MSDN - ASP.NET MVC
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
ย 
ASP .NET MVC - best practices
ASP .NET MVC - best practicesASP .NET MVC - best practices
ASP .NET MVC - best practices
ย 
CQRS and what it means for your architecture
CQRS and what it means for your architectureCQRS and what it means for your architecture
CQRS and what it means for your architecture
ย 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
ย 
Fast Cordova applications
Fast Cordova applicationsFast Cordova applications
Fast Cordova applications
ย 
Architecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsArchitecting ASP.NET MVC Applications
Architecting ASP.NET MVC Applications
ย 
10 jsp-scripting-elements
10 jsp-scripting-elements10 jsp-scripting-elements
10 jsp-scripting-elements
ย 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
ย 
Hexagonal architecture - message-oriented software design
Hexagonal architecture  - message-oriented software designHexagonal architecture  - message-oriented software design
Hexagonal architecture - message-oriented software design
ย 
Refactoring to SOLID Code
Refactoring to SOLID CodeRefactoring to SOLID Code
Refactoring to SOLID Code
ย 
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
ย 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdev
ย 
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
ย 
1. Spring intro IoC
1. Spring intro IoC1. Spring intro IoC
1. Spring intro IoC
ย 
My XML is Alive! An Intro to XAML
My XML is Alive! An Intro to XAMLMy XML is Alive! An Intro to XAML
My XML is Alive! An Intro to XAML
ย 

Viewers also liked

All You Jokers
All You JokersAll You Jokers
All You Jokers
Paul Jones
ย 
How Do We Get The Deficit To Zero?
How Do We Get The Deficit To Zero?How Do We Get The Deficit To Zero?
How Do We Get The Deficit To Zero?
Paul Jones
ย 
Framework and Application Benchmarking
Framework and Application BenchmarkingFramework and Application Benchmarking
Framework and Application Benchmarking
Paul Jones
ย 
Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHP
Paul Jones
ย 
Career and Life Management
Career and Life ManagementCareer and Life Management
Career and Life Management
Paul Jones
ย 
Smalltalk In a Nutshell
Smalltalk In a NutshellSmalltalk In a Nutshell
Smalltalk In a Nutshell
Michele Lanza
ย 

Viewers also liked (20)

Action Domain Response
Action Domain ResponseAction Domain Response
Action Domain Response
ย 
Action-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVCAction-Domain-Responder: A Refinement of MVC
Action-Domain-Responder: A Refinement of MVC
ย 
Driving Design with PhpSpec
Driving Design with PhpSpecDriving Design with PhpSpec
Driving Design with PhpSpec
ย 
Same Thing Happens Every Time
Same Thing Happens Every TimeSame Thing Happens Every Time
Same Thing Happens Every Time
ย 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)
ย 
All You Jokers
All You JokersAll You Jokers
All You Jokers
ย 
How Do We Get The Deficit To Zero?
How Do We Get The Deficit To Zero?How Do We Get The Deficit To Zero?
How Do We Get The Deficit To Zero?
ย 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
ย 
Framework and Application Benchmarking
Framework and Application BenchmarkingFramework and Application Benchmarking
Framework and Application Benchmarking
ย 
PHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better CodePHP: 4 Design Patterns to Make Better Code
PHP: 4 Design Patterns to Make Better Code
ย 
Decoupled Libraries for PHP
Decoupled Libraries for PHPDecoupled Libraries for PHP
Decoupled Libraries for PHP
ย 
How To Train Your Manager
How To Train Your ManagerHow To Train Your Manager
How To Train Your Manager
ย 
Web Development with Smalltalk
Web Development with SmalltalkWeb Development with Smalltalk
Web Development with Smalltalk
ย 
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
ย 
Career and Life Management
Career and Life ManagementCareer and Life Management
Career and Life Management
ย 
Smalltalk In a Nutshell
Smalltalk In a NutshellSmalltalk In a Nutshell
Smalltalk In a Nutshell
ย 
Architektura heksagonalna
Architektura heksagonalnaArchitektura heksagonalna
Architektura heksagonalna
ย 
JWT - To authentication and beyond!
JWT - To authentication and beyond!JWT - To authentication and beyond!
JWT - To authentication and beyond!
ย 
JavaCro'14 - Vaadin web application integration for Enterprise systems โ€“ Pete...
JavaCro'14 - Vaadin web application integration for Enterprise systems โ€“ Pete...JavaCro'14 - Vaadin web application integration for Enterprise systems โ€“ Pete...
JavaCro'14 - Vaadin web application integration for Enterprise systems โ€“ Pete...
ย 
Ten Reasons Why You Should Prefer PostgreSQL to MySQL
Ten Reasons Why You Should Prefer PostgreSQL to MySQLTen Reasons Why You Should Prefer PostgreSQL to MySQL
Ten Reasons Why You Should Prefer PostgreSQL to MySQL
ย 

Similar to Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller

MVC Framework
MVC FrameworkMVC Framework
MVC Framework
Ashton Feller
ย 
Cs 1023 lec 2 (week 1) edit 1
Cs 1023  lec 2 (week 1) edit 1Cs 1023  lec 2 (week 1) edit 1
Cs 1023 lec 2 (week 1) edit 1
stanbridge
ย 
Cs 1023 lec 2 (week 1) edit 1
Cs 1023  lec 2 (week 1) edit 1Cs 1023  lec 2 (week 1) edit 1
Cs 1023 lec 2 (week 1) edit 1
stanbridge
ย 
Lecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdfLecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdf
Lรช ThฦฐแปŸng
ย 

Similar to Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller (20)

Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
ย 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
ย 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
ย 
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
ย 
J2EE pattern 5
J2EE pattern 5J2EE pattern 5
J2EE pattern 5
ย 
Asp 1-mvc introduction
Asp 1-mvc introductionAsp 1-mvc introduction
Asp 1-mvc introduction
ย 
MVC architecture by Mohd.Awais on 18th Aug, 2017
MVC architecture by Mohd.Awais on 18th Aug, 2017MVC architecture by Mohd.Awais on 18th Aug, 2017
MVC architecture by Mohd.Awais on 18th Aug, 2017
ย 
Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9
ย 
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
MSc Enterprise Systems Development Guest Lecture at UniS (2/12/09)
ย 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
ย 
Spring MVC framework features and concepts
Spring MVC framework features and conceptsSpring MVC framework features and concepts
Spring MVC framework features and concepts
ย 
RubyConf Bangladesh 2017 - Rails buggy code
RubyConf Bangladesh 2017 - Rails buggy codeRubyConf Bangladesh 2017 - Rails buggy code
RubyConf Bangladesh 2017 - Rails buggy code
ย 
Mcv design patterns
Mcv design patternsMcv design patterns
Mcv design patterns
ย 
Cs 1023 lec 2 (week 1) edit 1
Cs 1023  lec 2 (week 1) edit 1Cs 1023  lec 2 (week 1) edit 1
Cs 1023 lec 2 (week 1) edit 1
ย 
Cs 1023 lec 2 (week 1) edit 1
Cs 1023  lec 2 (week 1) edit 1Cs 1023  lec 2 (week 1) edit 1
Cs 1023 lec 2 (week 1) edit 1
ย 
Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014
ย 
Lecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdfLecture 05 - Creating a website with Razor Pages.pdf
Lecture 05 - Creating a website with Razor Pages.pdf
ย 
Spring mvc
Spring mvcSpring mvc
Spring mvc
ย 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
ย 
Sitecore mvc
Sitecore mvcSitecore mvc
Sitecore mvc
ย 

Recently uploaded

VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
SUHANI PANDEY
ย 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
singhpriety023
ย 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
SUHANI PANDEY
ย 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
SUHANI PANDEY
ย 
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRLLucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
imonikaupta
ย 
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
SUHANI PANDEY
ย 
โ‚น5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] ๐Ÿ”|97111...
โ‚น5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] ๐Ÿ”|97111...โ‚น5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] ๐Ÿ”|97111...
โ‚น5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] ๐Ÿ”|97111...
Diya Sharma
ย 

Recently uploaded (20)

VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
ย 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
ย 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
ย 
Enjoy NightโšกCall Girls Dlf City Phase 3 Gurgaon >เผ’8448380779 Escort Service
Enjoy NightโšกCall Girls Dlf City Phase 3 Gurgaon >เผ’8448380779 Escort ServiceEnjoy NightโšกCall Girls Dlf City Phase 3 Gurgaon >เผ’8448380779 Escort Service
Enjoy NightโšกCall Girls Dlf City Phase 3 Gurgaon >เผ’8448380779 Escort Service
ย 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
ย 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
ย 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
ย 
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...
VVVIP Call Girls In Connaught Place โžก๏ธ Delhi โžก๏ธ 9999965857 ๐Ÿš€ No Advance 24HRS...
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
ย 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
ย 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
ย 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
ย 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
ย 
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRLLucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
Lucknow โคCALL GIRL 88759*99948 โคCALL GIRLS IN Lucknow ESCORT SERVICEโคCALL GIRL
ย 
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
Yerawada ] Independent Escorts in Pune - Book 8005736733 Call Girls Available...
ย 
โ‚น5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] ๐Ÿ”|97111...
โ‚น5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] ๐Ÿ”|97111...โ‚น5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] ๐Ÿ”|97111...
โ‚น5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] ๐Ÿ”|97111...
ย 
Call Now โ˜Ž 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now โ˜Ž 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now โ˜Ž 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
ย 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
ย 

Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller

  • 1. Action-Domain-Responder A Web-Specific Refinement Of Model-View-Controller ! CoderFaire 2014 @pmjones ! http://pmjones.github.io/adr
  • 3. About Me โ€ข 8 years USAF Intelligence โ€ข BASIC in 1983, PHP since 1999 โ€ข Jr. Developer, VP Engineering โ€ข Aura project, Zend_DB, Zend_View โ€ข PHP-FIG, PSR-1, PSR-2, PSR-4 โ€ข MLAPHP (http://mlaphp.com) โ€ข Super-Secret Startup (Tandum)
  • 4. Overview โ€ข How we think of MVC versus its desktop origins โ€ข How ADR refines โ€œMVCโ€ for the web โ€ข How ADR relates to existing โ€œMVCโ€ alternatives โ€ข Address ADR comments and questions
  • 5. โ€œYou Keep Using That Word โ€ฆโ€
  • 6. Server-Side MVC โ€ข From all concerns combined (ball of mud) โ€ฆ โ€ข โ€ฆ to separation of concerns (input, business logic, presentation) โ€ข Oriented around HTTP (stateless shared-nothing request/response) โ€ข Google for โ€œmvc in (php | python | rails)โ€ โ€ข General consensus on components, not so much on collaborations
  • 7. Server-Side MVC Collaborations โ€ข User Agent sends a Request โ€ข Router/Dispatcher invokes Controller โ€ข Controller manages flow, invokes Model(s) that encapsulate domain โ€ข Controller assigns values to View template โ€ข Controller invokes View and sets into Response (with headers)
  • 8. โ€œโ€ฆ I Do Not Think It Means What You Think It Means.โ€
  • 9. Smalltalk-80 MVC โ€ข Desktop graphical UI pattern โ€ข Separation of concerns (input management, internal representation of domain, presentation to user) โ€ข Interactive event-driven desktop (keyboard/mouse, in-memory) โ€ข Google for โ€œsmalltalk mvcโ€
  • 10. Smalltalk-80 MVC Collaborations โ€ข Controller receives keyboard/mouse input events from User โ€ข Controller notifies View and Model, respectively โ€ข View and Model notify each other for updates โ€ข View updates are rendered on the screen โ€ข Hierarchical collection of interrelated MVC triads for each screen element
  • 11. The Pit Web Of Despair
  • 12. How To Describe Web UI Patterns? โ€ข Model 1: Sun JSP for page scripting (ball of mud) โ€ข Model 2 : Servlet for action (Controller) and JSP for template (View)
  • 13. The Names Are The Same, But The Game Has Changed โ€ข Used the name MVC for Model 2 โ€ข Subverted the collaborations โ€ข From event-driven to request/response (pages) โ€ข No more messaging interactions between triads โ€ข One collected set of interactions delivered
  • 14. Are These The Same?
  • 15. โ€œDear God, What Is That Thing?โ€ โ€ข The pattern name โ€œModel-View-Controllerโ€ has several meanings โ€ข Hard to determine exactly what collaborations to expect โ€ข Smalltalk-80 MVC relates more closely to client-side โ€ข Model 2 MVC relates more closely to server-side โ€ข Even more semantic diffusion since 2000: โ€ข https://www.google.com/search?q=mvc+diagram
  • 16. Youโ€™re Trying To Kidnap What Iโ€™ve Rightfully Stolen
  • 17. Toward A Web-Specific UI Pattern โ€ข Stop using in-memory desktop GUI patterns as server patterns โ€ข Entirely new name to break the association with โ€œMVCโ€ โ€ข Remember we are in a client/server (request/response) environment โ€ข Use existing server-side โ€œMVCโ€ as a basis โ€ข Refine the components and collaborations toward better practices
  • 18. Refining the โ€œModelโ€ to โ€œDomainโ€ โ€ข The โ€œDomainโ€ has essentially identical responsibilities โ€ข Reminiscent of โ€œDomain Logicโ€ and โ€œDomain Driven Designโ€ โ€ข TransactionScript, DomainModel, TableModule, ServiceLayer โ€ข (ActiveRecord is a โ€œData Sourceโ€ pattern)
  • 19. Refining the โ€œViewโ€ to โ€œResponderโ€ โ€ข Usually think of a View system as templates (screen elements) โ€ข Client receives HTTP response of both body and headers โ€ข This means the View in server-based MVC is not the template โ€ข The View in server-based MVC is the Response
  • 20. Intermingled Presentation Logic โ€ข Template Views generally build HTTP body values โ€ข Remaining Controller logic manipulates HTTP header values โ€ข Presentation logic is mixed between Views and Controllers โ€ข Need a layer that is completely in charge of building the Response
  • 21. โ€œResponderโ€ For Presentation โ€ข Responder layer handles setting headers, status, etc โ€ข Additionally uses templates for setting body content โ€ข Invoke a Responder for presentation of Response
  • 22. Using Responders In Controllers โ€ข Remove Response presentation from all Controller action methods โ€ข index(), create(), read(), update(), delete() โ€ข Each action method has its own set of status codes and templates
  • 23. One Responder Per Controller? โ€ข One Responder per Controller to cover all possible action methods? โ€ข No: inject one Responder per action method โ€ข But: injecting Responders that might not be needed
  • 24. Refining the โ€œControllerโ€ To โ€œActionโ€ โ€ข Instead of a Controller with index(), create(), read(), etc. โ€ฆ โ€ข โ€ฆ one class per Action: IndexAction, CreateAction, ReadAction, etc. โ€ข Inject the individual Responder into the individual Action
  • 25. โ€œLet me explain. No, there is too much. Let me sum up.โ€
  • 26. Components โ€ข Domain is the logic to manipulate the domain, session, application, and environment data, modifying state and persistence as needed. โ€ข Responder is the logic to build an HTTP response or response description. It deals with body content, templates and views, headers and cookies, status codes, and so on. โ€ข Action is the logic that connects the Domain and Responder. It uses the request input to interact with the Domain, and passes the Domain output to the Responder.
  • 27. Collaborations โ€ข Action feeds input from HTTP request to a Domain layer โ€ข Action feeds output from Domain layer to a Responder โ€ข Responder builds the HTTP response headers and body Controller Model View Action Domain Responder
  • 29. About The Examples โ€ข Overly-simplified to highlight components and collaborations โ€ข Action is minimalist, almost trivial (micro-framework-ish) โ€ข Domain becomes much more robust โ€ข Responder has to determine presentation based on Domain values
  • 30. โ€œIโ€™m Not The Real Dread Pirate Roberts.โ€
  • 31. Is ADR Just Another Pattern โ€œIn Dragโ€? โ€ข EBI (Entity-Boundary-Interactor) โ€ข DCI (Data-Context-Interaction) โ€ข MVP (Model-View-Presenter) โ€ข MVVM (Model-View-ViewModel) โ€ข PAC (Presentation-Abstraction-Control) โ€ข RMR (Resource-Method-Representation)
  • 32. Entity-Boundary-Interactor At best, ADR maps only roughly to EBI: ! - the ADR Action and Responder elements may represent a web-specific EBI Boundary ! - the ADR Domain element may represent an EBI Interactor element, encapsulating or otherwise hiding the EBI Entity elements from the ADR Action. ! Alternatively, in ports-and-adapters or hexagonal architecture terms, it may be reasonable to think of the Action as a "port" through which an EBI Boundary is invoked as part of the ADR Domain. Finally, the Responder could be seen as an "adapter" back through which the application data is returned.
  • 33. Data-Context-Interaction DCI is described as a complement to MVC, not a replacement for MVC. I think it is fair to call it a complement to ADR as well.
  • 34. Model-View-Presenter (Supervising Controller, Passive View) - Model and the Domain map closely, as they do in MVC. ! - Passive View does not map well to either Action or Responder; it might better be regarded as the response that gets returned to the client. ! - Supervising Controller might map to Responder, in that it "manipulate[s] the view to handle more complex view logic". However, Responder is not responsible for interacting with the Domain, and it does not receive the client input, so does not seem to be a good fit for Supervising Controller. ! - Alternatively, Supervising Controller might map to Action, but the Action is not responsible for manipulating the view (i.e. the response).
  • 35. Model-View-ViewModel Maps only incompletely to ADR. ! - The Model in MVVM maps closely to the Model in MVC and the Domain in ADR. ! - Similarly, the View in MVVM maps closely to the View in MVC and the Responder in ADR. ! - However, the ViewModel does not map well to a Controller in MVC or an Action in ADR.
  • 36. Presentation-Abstraction-Control PAC is used as a hierarchical structure of agents, each consisting of a triad of presentation, abstraction and control parts. ! The agents (or triads) communicate with each other only through the control part of each triad. ! It completely insulates the presentation (view in MVC) and the abstraction (model in MVC). ! This provides the option to separately multithread the model and view which can give the user experience of very short program start times, as the user interface (presentation) can be shown before the abstraction has fully initialized.
  • 37. Resource-Method-Representation Resource <--> Domain Method <--> Action Representation <--> Responder ! โ€œA Resource can be thought of as an object with private variables and public methods that correspond to HTTP methods. From an MVC point of view, a resource can be thought of as a model with a bit of controller thrown in." -- Mixing of concerns. ! "The Representation is like a view in MVC, we give it a resource object and tell it to serialize the data into it's output format." -- No allowance for other HTTP responses. ! ADR might be considered an expanded or superset variation of RMR, one where a Resource and an action one can perform on it are cleanly separated into a Domain and an Action, and where the Representation (i.e., the building of the response) is handled by a Responder.
  • 38. โ€œI Would Not Say Such Things If I Were You!โ€
  • 39. Criticisms โ€ข Isnโ€™t that a lot of classes? โ€ข Where does โ€œfeatureโ€ go in ADR? โ€ข Can I use it with โ€œlanguageโ€ ? โ€ข Can I use it on the client? โ€ข Omission of Request โ€ข Omission of Front Controller โ€ข The examples are too limiting โ€ข Youโ€™re forgetting โ€œpatternโ€
  • 40. โ€œYouโ€™d Make A Wonderful Dread Pirate Roberts.โ€
  • 41. Conclusion โ€ข MVC originated for in-memory desktop user interfaces โ€ข Did not translate to the web so well โ€ข Explored ADR as a way to refine MVC specifically for the web โ€ข Code, commentary, and criticism around ADR
  • 42. Thanks! โ€ข http://pmjones.github.io/adr (ADR Paper) โ€ข http://mlaphp.com/ (Modernizing Legacy Apps in PHP) โ€ข http://paul-m-jones.com/ and @pmjones