SlideShare a Scribd company logo
1 of 27
Download to read offline
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?

More Related Content

Viewers also liked

[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
 

Viewers also liked (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
 

More from 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
 

More from 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
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
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
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
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
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.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
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
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
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

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...