SlideShare a Scribd company logo
Test Driven DevelopmentTest Driven Development
Part 2
Gamal ShaabanGamal Shaaban
International Centers
Orange Labs Cairo
Mobile Applications & Software Development
2 Orange restricted
3 Orange restricted
Session-2Session-2
3
• The Three Rules Of TDD
• Legacy Code & Refactoring
• Code Smells
• Coupling And Cohesion
• Continues Integration
4 Orange restricted
THE THREE
RULES OF TDD 1. You are not allowed to write any production
code unless it is to make a failing unit test pass.
2. You are not allowed to write any more of a unit
test than is sufficient to fail; and compilation
failures are failures.
3. You are not allowed to write any more
production code than is sufficient to pass the
one failing unit test.
 http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd
4
5 Orange restricted
RefactoringRefactoring  Refactoring is one of the most important parts
of TDD, which means you need to refine the
code design as you add new tests.
 Refactoring should be done consistently as
you increment the software, adding tests and
production code.
 Make code easier to maintain in the future
 Use IDE when possible to do refactoring.
 Refactor Without Fear.
5
6 Orange restricted
Code SmellsCode Smells
A code smell is a surface indication that usually corresponds to
a deeper problem in the system.
Martin FowlerMartin Fowler
http://martinfowler.com/bliki/CodeSmell.html
6
7 Orange restricted
Smells To BeSmells To Be
RefactoredRefactored
1.Duplicated Code
2.Long Method
3.Large Class
4.Long Parameter List
5.Divergent Change
6.Lazy Class
7.Speculative Generality
8.Temporary Field
9.Data Class
10.Refused Bequest
11.Comments
12.MiddleMan
8 Orange restricted
COUPLING ANDCOUPLING AND
COHESIONCOHESION
 Maximize internal interaction
(cohesion)
• easier to understand
• easier to test
 Minimize external interaction
(coupling)
• can be used independently
• easier to test
• easier to replace
• easier to understand
8
9 Orange restricted
9
Degree of dependence
among components
No dependencies Loosely coupled-some dependencies
Highly coupled-many dependencies
10 Orange restricted
11 Orange restricted
CONTINUES INTEGRATION
12 Orange restricted
• Teams integrate their work multiple times
per day.
• Each integration is verified by an
automated build
• Significantly reduces integration problems
• Develop cohesive software more rapidly
Source: Martin Fowler
13 Orange restricted
Five Principles of Continuous Integration
• Environments based on stability
• Maintain a code repository
• Commit frequently and build every commit
• Make the build self-testing
• Store every build
13
14 Orange restrictedOrange presentation
Questions?
thanks

More Related Content

What's hot (11)

PPTX
Code Smells Part 1: Basic Smells
Nancy Henson
 
PPTX
Refactoring, 2nd Edition
jexp
 
PDF
TDD CrashCourse Part2: TDD
David Rodenas
 
ODP
TDD - Test Driven Development
Lim Chanmann
 
PPT
Unit Testing
François Camus
 
PDF
Test driven development vs Behavior driven development
Gallop Solutions
 
PPTX
TDD with RSpec
Rachid Calazans
 
PDF
Testing concurrent java programs - Sameer Arora
IndicThreads
 
PPT
Test drive on driven development process
Muralidharan Deenathayalan
 
PPTX
TDD = bra design?
Kjetil Klaussen
 
Code Smells Part 1: Basic Smells
Nancy Henson
 
Refactoring, 2nd Edition
jexp
 
TDD CrashCourse Part2: TDD
David Rodenas
 
TDD - Test Driven Development
Lim Chanmann
 
Unit Testing
François Camus
 
Test driven development vs Behavior driven development
Gallop Solutions
 
TDD with RSpec
Rachid Calazans
 
Testing concurrent java programs - Sameer Arora
IndicThreads
 
Test drive on driven development process
Muralidharan Deenathayalan
 
TDD = bra design?
Kjetil Klaussen
 

Viewers also liked (18)

PPT
PlanMyDay remote_secretary
PlanMyDay
 
