SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Downloaden Sie, um offline zu lesen
Better Functional Design
       through TDD
Phil Calçado – SoundCloud
        @pcalcado
  http://philcalcado.com
This talk is not about how.
Clojure TDD demo by Brian Marick
http://bit.ly/sjCJBm




                       http://www.flickr.com/photos/doug88888/4507077583/
This talk is not about how.

     It is about why.
The London
  School



             http://www.flickr.com/photos/doug88888/4507077583/
The London School
1.Write a failing functional test
2.Mark it as Work-in-progress
3.Write a failing unit or integration test
4.Make it pass
5.Refactor
6.Repeat steps 3 to 5 until your functional
test passes

                     http://www.flickr.com/photos/doug88888/4507077583/
http://amzn.to/vZv4Yw
What Is the Point of
Test-Driven Development?
1.Software development
is a learning process
2.Feedback is the
Fundamental tool
3.Practices that support
change
But that is Development.
  What about Design?
http://amzn.to/vZv4Yw
“There are three aspects of TDD
that help us achieve [good
design]:
First, starting with a test means
that we have to describe what we
want to achieve before we
consider how. This focus helps
us maintain the right level
of abstraction.
“Write code in terms of the
problem's data types, not the types
     that happen to be in the
         implementation.”

        Peter Norvig, Good Lisp Programming Style - http://bit.ly/u6JTPt
Reverse engineering.
Lots of how. Not so much
      what or why.
To ensure that you say what you mean:
1.Start with an English description of the
algorithm
2.Write the code from the description
3.Translate the code back to English
4.Compare 3 to 1

           Peter Norvig, Good Lisp Programming Style - http://bit.ly/u6JTPt
On the (over-)usage of maps

 http://bit.ly/sNSVz9
Second, to keep tests
understandable and maintainable,
we limit their scope. Tests that
are dozens of lines long tell us
that the component they’re testing
is too large and needs breaking up
into smaller components.
“Break the problem into parts.
  Design useful subparts. Be
       opportunistic.”


      Peter Norvig, Good Lisp Programming Style - http://bit.ly/u6JTPt
Reverse engineering.
Way too much stuff going on.
Every function should have:
●A single specific purpose

●If possible, a generally useful purpose

●A meaningful name

●A structure that is simple to understand

●An interface that is simple yet general


enough

          Peter Norvig, Good Lisp Programming Style - http://bit.ly/u6JTPt
Third, to prepare a component for
a unit test, we have to pass its
dependencies to it, which means
that we have to know what they
are. A component with
implicit (or just too many)
dependencies is painful to
test.”
“Determine dependencies.
 Re-modularise to reduce
dependencies. Design most
  dependent parts first.”

    Peter Norvig, Good Lisp Programming Style - http://bit.ly/u6JTPt
Introduce similar feature.
Make it green.
Make it better.
Evolving to closures
   and combinators:
http://bit.ly/sTF5Nl
I see strong correlation
   between good design
and test-driven development.
Code which is coupled and
     complicated is
       bad design
Code which is coupled and
     complicated is
    hard to maintain
Code which is coupled and
     complicated is
      hard to test
http://xkcd.com/552/
http://soundcloud.com/jobs

Weitere ähnliche Inhalte

Was ist angesagt?

(WS11) Saša Matijašić (LogIT internet usluge): Quo Vadis, Browser?*
(WS11) Saša Matijašić (LogIT internet usluge): Quo Vadis, Browser?*(WS11) Saša Matijašić (LogIT internet usluge): Quo Vadis, Browser?*
(WS11) Saša Matijašić (LogIT internet usluge): Quo Vadis, Browser?*
Web::Strategija
 
Cf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanshipCf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanship
ColdFusionConference
 

Was ist angesagt? (12)

A Tale of Two Apps
A Tale of Two AppsA Tale of Two Apps
A Tale of Two Apps
 
Making sense of streaming
Making sense of streamingMaking sense of streaming
Making sense of streaming
 
SOA.2020
SOA.2020SOA.2020
SOA.2020
 
(WS11) Saša Matijašić (LogIT internet usluge): Quo Vadis, Browser?*
(WS11) Saša Matijašić (LogIT internet usluge): Quo Vadis, Browser?*(WS11) Saša Matijašić (LogIT internet usluge): Quo Vadis, Browser?*
(WS11) Saša Matijašić (LogIT internet usluge): Quo Vadis, Browser?*
 
Cf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanshipCf objective2014 software-craftsmanship
Cf objective2014 software-craftsmanship
 
Simplicitylesscode
SimplicitylesscodeSimplicitylesscode
Simplicitylesscode
 
Angular Vienna - Use React tools for better Angular apps
Angular Vienna - Use React tools for better Angular appsAngular Vienna - Use React tools for better Angular apps
Angular Vienna - Use React tools for better Angular apps
 
Code refactoring
Code refactoringCode refactoring
Code refactoring
 
Yet another startup built on Clojure(Script)
Yet another startup built on Clojure(Script)Yet another startup built on Clojure(Script)
Yet another startup built on Clojure(Script)
 
