SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
Yet Another Building Metaphor
      factor10.com :: @aslamkhn :: aslamkhan.net
Aslam Khan
mail at aslam.khan@factor10.com


 blog at http://aslamkhan.net

      tweet at @aslamkhn

       skype at aslmkhn
One of the first games that I wrote



     10   I = INT(10 * RND(1))
     20   PRINT “GUESS MY NUMBER:”
     30   INPUT J
     40   IF INT(J) != I THEN GOTO 20
     50   PRINT “YOU GOT IT!”
     60   PRINT “PLAY AGAIN (Y/N)?”
     70   INPUT Y
     80   IF Y == ‘Y’ THEN GOTO 10
     90   PRINT “THANKS FOR PLAYING”
It looks The JS version
           better with whitespace


do {
   var i = Math.floor(Math.random()*11);
   do {
         var j = prompt(“Guess my number”);
      } while (i != j);
   alert(“You got it!);
   y = confirm(“Play again?”);
} while (y);
alert(“Thanks for playing”);
It reads better with whitespace

do {
   var i = Math.floor(Math.random()*11);
   do {
         var j = prompt(“Guess my number”);
      } while (i != j);

   alert(“You got it!);

   y = confirm(“Play again?”);
} while (y);
alert(“Thanks for playing”);
What else can we do about it?

do {
   var i = Math.floor(Math.random()*11);
   do {
         var j = prompt(“Guess my number”);
      } while (i != j);

   alert(“You got it!);

   y = confirm(“Play again?”);
} while (y);
alert(“Thanks for playing”);
It reads better with nicer names

do {
  var mystery_number = Math.floor(Math.random()*11);
  do {
     var guessed_number = prompt(“Guess my number”);
  } while (guessed_number != mystery_number);

  alert(“You got it!);

   var play_again = confirm(“Play again?”);
} while (play_again);

alert(“Thanks for playing”);
Can we do better than renaming?

do {
  var mystery_number = Math.floor(Math.random()*11);
  do {
     var guessed_number = prompt(“Guess my number”);
  } while (guessed_number != mystery_number);

  alert(“You got it!);

   var play_again = confirm(“Play again?”);
} while (play_again);

alert(“Thanks for playing”);
Make the intention clearer




do {
   keep_guessing_until_matched( mystery_number() );
} while (play_again());
say_thanks();
It’s still not good enough



do {

  keep_guessing_until_matched( mystery_number() );

} while (play_again());

say_thanks();


                      Why?
Because it is still this design


10    I = INT(10 * RND(1))
20    PRINT “GUESS MY NUMBER:”
30    INPUT J
40    IF INT(J) != I THEN GOTO 20 And it is not a
50    PRINT “YOU GOT IT!”          very good
60    PRINT “PLAY AGAIN (Y/N)?”   design either
70    INPUT Y
80    IF Y == ‘Y’ THEN GOTO 10
90    PRINT “THANKS FOR PLAYING”
How do I add a new feature?
10   I = INT(10 * RND(1))
20   PRINT “GUESS MY NUMBER:”
30   INPUT J
40   IF INT(J) != I THEN GOTO 20 And it is not a
50   PRINT “YOU GOT IT!”          very good
60   PRINT “PLAY AGAIN (Y/N)?”   design either
70   INPUT Y
80   IF Y == ‘Y’ THEN GOTO 10
90   PRINT “THANKS FOR PLAYING”
How do I test it?
10   I = INT(10 * RND(1))
20   PRINT “GUESS MY NUMBER:”
30   INPUT J
40   IF INT(J) != I THEN GOTO 20 And it is not a
50   PRINT “YOU GOT IT!”          very good
60   PRINT “PLAY AGAIN (Y/N)?”   design either
70   INPUT Y
80   IF Y == ‘Y’ THEN GOTO 10
90   PRINT “THANKS FOR PLAYING”
Let’s just focus on the game itself

TestCase("Game Tests", {
   "test new game should let us play": function() {
        var play = new_game();
        assertFunction(play);
     },
      "test play should let us check for a win": function() {
           var play = new_game();
           var win = play(5);
           assertFunction(win);
        },
      "test winning play": function() {
          var play = new_game();
          var guess = play['mystery_number'];
          var win = play(guess);
          assertTrue(win());
      }
});
The game as Higher Order Functions



         var play = new_game();
         var win = play(guess);



      The rest is user interface stuff