PPTX
Pemahaman tentang hak kekayaan intelektual
aliyahzahra
 
PPTX
Cigarette
Bengi Koseoglu
 
ODP
Montaje
encarnika
 
PPTX
Pemahaman tentang hak kekayaan intelektual
aliyahzahra
 
PPTX
ssk foundation. macam keajaiban dunia yang indah 2014
Nada Nafisah
 
PPTX
Pemahaman tentang hak kekayaan intelektual
aliyahzahra
 
PPTX
Orange developers day-Application Caching
Gamal Shaban
 
PPTX
Author and Audience
loisboylan
 
PPTX
Orange developers day - Hibernate Search Workshop
Gamal Shaban
 
ODP
Montaje
encarnika
 
PPTX
Pemahaman tentang hak kekayaan intelektual
aliyahzahra
 
PPT
Test Driven Development Part 1
Gamal Shaban
 
PPTX
Inquiry based labs
corinne01
 
PPT
Time management
PlanMyDay
 
PPTX
Spring session
Gamal Shaban
 
PPTX
Hücre ve organeller
Tuba Turgutlu
 
PPTX
It Takes a Village: How Data Projects Succeed
Amy Gaskins
 
PlanMyDay remote_secretary
PlanMyDay
 
Pemahaman tentang hak kekayaan intelektual
aliyahzahra
 
Cigarette
Bengi Koseoglu
 
Montaje
encarnika
 
Pemahaman tentang hak kekayaan intelektual
aliyahzahra
 
ssk foundation. macam keajaiban dunia yang indah 2014
Nada Nafisah
 
Pemahaman tentang hak kekayaan intelektual
aliyahzahra
 
Orange developers day-Application Caching
Gamal Shaban
 
Author and Audience
loisboylan
 
Orange developers day - Hibernate Search Workshop
Gamal Shaban
 
Montaje
encarnika
 
Pemahaman tentang hak kekayaan intelektual
aliyahzahra
 
Test Driven Development Part 1
Gamal Shaban
 
Inquiry based labs
corinne01
 
Time management
PlanMyDay
 
Spring session
Gamal Shaban
 
Hücre ve organeller
Tuba Turgutlu
 
It Takes a Village: How Data Projects Succeed
Amy Gaskins
 
Ad

Similar to Test Driven Development Part 2 (20)

PDF
Keeping code clean
Brett Child
 
PPTX
Test Drive Dirven Driver HAHAahhaha.pptx
findwaytocom
 
PDF
Day2 - Refactoring (Lecture SS 2015)
wolframkriesing
 
PDF
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay Da Nang
 
PPTX
An Introduction to Developer Testing
Will Green
 
PPTX
Code quality
Sunil Prasad
 
PDF
Test-Driven Development
Amir Assad
 
PDF
Refactoring
Xavier Fornés Arrabal
 
PDF
Test Driven Design - GDG DevFest Istanbul 2016
Lemi Orhan Ergin
 
PDF
Test Driven Design
Saad Ahmed
 
PPTX
Paving the Way for Agile Engineering Practices
Aman King
 
PPT
TDD - Christchurch APN May 2012
Alan Christensen
 
PPTX
TDD & Refactoring
Hernan Wilkinson
 
PPTX
QA and scrum
clintonbosch
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Test Driven Development
dcsunu
 
PPTX
Test driven development
Luis Goldster
 
PPTX
Test driven development
Young Alista
 
PPTX
Test driven development
Tony Nguyen
 
PPTX
Test driven development
Fraboni Ec
 
Keeping code clean
Brett Child
 
Test Drive Dirven Driver HAHAahhaha.pptx
findwaytocom
 
Day2 - Refactoring (Lecture SS 2015)
wolframkriesing
 
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
DevDay Da Nang
 
An Introduction to Developer Testing
Will Green
 
Code quality
Sunil Prasad
 
Test-Driven Development
Amir Assad
 
Test Driven Design - GDG DevFest Istanbul 2016
Lemi Orhan Ergin
 
Test Driven Design
Saad Ahmed
 
