Test Driven Design

46
TEST DRIVEN DESIGN LEMi ORHAN ERGiN software craftsman @ acm

Transcript of Test Driven Design

Page 1: Test Driven Design

TEST DRIVENDESIGN

LEMi ORHAN ERGiNsoftware craftsman @ acm

Page 2: Test Driven Design

DESIGN LEMi ORHAN ERGiNagile software craftsman @ acm

/lemiorhan lemiorhanergin.com @lemiorhan

managing partner at acm developing since 2001

worked at Sony and eBay/GittiGidiyor consultant, architect, trainer, developer

founder of Software Craftsmanship Turkey ex product owner of Agile Turkey Summit

meetup.scturkey.org summit.agileturkey.org

Page 3: Test Driven Design

Jack W. Reeves

The C++ Journal Vol. 2, No. 2. 1992http://user.it.uu.se/~carle/softcraft/notes/Reeve_SourceCodeIsTheDesign.pdf

What is So!ware Design?

Page 4: Test Driven Design

Source code is the real so!ware designDesigning so!ware is an exercise in managing complexity

Jack W. ReevesWhat is Software Design? The C++ Journal Vol. 2, No. 2. 1992http://user.it.uu.se/~carle/softcraft/notes/Reeve_SourceCodeIsTheDesign.pdf

Page 5: Test Driven Design

The so!ware design is not complete until it has been coded and testedTesting is part of the process of refining the design

Jack W. ReevesWhat is Software Design? The C++ Journal Vol. 2, No. 2. 1992http://user.it.uu.se/~carle/softcraft/notes/Reeve_SourceCodeIsTheDesign.pdf

Page 6: Test Driven Design

ProgrammingSource Code

SOFTWARE DESIGN

Test andVerification

Page 7: Test Driven Design

The very first value of so!ware is…

Robert C. MartinAuthor of Clean Code and Clean CoderOwner of cleancoders.com training site

Page 8: Test Driven Design

The very first value of so!ware is to tolerate and facilitate on-going changes

Robert C. MartinAuthor of Clean Code and Clean CoderOwner of cleancoders.com training site

Page 9: Test Driven Design

Each city has to be renewed in order to meet the needs of its populace. So!ware-intensive systems are like that.

Grady Booch

Developed UMLWrote foreword to “Design Patterns” and “Technical Debt” books

Istanbul, TurkeyCredit: European Space Imaging

Page 10: Test Driven Design

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

Test andVerification

Page 11: Test Driven Design

Everything is part of the design process

Jack W. ReevesWhat is Software Design? The C++ Journal Vol. 2, No. 2. 1992http://user.it.uu.se/~carle/softcraft/notes/Reeve_SourceCodeIsTheDesign.pdf

Page 12: Test Driven Design

but… we develop

without driving

the design

Page 13: Test Driven Design

nebulaconcepts and terminology trigger ideas about the design

what we really do in general…

Page 14: Test Driven Design

proto-starinitial classes containing the logic

simple structure, basic domain model and behaviors

Page 15: Test Driven Design

brown dwarfbasic dependencies, works as we expect

utility classes start to occur

Page 16: Test Driven Design

main sequence starneedless complexity starts, a lot of inter-dependencies

manual testing starts to take longer time than usual

Page 17: Test Driven Design

hard to add new features too much debugging

too many workarounds too complex to know every flow

red giant

Page 18: Test Driven Design

blue-white super giant

single change affects many areas, no reuse - duplication hell,

fragile system - unstable prod scary refactoring,

silos occur

Page 19: Test Driven Design

red super gianthuge classes, tons of workarounds, no new features, maintenance mode rules, basic implementations take weeks, no one knows how overall system works, rollbacks a!er deployments, architect saves the company

Page 20: Test Driven Design
Page 21: Test Driven Design
Page 22: Test Driven Design

supernovaemployee turnovers,

frustrated management, blame & fight

Page 23: Test Driven Design

black holedeadly loop of total rewrite or exit from the market

Page 24: Test Driven Design

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

Test andVerification

Page 25: Test Driven Design

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

good?

Test andVerification

Page 26: Test Driven Design