age Ma tter?
Does Langu
Every powerful language has this



             Primitive expressions

            Means of combination

              Means of abstraction


  (this parallels the basics of human understanding too, btw)
We use these languages to
express and organise our thoughts

  do {
     keep_guessing( mystery_number() );
  } while (play_again());
  say_thanks();


                   OR

       var play = new_game();
       var win = play(guess);
We use these languages to
express and organise our thoughts

  do {
      Build monolithic
     keep_guessing( mystery_number() );
  } while (play_again());
      static structures
  say_thanks();


                   OR

       var play = new_game();
       var win = play(guess);
     Build composable
    dynamic structures
JS let’s you build both.
What do you want to build?
       factor10.com :: @aslamkhn :: aslamkhan.net

Más contenido relacionado

La actualidad más candente

Welcome to MAZE
Welcome to MAZEWelcome to MAZE
Welcome to MAZEMayoiNoroi
 
The Ring programming language version 1.8 book - Part 52 of 202
The Ring programming language version 1.8 book - Part 52 of 202The Ring programming language version 1.8 book - Part 52 of 202
The Ring programming language version 1.8 book - Part 52 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185Mahmoud Samir Fayed
 

La actualidad más candente (7)

Welcome to MAZE
Welcome to MAZEWelcome to MAZE
Welcome to MAZE
 
The Ring programming language version 1.8 book - Part 52 of 202
The Ring programming language version 1.8 book - Part 52 of 202The Ring programming language version 1.8 book - Part 52 of 202
The Ring programming language version 1.8 book - Part 52 of 202
 
Serpent sboxes
Serpent sboxesSerpent sboxes
Serpent sboxes
 
The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185The Ring programming language version 1.5.4 book - Part 46 of 185
The Ring programming language version 1.5.4 book - Part 46 of 185
 
Tic tac toe code
Tic tac toe codeTic tac toe code
Tic tac toe code
 
pptuni1
pptuni1pptuni1
pptuni1
 
Toss_Up
Toss_UpToss_Up
Toss_Up
 

Destacado

Beyond Apartheid and Democracy
Beyond Apartheid and DemocracyBeyond Apartheid and Democracy
Beyond Apartheid and DemocracyAslam Khan
 
Product Innovation is a Habit
Product Innovation is a HabitProduct Innovation is a Habit
Product Innovation is a HabitEd Kraay
 
Demystifying 11 japanese jargons from tps lean
Demystifying 11 japanese jargons from tps leanDemystifying 11 japanese jargons from tps lean
Demystifying 11 japanese jargons from tps leanNitin Ramrakhyani
 
How to get open data into the hands of activists
How to get open data into the hands of activistsHow to get open data into the hands of activists
How to get open data into the hands of activistsAslam Khan
 
Lean roots to grow, wings to fly!
Lean roots to grow, wings to fly!Lean roots to grow, wings to fly!
Lean roots to grow, wings to fly!Nitin Ramrakhyani
 
Take Product Ownership To Next Level !!
Take Product Ownership To Next Level !!Take Product Ownership To Next Level !!
Take Product Ownership To Next Level !!Nitin Ramrakhyani
 
Scale hurts
Scale hurtsScale hurts
Scale hurtsEd Kraay
 
Agile 2012 inside out leading change from the middle
Agile 2012 inside out leading change from the middleAgile 2012 inside out leading change from the middle
Agile 2012 inside out leading change from the middleEd Kraay
 
Innovation is a habit
Innovation is a habitInnovation is a habit
Innovation is a habitEd Kraay
 
Puppet for Human Beings (NOT!)
Puppet for Human Beings (NOT!)Puppet for Human Beings (NOT!)
Puppet for Human Beings (NOT!)Aslam Khan
 
OperatingModelForProductCos
OperatingModelForProductCosOperatingModelForProductCos
OperatingModelForProductCosRavi Padaki
 