Paving the Way for Agile Engineering Practices
Aman King
 
TDD - Christchurch APN May 2012
Alan Christensen
 
TDD & Refactoring
Hernan Wilkinson
 
QA and scrum
clintonbosch
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Test Driven Development
dcsunu
 
Test driven development
Luis Goldster
 
Test driven development
Young Alista
 
Test driven development
Tony Nguyen
 
Test driven development
Fraboni Ec
 
Ad

Recently uploaded (20)

PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 

Test Driven Development Part 2

  • 1. Test Driven DevelopmentTest Driven Development Part 2 Gamal ShaabanGamal Shaaban International Centers Orange Labs Cairo Mobile Applications & Software Development
  • 3. 3 Orange restricted Session-2Session-2 3 • The Three Rules Of TDD • Legacy Code & Refactoring • Code Smells • Coupling And Cohesion • Continues Integration
  • 4. 4 Orange restricted THE THREE RULES OF TDD 1. You are not allowed to write any production code unless it is to make a failing unit test pass. 2. You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures. 3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.  http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd 4
  • 5. 5 Orange restricted RefactoringRefactoring  Refactoring is one of the most important parts of TDD, which means you need to refine the code design as you add new tests.  Refactoring should be done consistently as you increment the software, adding tests and production code.  Make code easier to maintain in the future  Use IDE when possible to do refactoring.  Refactor Without Fear. 5
  • 6. 6 Orange restricted Code SmellsCode Smells A code smell is a surface indication that usually corresponds to a deeper problem in the system. Martin FowlerMartin Fowler http://martinfowler.com/bliki/CodeSmell.html 6
  • 7. 7 Orange restricted Smells To BeSmells To Be RefactoredRefactored 1.Duplicated Code 2.Long Method 3.Large Class 4.Long Parameter List 5.Divergent Change 6.Lazy Class 7.Speculative Generality 8.Temporary Field 9.Data Class 10.Refused Bequest 11.Comments 12.MiddleMan
  • 8. 8 Orange restricted COUPLING ANDCOUPLING AND COHESIONCOHESION  Maximize internal interaction (cohesion) • easier to understand • easier to test  Minimize external interaction (coupling) • can be used independently • easier to test • easier to replace • easier to understand 8
  • 9. 9 Orange restricted 9 Degree of dependence among components No dependencies Loosely coupled-some dependencies Highly coupled-many dependencies
  • 12. 12 Orange restricted • Teams integrate their work multiple times per day. • Each integration is verified by an automated build • Significantly reduces integration problems • Develop cohesive software more rapidly Source: Martin Fowler
  • 13. 13 Orange restricted Five Principles of Continuous Integration • Environments based on stability • Maintain a code repository • Commit frequently and build every commit • Make the build self-testing • Store every build 13
  • 14. 14 Orange restrictedOrange presentation Questions?

Editor's Notes

  • #3: “TDD Intro” Is all code guilty until proven innocent??? can we find out?
  • #8: Duplicated Code :bad because if you modify one instance of duplicated code but not the others, you (may) have introduced a bug! Long Method :long methods are more difficult to understand performance concerns with respect to lots of short methods are largely obsolete Large Class: classes try to do too much, which reduces cohesion Long Parameter List : hard to understand, can become inconsistent Divergent Change: Related to cohesion: symptom: one type of change requires changing one subset of methods; another type of change requires changing another subset Lazy Class : A class that no longer “pays its way” e.g. may be a class that was downsized by a previous refactoring, or represented planned functionality that did not pan out Speculative Generality : “Oh I think we need the ability to do this kind of thing someday” Temporary Field : An attribute of an object is only set in certain circumstances; but an object should need all of its attributes More: http://c2.com/cgi/wiki?CodeSmell http://www.industriallogic.com/wp-content/uploads/2005/09/smellstorefactorings.pdf
  • #11: http://stackoverflow.com/questions/39946/coupling-and-cohesion
  • #14: Environments based on stability Maintain a code repository Commit frequently and build every commit Make the build self-testing Store every build