Does reporting takes lots of time
Does reporting takes lots of timeDoes reporting takes lots of time
Does reporting takes lots of time
 
Contract Testing Php-pact
Contract Testing Php-pactContract Testing Php-pact
Contract Testing Php-pact
 
Improving your code design using Java
Improving your code design using JavaImproving your code design using Java
Improving your code design using Java
 

Ähnlich wie Better Functional Design through TDD

Placement-pucrehxycufocuccpuupcuppcps.pptx
Placement-pucrehxycufocuccpuupcuppcps.pptxPlacement-pucrehxycufocuccpuupcuppcps.pptx
Placement-pucrehxycufocuccpuupcuppcps.pptx
YashJadhav496388
 
Cf objective2014 testing-testingeverywhere
Cf objective2014   testing-testingeverywhereCf objective2014   testing-testingeverywhere
Cf objective2014 testing-testingeverywhere
ColdFusionConference
 
Agile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovAgile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin Nakov
Svetlin Nakov
 

Ähnlich wie Better Functional Design through TDD (20)

TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019TDD and Simple Design Workshop - Session 1 - March 2019
TDD and Simple Design Workshop - Session 1 - March 2019
 
Cf objective2014 software-craftsmanship
Cf objective2014   software-craftsmanshipCf objective2014   software-craftsmanship
Cf objective2014 software-craftsmanship
 
Placement-pucrehxycufocuccpuupcuppcps.pptx
Placement-pucrehxycufocuccpuupcuppcps.pptxPlacement-pucrehxycufocuccpuupcuppcps.pptx
Placement-pucrehxycufocuccpuupcuppcps.pptx
 
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd   seven years afterIan Cooper webinar for DDD Iran: Kent beck style tdd   seven years after
Ian Cooper webinar for DDD Iran: Kent beck style tdd seven years after
 
ODSC West 2022 – Kitbashing in ML
ODSC West 2022 – Kitbashing in MLODSC West 2022 – Kitbashing in ML
ODSC West 2022 – Kitbashing in ML
 
How to get started with Site Reliability Engineering
How to get started with Site Reliability EngineeringHow to get started with Site Reliability Engineering
How to get started with Site Reliability Engineering
 
Cf objective2014 testing-testingeverywhere
Cf objective2014   testing-testingeverywhereCf objective2014   testing-testingeverywhere
Cf objective2014 testing-testingeverywhere
 
Cf objective2014 testing-testingeverywhere
Cf objective2014   testing-testingeverywhereCf objective2014   testing-testingeverywhere
Cf objective2014 testing-testingeverywhere
 
Test Drive Development
Test Drive DevelopmentTest Drive Development
Test Drive Development
 
tem7
tem7tem7
tem7
 
Zap Scanning
Zap ScanningZap Scanning
Zap Scanning
 
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflowMay 2021 Spark Testing ... or how to farm reputation on StackOverflow
May 2021 Spark Testing ... or how to farm reputation on StackOverflow
 
Introduction to Behavior Driven Development
Introduction to Behavior Driven Development Introduction to Behavior Driven Development
Introduction to Behavior Driven Development
 
TestDrivenDeveloment
TestDrivenDevelomentTestDrivenDeveloment
TestDrivenDeveloment
 
Test-Driven Development In Action
Test-Driven Development In ActionTest-Driven Development In Action
Test-Driven Development In Action
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
 
Introduction to TDD
Introduction to TDDIntroduction to TDD
Introduction to TDD
 
Agile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin NakovAgile Methodologies And Extreme Programming - Svetlin Nakov
Agile Methodologies And Extreme Programming - Svetlin Nakov
 
Python and test
Python and testPython and test
Python and test
 
That worked before
That worked beforeThat worked before
That worked before
 

Mehr von Phil Calçado

the afterparty: refactoring after 100x hypergrowth
the afterparty: refactoring after 100x hypergrowththe afterparty: refactoring after 100x hypergrowth
the afterparty: refactoring after 100x hypergrowth
Phil Calçado
 
don't try this at home: self-improvement as a senior leader
don't try this at home: self-improvement as a senior leaderdon't try this at home: self-improvement as a senior leader
don't try this at home: self-improvement as a senior leader
Phil Calçado
 
From microservices to serverless - Chicago CTO Summit 2019
From microservices to serverless - Chicago CTO Summit 2019From microservices to serverless - Chicago CTO Summit 2019
From microservices to serverless - Chicago CTO Summit 2019
Phil Calçado
 
Microservices vs. The First Law of Distributed Objects - GOTO Nights Chicago ...
Microservices vs. The First Law of Distributed Objects - GOTO Nights Chicago ...Microservices vs. The First Law of Distributed Objects - GOTO Nights Chicago ...
Microservices vs. The First Law of Distributed Objects - GOTO Nights Chicago ...
Phil Calçado
 
An example of Future composition in a real app
An example of Future composition in a real appAn example of Future composition in a real app
An example of Future composition in a real app
Phil Calçado
 
Evolutionary Architecture at Work
Evolutionary  Architecture at WorkEvolutionary  Architecture at Work
Evolutionary Architecture at Work
Phil Calçado
 