Surviving the Agile Re-Org
Surviving the Agile Re-OrgSurviving the Agile Re-Org
Surviving the Agile Re-OrgJesse Fewell
 
Kaizen events - jump start your continuous improvement culture
Kaizen events - jump start your continuous improvement cultureKaizen events - jump start your continuous improvement culture
Kaizen events - jump start your continuous improvement cultureEd Kraay
 
Scaling Agile Product Ownership In A Large Enterprise
Scaling Agile Product Ownership In A Large EnterpriseScaling Agile Product Ownership In A Large Enterprise
Scaling Agile Product Ownership In A Large EnterpriseNitin Ramrakhyani
 
InfoPak3 Personal Kanban Design Patterns
InfoPak3 Personal Kanban Design PatternsInfoPak3 Personal Kanban Design Patterns
InfoPak3 Personal Kanban Design PatternsJim Benson
 
Personal Kanban 101
Personal Kanban 101Personal Kanban 101
Personal Kanban 101Jim Benson
 

Destacado (20)

Beyond Apartheid and Democracy
Beyond Apartheid and DemocracyBeyond Apartheid and Democracy
Beyond Apartheid and Democracy
 
Product Innovation is a Habit
Product Innovation is a HabitProduct Innovation is a Habit
Product Innovation is a Habit
 
Demystifying 11 japanese jargons from tps lean
Demystifying 11 japanese jargons from tps leanDemystifying 11 japanese jargons from tps lean
Demystifying 11 japanese jargons from tps lean
 
How to get open data into the hands of activists
How to get open data into the hands of activistsHow to get open data into the hands of activists
How to get open data into the hands of activists
 
Lean roots to grow, wings to fly!
Lean roots to grow, wings to fly!Lean roots to grow, wings to fly!
Lean roots to grow, wings to fly!
 
Take Product Ownership To Next Level !!
Take Product Ownership To Next Level !!Take Product Ownership To Next Level !!
Take Product Ownership To Next Level !!
 
Scale hurts
Scale hurtsScale hurts
Scale hurts
 
Agile 2012 inside out leading change from the middle
Agile 2012 inside out leading change from the middleAgile 2012 inside out leading change from the middle
Agile 2012 inside out leading change from the middle
 
Innovation is a habit
Innovation is a habitInnovation is a habit
Innovation is a habit
 
Systems Thinking
Systems ThinkingSystems Thinking
Systems Thinking
 
Puppet for Human Beings (NOT!)
Puppet for Human Beings (NOT!)Puppet for Human Beings (NOT!)
Puppet for Human Beings (NOT!)
 
Speed2 innovation agile noida
Speed2 innovation agile noidaSpeed2 innovation agile noida
Speed2 innovation agile noida
 
OperatingModelForProductCos
OperatingModelForProductCosOperatingModelForProductCos
OperatingModelForProductCos
 
Surviving the Agile Re-Org
Surviving the Agile Re-OrgSurviving the Agile Re-Org
Surviving the Agile Re-Org
 
Lean Analytics 101
Lean Analytics 101Lean Analytics 101
Lean Analytics 101
 
Kaizen events - jump start your continuous improvement culture
Kaizen events - jump start your continuous improvement cultureKaizen events - jump start your continuous improvement culture
Kaizen events - jump start your continuous improvement culture
 
Scaling Agile Product Ownership In A Large Enterprise
Scaling Agile Product Ownership In A Large EnterpriseScaling Agile Product Ownership In A Large Enterprise
Scaling Agile Product Ownership In A Large Enterprise
 
InfoPak3 Personal Kanban Design Patterns
InfoPak3 Personal Kanban Design PatternsInfoPak3 Personal Kanban Design Patterns
InfoPak3 Personal Kanban Design Patterns
 
Antifragility and Coaching 20151029
Antifragility and Coaching 20151029Antifragility and Coaching 20151029
Antifragility and Coaching 20151029
 
Personal Kanban 101
Personal Kanban 101Personal Kanban 101
Personal Kanban 101
 

Similar a Yet another building metaphor

This is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdfThis is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdffeelinggift
 
Hello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfHello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfjyothimuppasani1
 
