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

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

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

一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
F
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理
F
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
ydyuyu
 
一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理
F
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
ayvbos
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 
一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
F
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Monica Sydney
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Monica Sydney
 

Recently uploaded (20)

Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理一比一原版奥兹学院毕业证如何办理
一比一原版奥兹学院毕业证如何办理
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理一比一原版犹他大学毕业证如何办理
一比一原版犹他大学毕业证如何办理
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理一比一原版帝国理工学院毕业证如何办理
一比一原版帝国理工学院毕业证如何办理
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书一比一原版贝德福特大学毕业证学位证书
一比一原版贝德福特大学毕业证学位证书
 
Call girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girlsCall girls Service in Ajman 0505086370 Ajman call girls
Call girls Service in Ajman 0505086370 Ajman call girls
 
PIC Microcontroller Structure & Assembly Language.ppsx
PIC Microcontroller Structure & Assembly Language.ppsxPIC Microcontroller Structure & Assembly Language.ppsx
PIC Microcontroller Structure & Assembly Language.ppsx
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
South Bopal [ (Call Girls) in Ahmedabad ₹7.5k Pick Up & Drop With Cash Paymen...
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 

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