Structuring apps in Scala
Structuring apps in ScalaStructuring apps in Scala
Structuring apps in Scala
Phil Calçado
 
From a monolithic Ruby on Rails app to the JVM
From a monolithic  Ruby on Rails app  to the JVMFrom a monolithic  Ruby on Rails app  to the JVM
From a monolithic Ruby on Rails app to the JVM
Phil Calçado
 
Applying Evolutionary Architecture on a Popular API
Applying Evolutionary Architecture on a  Popular APIApplying Evolutionary Architecture on a  Popular API
Applying Evolutionary Architecture on a Popular API
Phil Calçado
 
SoundCloud Masterclass on Brazil
SoundCloud Masterclass on BrazilSoundCloud Masterclass on Brazil
SoundCloud Masterclass on Brazil
Phil Calçado
 

Mehr von Phil Calçado (20)

the afterparty: refactoring after 100x hypergrowth
the afterparty: refactoring after 100x hypergrowththe afterparty: refactoring after 100x hypergrowth
the afterparty: refactoring after 100x hypergrowth
 
don't try this at home: self-improvement as a senior leader
don't try this at home: self-improvement as a senior leaderdon't try this at home: self-improvement as a senior leader
don't try this at home: self-improvement as a senior leader
 
From microservices to serverless - Chicago CTO Summit 2019
From microservices to serverless - Chicago CTO Summit 2019From microservices to serverless - Chicago CTO Summit 2019
From microservices to serverless - Chicago CTO Summit 2019
 
Ten Years of Failing Microservices
Ten Years of Failing MicroservicesTen Years of Failing Microservices
Ten Years of Failing Microservices
 
The Next Generation of Microservices
The Next Generation of MicroservicesThe Next Generation of Microservices
The Next Generation of Microservices
 
The Next Generation of Microservices — YOW 2017 Brisbane
The Next Generation of Microservices — YOW 2017 BrisbaneThe Next Generation of Microservices — YOW 2017 Brisbane
The Next Generation of Microservices — YOW 2017 Brisbane
 
Microservices vs. The First Law of Distributed Objects - GOTO Nights Chicago ...
Microservices vs. The First Law of Distributed Objects - GOTO Nights Chicago ...Microservices vs. The First Law of Distributed Objects - GOTO Nights Chicago ...
Microservices vs. The First Law of Distributed Objects - GOTO Nights Chicago ...
 
Finagle @ SoundCloud
Finagle @ SoundCloudFinagle @ SoundCloud
Finagle @ SoundCloud
 
A Brief Talk On High-Performing Organisations
A Brief Talk On High-Performing OrganisationsA Brief Talk On High-Performing Organisations
A Brief Talk On High-Performing Organisations
 
Three Years of Microservices at SoundCloud - Distributed Matters Berlin 2015
Three Years of Microservices at SoundCloud - Distributed Matters Berlin 2015Three Years of Microservices at SoundCloud - Distributed Matters Berlin 2015
Three Years of Microservices at SoundCloud - Distributed Matters Berlin 2015
 
Rhein-Main Scala Enthusiasts — Your microservice as a Function
Rhein-Main Scala Enthusiasts — Your microservice as a FunctionRhein-Main Scala Enthusiasts — Your microservice as a Function
Rhein-Main Scala Enthusiasts — Your microservice as a Function
 
ScalaItaly 2015 - Your Microservice as a Function
ScalaItaly 2015 - Your Microservice as a FunctionScalaItaly 2015 - Your Microservice as a Function
ScalaItaly 2015 - Your Microservice as a Function
 
Finagle-Based Microservices at SoundCloud
Finagle-Based Microservices at SoundCloudFinagle-Based Microservices at SoundCloud
Finagle-Based Microservices at SoundCloud
 
An example of Future composition in a real app
An example of Future composition in a real appAn example of Future composition in a real app
An example of Future composition in a real app
 
APIs: The Problems with Eating your Own Dog Food
APIs: The Problems with Eating your Own Dog FoodAPIs: The Problems with Eating your Own Dog Food
APIs: The Problems with Eating your Own Dog Food
 
Evolutionary Architecture at Work
Evolutionary  Architecture at WorkEvolutionary  Architecture at Work
Evolutionary Architecture at Work
 
Structuring apps in Scala
Structuring apps in ScalaStructuring apps in Scala
Structuring apps in Scala
 
From a monolithic Ruby on Rails app to the JVM
From a monolithic  Ruby on Rails app  to the JVMFrom a monolithic  Ruby on Rails app  to the JVM
From a monolithic Ruby on Rails app to the JVM
 
Applying Evolutionary Architecture on a Popular API
Applying Evolutionary Architecture on a  Popular APIApplying Evolutionary Architecture on a  Popular API
Applying Evolutionary Architecture on a Popular API
 
SoundCloud Masterclass on Brazil
SoundCloud Masterclass on BrazilSoundCloud Masterclass on Brazil
SoundCloud Masterclass on Brazil
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Better Functional Design through TDD