SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
over
presentation

                                http
    business
     logic




problem 1:
presentation depends on the interaction
flow, and mobile flows are really
different
presentation



                                http
   business
    logic




                 presentation



                                http

problem 2:
conversation state shared between client
and server. conversation state on
server leads to “session abuse”
presentation



                                http
   business
    logic




                 presentation



                                http

problem 2:
conversation state shared between client
and server. conversation state on
server leads to “session abuse”
presentation



                                http
   business
    logic




                 presentation



                                http

problem 2:
conversation state shared between client
and server. conversation state on
server leads to “session abuse”
n
                                         io



                 presentation
                                       t



                                http
                                       a
                                      s e
   business
    logic                            r t
                                    e a
                                   v t
                 presentation
                                  n s

                                http
                 c              o

problem 2:
conversation state shared between client
and server. conversation state on
server leads to “session abuse”
n
                                          io



                  presentation
                                        t



                                 http
                                        a
ap                                     s e
  pl business
      logic
     ic                               r t
                                     e a
 st at
                                    v t
                  presentation
   at io                           n s

                                 http
       e n
                  c              o

problem 2:
 conversation state shared between client
 and server. conversation state on
 server leads to “session abuse”
n
                                                                io



                                        presentation
                                                              t



                                                       http
                                                              a
ap                                                           s e
  pl business
                                                            r t
                  presentation



                                 http




       business
        logic
                  presentation



                                 http




                                                           e a
      logic
     ic
 st at
                                                          v t
                                        presentation
   at io                                                 n s

                                                       http
       e n
                                        c              o

problem 2: (sessions)
 could make horizontal scalability harder
 than it should be
n
                                           io



                   presentation
                                         t



                                  http
                                         a
ap                                      s e
  pl business
      logic
     ic                                r t
                                      e a
 st at
                                     v t
                   presentation
   at io                            n s

                                  http
       e n
                  c               o

problem 2: (sessions)
 it’s very hard to migrate conversations
 from agents (mobile <-> desktop)
logic
                                                                 business



                                                   business                  business
                                                    logic                     logic
                                                    usage                     usage


                                                  presentation              presentation




                                     problem 3:
                                                    http                      http




business logic usage is duplicated
business
                                                                        logic




                                            problem 3:
                                                              business              business
                                                               logic                 logic




                                            (duplication)
                                                               usage                 usage


                                                            presentation          presentation


                                                                http                  http
worst when there’s an anemic domain model
presentation




               presentation



                              http
  business
   logic
                                                    presentation




               presentation



                              http




problem 4: rich client
more duplication (different languages),
more difficult to separate
responsibilities (where is what?)
presentation
              business




                                        http
               usage
               logic
 business
  logic




                         presentation
              business




                                        http
               usage
               logic




problem 5: (testability)
difficult to reach a particular point in
the conversation. presentation changes
often (smell: divergent change)
presentation




 business
  logic

            http
                                  presentation




adopted solution
SmartphoneClient.prototype.next = function() {
  var self = this
  this.seq(
     this.purchase,
     this.transferIn,
     this.optIn,
     this.waitForCompletion
  ).exit(function(exit) {
     exit.callHandler(self.callbacks)
  })
}

                        var client = new SmartphoneClient(server, {
                           onError: function(error) {
                              app.pages.notify.error(error)
                           },
                           onRoute: function(route) {
                              app.goTo(route)
                           },
                           onUrl: function(url) {
                              location.href = url
                           }
                        })
presentation




business
 logic

           http
                                 presentation




  clear separation
from application and
 conversation state
presentation




    business
     logic

               http
                                     presentation




  stateless: easy to scale
horizontally, conversations
  can be migrated/resumed
$app->post("/purchase/:id/transfer-in/opt-in/pin",
    function($purchaseId) use($app) {
        ContentDelivery::on($app)
            ->process(function($request, $response) use($purchaseId, $app) {
                $purchase = Purchase::fromRequest($request, $purchaseId);
                $transferIn = $purchase->boundedTransferIn("pin-flow");
                $transferIn->checkPin($request->params("pin"));

                $response->status(200);
            })
            ->rescue('OnebipCoreNotSupportedActionInState', 409)
            ->rescue('OnebipPurchasePurchaseNotFound', 404)
            ->rescue('OnebipPurchaseTransferInNotFound', 404)
            ->rescue('OnebipPurchaseSpendingLimitReached', 403)
            ->rescue('OnebipPurchaseCheckPinFailed', 400)
            ->rescue('HttpUnauthenticatedRequest', 401)
            ->deliver();
     }
);


                         look, no session,
                        and the controller
                        code is really small