Utility Classes Are Killing Us
Utility Classes Are Killing UsUtility Classes Are Killing Us
Utility Classes Are Killing UsYegor Bugayenko
 
PLEASE can do this in NETBEAN I need that way thank very muchManca.pdf
PLEASE can do this in NETBEAN I need that way thank very muchManca.pdfPLEASE can do this in NETBEAN I need that way thank very muchManca.pdf
PLEASE can do this in NETBEAN I need that way thank very muchManca.pdfkennithdase
 
Guess a number game v1.00
Guess a number game v1.00Guess a number game v1.00
Guess a number game v1.00Willie Barnes
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfasif1401
 
The Ring programming language version 1.10 book - Part 62 of 212
The Ring programming language version 1.10 book - Part 62 of 212The Ring programming language version 1.10 book - Part 62 of 212
The Ring programming language version 1.10 book - Part 62 of 212Mahmoud Samir Fayed
 
Guees a number game v1.05
Guees a number game v1.05Guees a number game v1.05
Guees a number game v1.05Willie Barnes
 
This is for an homework assignment using Java code. Here is the home.pdf
This is for an homework assignment using Java code. Here is the home.pdfThis is for an homework assignment using Java code. Here is the home.pdf
This is for an homework assignment using Java code. Here is the home.pdfrajkumarm401
 
Guess a number game v1.10
Guess a number game v1.10Guess a number game v1.10
Guess a number game v1.10Willie Barnes
 
The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196Mahmoud Samir Fayed
 
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfrajkumarm401
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfanjandavid
 
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31Mahmoud Samir Fayed
 
Why we disagree
Why we disagreeWhy we disagree
Why we disagreeChang Wang
 
The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202Mahmoud Samir Fayed
 
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdfNeed to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdfflashfashioncasualwe
 

Similar a Yet another building metaphor (20)

This is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdfThis is a homework assignment that I have for my Java coding class. .pdf
This is a homework assignment that I have for my Java coding class. .pdf
 
Hello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfHello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdf
 
Utility Classes Are Killing Us
Utility Classes Are Killing UsUtility Classes Are Killing Us
Utility Classes Are Killing Us
 
PLEASE can do this in NETBEAN I need that way thank very muchManca.pdf
PLEASE can do this in NETBEAN I need that way thank very muchManca.pdfPLEASE can do this in NETBEAN I need that way thank very muchManca.pdf
PLEASE can do this in NETBEAN I need that way thank very muchManca.pdf
 
Guess a number game v1.00
Guess a number game v1.00Guess a number game v1.00
Guess a number game v1.00
 