COUPLINGWhen readfile() is changed, do you change writeFile() too? It shows how many places we need to change

Page 27: Test Driven Design

Two elements are loosely coupled if they are not shown in the same diff

Kent BeckThe creator of extreme programmingOne of the signatories of the Agile ManifestoPioneered software design patterns and TDD

Page 28: Test Driven Design

COHESIONDo you search a lot where to change? It shows how easy to find the places we need to change

Page 29: Test Driven Design

How many files at any one time is still open for edit shows the level of cohesion

Nat PryceCo-Author of Growing Object-Oriented Software Guided by TestsEarly adopter of XP

Page 30: Test Driven Design

ProgrammingSource Code

SOFTWARE DESIGN

RefactoringLow Coupling

Test andVerification

High Cohesion

Page 31: Test Driven Design

ProgrammingSource Code

SOFTWARE DESIGN

Refactoring

is hard and needs discipline!Test andVerification

Test Driven

High CohesionLow Coupling

Page 32: Test Driven Design

ProgrammingSource Code

Test andVerification

SOFTWARE DESIGN

Refactoring

Test Driven

High CohesionLow Coupling

Page 33: Test Driven Design

ProgrammingSource Code

Test andVerification

SOFTWARE DESIGN

Refactoring

Test Driven

High CohesionLow Coupling

Page 34: Test Driven Design

ProgrammingSource Code

Test andVerification

SOFTWARE DESIGN

Refactoring

Test Driven

High CohesionLow Coupling

Page 35: Test Driven Design

ProgrammingSource Code

Test andVerification

SOFTWARE DESIGN

Refactoring

Test Driven

High CohesionLow Coupling

Page 36: Test Driven Design

ProgrammingSource Code

Test andVerification

SOFTWARE DESIGN

Refactoring

Test Driven

High CohesionLow Coupling

Page 37: Test Driven Design

ProgrammingSource Code

Test andVerification

SOFTWARE DESIGN

Refactoring

Test Driven

High CohesionLow Coupling

Page 38: Test Driven Design

ProgrammingSource Code

Test andVerification

SOFTWARE DESIGN

Refactoring

Test Driven

High CohesionLow Coupling

Page 39: Test Driven Design

ProgrammingSource Code

Test andVerification

SOFTWARE DESIGN

Refactoring

Test Driven

High CohesionLow Coupling

Page 40: Test Driven Design

Unit testing frameworks Mocking frameworks Automated testing types Design principles Refactoring techniques Clean code principles

LEARN

Continuous Integration Source code versioning Notification mechanism Code coverage monitoring

Practice TDD via katas Develop via TDD Acceptance testing via TDD Verify by behaviours via BDD

ESTABLISH

PERFORM

Page 41: Test Driven Design

Unit testing frameworks Mocking frameworks Automated testing types Design principles Refactoring techniques Clean code principles

LEARN

Continuous Integration Source code versioning Notification mechanism Code coverage monitoring

Practice TDD via katas Develop via TDD Acceptance testing via TDD Verify by behaviours via BDD

ESTABLISH

PERFORM

Page 42: Test Driven Design

Unit testing frameworks Mocking frameworks Automated testing types Design principles Refactoring techniques Clean code principles

LEARN

Continuous Integration Source code versioning Notification mechanism Code coverage monitoring

Practice TDD via katas Develop via TDD Acceptance testing via TDD Verify by behaviours via BDD

ESTABLISH

PERFORM

Page 43: Test Driven Design

Unit testing frameworks Mocking frameworks Automated testing types Design principles Refactoring techniques Clean code principles

LEARN

Continuous Integration Source code versioning Notification mechanism Code coverage monitoring

Practice TDD via katas Develop via TDD Acceptance testing via TDD Verify by behaviours via BDD

ESTABLISH

PERFORM

Page 44: Test Driven Design

small set of entities few lines in methods

follows OOP design guidelines simple design, names are the intensions

marbles

Page 45: Test Driven Design

If you really want to see something interesting:)

ursa minor and polaris

LEMi ORHAN ERGiN

Page 46: Test Driven Design

LEMi ORHAN ERGiNagile software craftsman @ acm

/lemiorhan lemiorhanergin.com @lemiorhan