presentation




   business
    logic

              http
                                    presentation




clear application interface
$app->map("/purchases", ...
$app->get("/purchase/:id", ...
$app->post("/purchase/:id/login", ...
$app->get("/purchase/:id/buyer", ...
$app->post("/purchase/:id/transfers-in", ...
$app->get("/purchase/:id/transfer-in", ...
$app->put("/purchase/:id/transfer-in", ...
$app->post("/purchase/:id/transfer-in/opt-in/pin", ...
$app->put("/purchase/:id/transfer-in/mo", ...




                      clear application
                          interface
presentation




business
 logic

           http
                                     presentation




                  testable
public function testShouldLoginWithARegisteredMsisdn()
{
    $self = $this;
    $msisdn = Baker::bake("Msisdn", "registered");
    $purchase = Baker::bake("Purchase", "from Country", $msisdn->country());

    $insertByUser = $msisdn->withoutNationalPrefixAsString();
    $this->request("POST", "/purchase/{$purchase->id()}/login")
        ->withBody(array("msisdn" => $insertByUser))
        ->run(function($response) use ($self) {
            $self->assertEquals(201, $response->status());
        });
}




                          testable
business
     logic

               http
                              presentation




    what
   about              presentation




old phones?
business




now
                  logic

                   http




                                     presentation


                                        http




  presentation
                      presentation
namespace HttpFeaturePhone
{
    class Client
    {
        public function next()
        {
            try {
                 $this->purchase();
                 $this->transferIn();
                 $this->optIn();
                 $this->waitForCompletion();
            } catch (ClientExit $exit) {
                 $exit->callHandler($this->callbacks);
            } catch (Exception $e) {
                 $exit = new ClientExit("error", $e->getMessage());
                 $exit->callHandler($this->callbacks);
            }
        }
        ...
    }
}                                   $client = new HttpFeaturePhoneClient($server, array(
                                       "onError" => function($error) use ($app) {
                                           $app->flash($error);
                                           $app->redirectTo($app->urlFor("error-ui"));
                                       },
                                       "onRoute" => function($route) use ($app) {
                                           $app->renderOrRedirectTo($route);
                                       },
                                       "onUrl" => function($url) use ($app) {
                                           $app->redirectTo($url);
                                       }
                                 ));
presentation


                                    http
   business
    logic

              http
                                                   presentation




                                           presentation




tomorrow...
questions?

Más contenido relacionado

Destacado

[Java] Khái niệm về RMI trong Java và cách sử dụng RMI
[Java] Khái niệm về RMI trong Java và cách sử dụng RMI[Java] Khái niệm về RMI trong Java và cách sử dụng RMI
[Java] Khái niệm về RMI trong Java và cách sử dụng RMITí Bụng Bự
 
Minimum Viable Product
Minimum Viable ProductMinimum Viable Product
Minimum Viable ProductGabriele Lana
 
Resource Oriented Design
Resource Oriented DesignResource Oriented Design
Resource Oriented DesignGabriele Lana
 
Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?Tushar Sharma
 
Professional Programmer
Professional ProgrammerProfessional Programmer
Professional ProgrammerGabriele Lana
 
Milano Legacy Coderetreat 2013
Milano Legacy Coderetreat 2013Milano Legacy Coderetreat 2013
Milano Legacy Coderetreat 2013Gabriele Lana
 
Agileday Coderetreat 2013
Agileday Coderetreat 2013Agileday Coderetreat 2013
Agileday Coderetreat 2013Gabriele Lana
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to NodejsGabriele Lana
 
It is not supposed to fly but it does
It is not supposed to fly but it doesIt is not supposed to fly but it does
It is not supposed to fly but it doesGabriele Lana
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with ExamplesGabriele Lana
 

Destacado (18)

[Java] Khái niệm về RMI trong Java và cách sử dụng RMI
[Java] Khái niệm về RMI trong Java và cách sử dụng RMI[Java] Khái niệm về RMI trong Java và cách sử dụng RMI
[Java] Khái niệm về RMI trong Java và cách sử dụng RMI
 
Minimum Viable Product
Minimum Viable ProductMinimum Viable Product
Minimum Viable Product
 
Magic of Ruby
Magic of RubyMagic of Ruby
Magic of Ruby
 
Why couchdb is cool
Why couchdb is coolWhy couchdb is cool
Why couchdb is cool
 
Nosql
NosqlNosql
Nosql
 
Resource Oriented Design
Resource Oriented DesignResource Oriented Design
Resource Oriented Design
 
MongoDB With Style
MongoDB With StyleMongoDB With Style
MongoDB With Style
 
Does your configuration code smell?
Does your configuration code smell?Does your configuration code smell?
Does your configuration code smell?
 
Beyond Phoenix
Beyond PhoenixBeyond Phoenix
Beyond Phoenix
 
Professional Programmer
Professional ProgrammerProfessional Programmer
Professional Programmer
 
Milano Legacy Coderetreat 2013
Milano Legacy Coderetreat 2013Milano Legacy Coderetreat 2013
Milano Legacy Coderetreat 2013
 
Agileday Coderetreat 2013
Agileday Coderetreat 2013Agileday Coderetreat 2013
Agileday Coderetreat 2013
 
coderetreat
coderetreatcoderetreat
coderetreat
 
CouchDB Vs MongoDB
CouchDB Vs MongoDBCouchDB Vs MongoDB
CouchDB Vs MongoDB
 
Introduction to Nodejs
Introduction to NodejsIntroduction to Nodejs
Introduction to Nodejs
 
It is not supposed to fly but it does
It is not supposed to fly but it doesIt is not supposed to fly but it does
It is not supposed to fly but it does
 
Nodejs Explained with Examples
Nodejs Explained with ExamplesNodejs Explained with Examples
Nodejs Explained with Examples
 
Denial Of Service Attack
Denial Of Service AttackDenial Of Service Attack
Denial Of Service Attack
 

Más de Gabriele Lana

Microservice Architectures
Microservice ArchitecturesMicroservice Architectures
Microservice ArchitecturesGabriele Lana
 
Professional Programmer 2018
Professional Programmer 2018Professional Programmer 2018
Professional Programmer 2018Gabriele Lana
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartGabriele Lana
 
Erlang: the language and the platform
Erlang: the language and the platformErlang: the language and the platform
Erlang: the language and the platformGabriele Lana
 
Resource Oriented Architectures
Resource Oriented ArchitecturesResource Oriented Architectures
Resource Oriented ArchitecturesGabriele Lana
 
Sustainable Agile Development
Sustainable Agile DevelopmentSustainable Agile Development
Sustainable Agile DevelopmentGabriele Lana
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to ErlangGabriele Lana
 

Más de Gabriele Lana (8)

Microservice Architectures
Microservice ArchitecturesMicroservice Architectures
Microservice Architectures
 
Professional Programmer 2018
Professional Programmer 2018Professional Programmer 2018
Professional Programmer 2018
 
ProgrammingKatas
ProgrammingKatasProgrammingKatas
ProgrammingKatas
 
Refactoring In Tdd The Missing Part
Refactoring In Tdd The Missing PartRefactoring In Tdd The Missing Part
Refactoring In Tdd The Missing Part
 
Erlang: the language and the platform
Erlang: the language and the platformErlang: the language and the platform
Erlang: the language and the platform
 
Resource Oriented Architectures
Resource Oriented ArchitecturesResource Oriented Architectures
Resource Oriented Architectures
 
Sustainable Agile Development
Sustainable Agile DevelopmentSustainable Agile Development
Sustainable Agile Development
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 

Último

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Último (20)

Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Stateless conversation architecture for mobile applications

  • 2. presentation http business logic problem 1: presentation depends on the interaction flow, and mobile flows are really different
  • 3. presentation http business logic presentation http problem 2: conversation state shared between client and server. conversation state on server leads to “session abuse”
  • 4. presentation http business logic presentation http problem 2: conversation state shared between client and server. conversation state on server leads to “session abuse”
  • 5. presentation http business logic presentation http problem 2: conversation state shared between client and server. conversation state on server leads to “session abuse”
  • 6. n io presentation t http a s e business logic r t e a v t presentation n s http c o problem 2: conversation state shared between client and server. conversation state on server leads to “session abuse”
  • 7. n io presentation t http a ap s e pl business logic ic r t e a st at v t presentation at io n s http e n c o problem 2: conversation state shared between client and server. conversation state on server leads to “session abuse”
  • 8. n io presentation t http a ap s e pl business r t presentation http business logic presentation http e a logic ic st at v t presentation at io n s http e n c o problem 2: (sessions) could make horizontal scalability harder than it should be
  • 9. n io presentation t http a ap s e pl business logic ic r t e a st at v t presentation at io n s http e n c o problem 2: (sessions) it’s very hard to migrate conversations from agents (mobile <-> desktop)
  • 10. logic business business business logic logic usage usage presentation presentation problem 3: http http business logic usage is duplicated
  • 11. business logic problem 3: business business logic logic (duplication) usage usage presentation presentation http http worst when there’s an anemic domain model
  • 12. presentation presentation http business logic presentation presentation http problem 4: rich client more duplication (different languages), more difficult to separate responsibilities (where is what?)
  • 13. presentation business http usage logic business logic presentation business http usage logic problem 5: (testability) difficult to reach a particular point in the conversation. presentation changes often (smell: divergent change)
  • 14. presentation business logic http presentation adopted solution
  • 15. SmartphoneClient.prototype.next = function() { var self = this this.seq( this.purchase, this.transferIn, this.optIn, this.waitForCompletion ).exit(function(exit) { exit.callHandler(self.callbacks) }) } var client = new SmartphoneClient(server, { onError: function(error) { app.pages.notify.error(error) }, onRoute: function(route) { app.goTo(route) }, onUrl: function(url) { location.href = url } })
  • 16. presentation business logic http presentation clear separation from application and conversation state
  • 17. presentation business logic http presentation stateless: easy to scale horizontally, conversations can be migrated/resumed
  • 18. $app->post("/purchase/:id/transfer-in/opt-in/pin", function($purchaseId) use($app) { ContentDelivery::on($app) ->process(function($request, $response) use($purchaseId, $app) { $purchase = Purchase::fromRequest($request, $purchaseId); $transferIn = $purchase->boundedTransferIn("pin-flow"); $transferIn->checkPin($request->params("pin")); $response->status(200); }) ->rescue('OnebipCoreNotSupportedActionInState', 409) ->rescue('OnebipPurchasePurchaseNotFound', 404) ->rescue('OnebipPurchaseTransferInNotFound', 404) ->rescue('OnebipPurchaseSpendingLimitReached', 403) ->rescue('OnebipPurchaseCheckPinFailed', 400) ->rescue('HttpUnauthenticatedRequest', 401) ->deliver(); } ); look, no session, and the controller code is really small
  • 19. presentation business logic http presentation clear application interface
  • 20. $app->map("/purchases", ... $app->get("/purchase/:id", ... $app->post("/purchase/:id/login", ... $app->get("/purchase/:id/buyer", ... $app->post("/purchase/:id/transfers-in", ... $app->get("/purchase/:id/transfer-in", ... $app->put("/purchase/:id/transfer-in", ... $app->post("/purchase/:id/transfer-in/opt-in/pin", ... $app->put("/purchase/:id/transfer-in/mo", ... clear application interface
  • 21. presentation business logic http presentation testable
  • 22. public function testShouldLoginWithARegisteredMsisdn() { $self = $this; $msisdn = Baker::bake("Msisdn", "registered"); $purchase = Baker::bake("Purchase", "from Country", $msisdn->country()); $insertByUser = $msisdn->withoutNationalPrefixAsString(); $this->request("POST", "/purchase/{$purchase->id()}/login") ->withBody(array("msisdn" => $insertByUser)) ->run(function($response) use ($self) { $self->assertEquals(201, $response->status()); }); } testable
  • 23. business logic http presentation what about presentation old phones?
  • 24. business now logic http presentation http presentation presentation
  • 25. namespace HttpFeaturePhone { class Client { public function next() { try { $this->purchase(); $this->transferIn(); $this->optIn(); $this->waitForCompletion(); } catch (ClientExit $exit) { $exit->callHandler($this->callbacks); } catch (Exception $e) { $exit = new ClientExit("error", $e->getMessage()); $exit->callHandler($this->callbacks); } } ... } } $client = new HttpFeaturePhoneClient($server, array( "onError" => function($error) use ($app) { $app->flash($error); $app->redirectTo($app->urlFor("error-ui")); }, "onRoute" => function($route) use ($app) { $app->renderOrRedirectTo($route); }, "onUrl" => function($url) use ($app) { $app->redirectTo($url); } ));
  • 26. presentation http business logic http presentation presentation tomorrow...