The main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdfThe main class of the tictoe game looks like.public class Main {.pdf
The main class of the tictoe game looks like.public class Main {.pdf
 
The Ring programming language version 1.10 book - Part 62 of 212
The Ring programming language version 1.10 book - Part 62 of 212The Ring programming language version 1.10 book - Part 62 of 212
The Ring programming language version 1.10 book - Part 62 of 212
 
Guees a number game v1.05
Guees a number game v1.05Guees a number game v1.05
Guees a number game v1.05
 
This is for an homework assignment using Java code. Here is the home.pdf
This is for an homework assignment using Java code. Here is the home.pdfThis is for an homework assignment using Java code. Here is the home.pdf
This is for an homework assignment using Java code. Here is the home.pdf
 
Guess a number game v1.10
Guess a number game v1.10Guess a number game v1.10
Guess a number game v1.10
 
The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196The Ring programming language version 1.7 book - Part 55 of 196
The Ring programming language version 1.7 book - Part 55 of 196
 
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdfObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
ObjectiveCreate a graphical game of minesweeper IN JAVA. The boar.pdf
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
 
The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84The Ring programming language version 1.2 book - Part 38 of 84
The Ring programming language version 1.2 book - Part 38 of 84
 
The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180The Ring programming language version 1.5.1 book - Part 49 of 180
The Ring programming language version 1.5.1 book - Part 49 of 180
 
The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31The Ring programming language version 1.4.1 book - Part 15 of 31
The Ring programming language version 1.4.1 book - Part 15 of 31
 
Python scripts
Python scriptsPython scripts
Python scripts
 
Why we disagree
Why we disagreeWhy we disagree
Why we disagree
 
The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202The Ring programming language version 1.8 book - Part 57 of 202
The Ring programming language version 1.8 book - Part 57 of 202
 
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdfNeed to make a ReversiOthello Board game in JAVAThe board size ca.pdf
Need to make a ReversiOthello Board game in JAVAThe board size ca.pdf
 

Más de Aslam Khan

The Humble Programmer
The Humble ProgrammerThe Humble Programmer
The Humble ProgrammerAslam Khan
 
Experiments in Reasoning
Experiments in ReasoningExperiments in Reasoning
Experiments in ReasoningAslam Khan
 
Do we care rubyfuza 2019
Do we care   rubyfuza 2019Do we care   rubyfuza 2019
Do we care rubyfuza 2019Aslam Khan
 
Agile Rabbit Holes
Agile Rabbit HolesAgile Rabbit Holes
Agile Rabbit HolesAslam Khan
 
Not Quite Object Oriented
Not Quite Object OrientedNot Quite Object Oriented
Not Quite Object OrientedAslam Khan
 
Lean in Software Development
Lean in Software DevelopmentLean in Software Development
Lean in Software DevelopmentAslam Khan
 
Product Ownership - Leaders of Agile Webinar
Product Ownership - Leaders of Agile WebinarProduct Ownership - Leaders of Agile Webinar
Product Ownership - Leaders of Agile WebinarAslam Khan
 
Being in a State of REST
Being in a State of RESTBeing in a State of REST
Being in a State of RESTAslam Khan
 
Practical Scrum with Kent Beck (SD Times Webinar)
Practical Scrum with Kent Beck (SD Times Webinar)Practical Scrum with Kent Beck (SD Times Webinar)
Practical Scrum with Kent Beck (SD Times Webinar)Aslam Khan
 
Collaboration: TRC
Collaboration: TRCCollaboration: TRC
Collaboration: TRCAslam Khan
 

Más de Aslam Khan (10)

The Humble Programmer
The Humble ProgrammerThe Humble Programmer
The Humble Programmer
 
Experiments in Reasoning
Experiments in ReasoningExperiments in Reasoning
Experiments in Reasoning
 
Do we care rubyfuza 2019
Do we care   rubyfuza 2019Do we care   rubyfuza 2019
Do we care rubyfuza 2019
 
Agile Rabbit Holes
Agile Rabbit HolesAgile Rabbit Holes
Agile Rabbit Holes
 
Not Quite Object Oriented
Not Quite Object OrientedNot Quite Object Oriented
Not Quite Object Oriented
 
Lean in Software Development
Lean in Software DevelopmentLean in Software Development
Lean in Software Development
 
Product Ownership - Leaders of Agile Webinar
Product Ownership - Leaders of Agile WebinarProduct Ownership - Leaders of Agile Webinar
Product Ownership - Leaders of Agile Webinar
 
Being in a State of REST
Being in a State of RESTBeing in a State of REST
Being in a State of REST
 
Practical Scrum with Kent Beck (SD Times Webinar)
Practical Scrum with Kent Beck (SD Times Webinar)Practical Scrum with Kent Beck (SD Times Webinar)
Practical Scrum with Kent Beck (SD Times Webinar)
 
Collaboration: TRC
Collaboration: TRCCollaboration: TRC
Collaboration: TRC
 

Último

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 

Último (20)

"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Yet another building metaphor

  • 1. Yet Another Building Metaphor factor10.com :: @aslamkhn :: aslamkhan.net
  • 2. Aslam Khan mail at aslam.khan@factor10.com blog at http://aslamkhan.net tweet at @aslamkhn skype at aslmkhn
  • 3. One of the first games that I wrote 10 I = INT(10 * RND(1)) 20 PRINT “GUESS MY NUMBER:” 30 INPUT J 40 IF INT(J) != I THEN GOTO 20 50 PRINT “YOU GOT IT!” 60 PRINT “PLAY AGAIN (Y/N)?” 70 INPUT Y 80 IF Y == ‘Y’ THEN GOTO 10 90 PRINT “THANKS FOR PLAYING”
  • 4. It looks The JS version better with whitespace do { var i = Math.floor(Math.random()*11); do { var j = prompt(“Guess my number”); } while (i != j); alert(“You got it!); y = confirm(“Play again?”); } while (y); alert(“Thanks for playing”);
  • 5. It reads better with whitespace do { var i = Math.floor(Math.random()*11); do { var j = prompt(“Guess my number”); } while (i != j); alert(“You got it!); y = confirm(“Play again?”); } while (y); alert(“Thanks for playing”);
  • 6. What else can we do about it? do { var i = Math.floor(Math.random()*11); do { var j = prompt(“Guess my number”); } while (i != j); alert(“You got it!); y = confirm(“Play again?”); } while (y); alert(“Thanks for playing”);
  • 7. It reads better with nicer names do { var mystery_number = Math.floor(Math.random()*11); do { var guessed_number = prompt(“Guess my number”); } while (guessed_number != mystery_number); alert(“You got it!); var play_again = confirm(“Play again?”); } while (play_again); alert(“Thanks for playing”);
  • 8. Can we do better than renaming? do { var mystery_number = Math.floor(Math.random()*11); do { var guessed_number = prompt(“Guess my number”); } while (guessed_number != mystery_number); alert(“You got it!); var play_again = confirm(“Play again?”); } while (play_again); alert(“Thanks for playing”);
  • 9. Make the intention clearer do { keep_guessing_until_matched( mystery_number() ); } while (play_again()); say_thanks();
  • 10. It’s still not good enough do { keep_guessing_until_matched( mystery_number() ); } while (play_again()); say_thanks(); Why?
  • 11. Because it is still this design 10 I = INT(10 * RND(1)) 20 PRINT “GUESS MY NUMBER:” 30 INPUT J 40 IF INT(J) != I THEN GOTO 20 And it is not a 50 PRINT “YOU GOT IT!” very good 60 PRINT “PLAY AGAIN (Y/N)?” design either 70 INPUT Y 80 IF Y == ‘Y’ THEN GOTO 10 90 PRINT “THANKS FOR PLAYING”
  • 12. How do I add a new feature? 10 I = INT(10 * RND(1)) 20 PRINT “GUESS MY NUMBER:” 30 INPUT J 40 IF INT(J) != I THEN GOTO 20 And it is not a 50 PRINT “YOU GOT IT!” very good 60 PRINT “PLAY AGAIN (Y/N)?” design either 70 INPUT Y 80 IF Y == ‘Y’ THEN GOTO 10 90 PRINT “THANKS FOR PLAYING”
  • 13. How do I test it? 10 I = INT(10 * RND(1)) 20 PRINT “GUESS MY NUMBER:” 30 INPUT J 40 IF INT(J) != I THEN GOTO 20 And it is not a 50 PRINT “YOU GOT IT!” very good 60 PRINT “PLAY AGAIN (Y/N)?” design either 70 INPUT Y 80 IF Y == ‘Y’ THEN GOTO 10 90 PRINT “THANKS FOR PLAYING”
  • 14. Let’s just focus on the game itself TestCase("Game Tests", { "test new game should let us play": function() { var play = new_game(); assertFunction(play); }, "test play should let us check for a win": function() { var play = new_game(); var win = play(5); assertFunction(win); }, "test winning play": function() { var play = new_game(); var guess = play['mystery_number']; var win = play(guess); assertTrue(win()); } });
  • 15. The game as Higher Order Functions var play = new_game(); var win = play(guess); The rest is user interface stuff
  • 17. Every powerful language has this Primitive expressions Means of combination Means of abstraction (this parallels the basics of human understanding too, btw)
  • 18. We use these languages to express and organise our thoughts do { keep_guessing( mystery_number() ); } while (play_again()); say_thanks(); OR var play = new_game(); var win = play(guess);
  • 19. We use these languages to express and organise our thoughts do { Build monolithic keep_guessing( mystery_number() ); } while (play_again()); static structures say_thanks(); OR var play = new_game(); var win = play(guess); Build composable dynamic structures
  • 20. JS let’s you build both. What do you want to build? factor10.com :: @aslamkhn :: aslamkhan.net