SlideShare a Scribd company logo
Moving away from
legacy code
with BDD
BDD Evangelist
BDD Practice Manager @Inviqa
Creator of Behat, Mink, PhpSpec2,
Prophecy
Contributor to Symfony2, Composer
@everzet
This talk is about
• Solving purely technical “TCIAM” problem using
behavioural business analysis and discovery process
• Building a delivery strategy on the idea of the
change appreciation
• Real-life experience
This talk is not about
• Greenfield projects
• Maintenance-mode projects
• Solutions for everyone
• How to write code
Legacy projects
How most developers see
their next project
My next
project
My next
project
His actual next
project
Agile, TDD, BDD,
General QA, etc…
// TODO: refactor this
later
Is it really that bad?
If the project can afford at least one full-time
specialist on a payroll that whines how horrible
this project is, then surely it did something right.
// TODO: refactor this
later
// TODO: refactor this
later
// TODO: refactor this
later
This world is full of brilliant projects that nobody
wants to whine about. Sadly, it’s often simply
because there’s no one left to pay for that.
The truth is:
You deliver value!
Just not as effectively as you could
• Great value + Awful code = Great product today
• Great value + Great code = Great product tomorrow
• No value + Any kind of code= Awful product anytime
• Great value + Awful code = Great product today
• Great value + Great code = Great product tomorrow
• No value + Any kind of code= Awful product anytime
// TODO: refactor this
later
Agile, TDD, BDD,
General QA, etc…
How?
Three popular options
1. Rewrite an entire application using “the right way”
2. Do technical refactoring
3. Do business-oriented rewrite using “BDD pipeline”
#1: Full Rewrite
#1: Full Rewrite
• Scrum / Kanban
• TDD / BDD / DDD / Other XP goodness
• New everything
• Mirroring functionality
#1: Income
6 Months later…
#1: Almost there…
#1: Full Rewrite
Just spaghetti, please: 4 man years
Full London meal (TDD, BDD, Agile, QA): ??? man years
#2: Technical Refactoring
#2: Technical Refactoring
• Blackbox testing
• New routing
• New templating system
• Migration of model layer (MySQL -> Mongo)
• Whatever else that is easy to replace
#2: Income
6 Months later…
#2: Ta-da!!!
– Your client. (most likely)
“Exactly what did you do here?”
#3: BDD PIPELINE
AKA Business-Focused rewrite
Why do legacy
projects suck?
Cost
Time
Because of the
cost of change
… Of change where?
Why do
applications change?
Welcome to the
wonderland
of Behaviour Driven Development
Questionnaire
1. Where is this project going?
2. Which features are going to change?
3. How are they going to change?
4. How to support that change?
“BDD Pipeline”
1. Where is this project going?
2. Which features are going to change?
3. How are they going to change?
4. How to support that change?
• Impact Mapping
• Business Prioritisation
• Example (3 Amigos) Workshop
• BDD layers
1. Where is this
project going?
Impact Mapping
– Gojko Adzic
“Impact mapping is a strategic planning technique
that prevents organisations from getting lost
while building products and delivering projects,
by clearly communicating assumptions, helping
teams align their activities with overall business
objectives and make better roadmap decisions.”
Four levels of Impact Map
1. Why? are we doing all this (rewrite)? What is the
goal we’re trying to achieve?
2. Who? will be impacted by it?
3. How? can they help us to achieve the goal?
4. What? can we do to support them?
Moving away from legacy code with BDD
MVP
Product Backlog
Moving away from legacy code with BDD
In order to buy more products
As a customer
I need to have a product autocompletion in the search field
2. Which features are
going to change?
Business Prioritisation
In order to maintain my shopping history
As a site visitor
I need to be able to register on this site
In order to maintain my shopping history
As a site visitor
I need to be able to register on this site
benefit
actor
SELECT s.*
FROM backlog as s
ORDER BY s.role, s.benet
LIMIT 25
3. How are these features
going to change?
Example (3 Amigos) workshops
Three layers of a User-Story
• Business rule(s)
• Communication
• Acceptance criteria
Three layers of a User-Story
• Business rule(s) == Acceptance criteria
• Communication
Three layers of a User-Story
• Business rule(s) == Acceptance criteria
• Communication == Examples
Three layers of a User-Story
• Business rule(s)
• Communication == Examples == Acceptance criteria
In order to keep track of stock
As a store owner
I want to add items back to stock when they are returned
Feature: Returned items go back to stock
Scenario: Refunded items should be returned to stock
In order to keep track of stock
As a store owner
I want to add items back to stock when they are returned
Feature: Returned items go back to stock
Scenario: Replaced items should be returned to stock
Scenario: Refunded items should be returned to stock
In order to keep track of stock
As a store owner
I want to add items back to stock when they are returned
Feature: Returned items go back to stock
Scenario: ...
Scenario: Replaced items should be returned to stock
Scenario: Refunded items should be returned to stock
In order to keep track of stock
As a store owner
I want to add items back to stock when they are returned
Feature: Returned items go back to stock
Scenario: ...
Scenario: ...
Scenario: ...
Scenario: ...
Scenario: ...
Scenario: Replaced items should be returned to stock
Scenario: Refunded items should be returned to stock
In order to keep track of stock
As a store owner
I want to add items back to stock when they are returned
Feature: Returned items go back to stock
Given a customer previously bought a black sweater from me
And I currently have three black sweaters left in stock
When he returns the sweater for a refund
Then I should have four black sweaters in stock
Scenario: Refunded items should be returned to stock
In order to keep track of stock
As a store owner
I want to add items back to stock when they are returned
Feature: Returned items go back to stock
4. How to make it work?
Delivery
Given a customer previously bought a black sweater from me
And I currently have three black sweaters left in stock
When he returns the sweater for a refund
Then I should have four black sweaters in stock
Scenario: Refunded items should be returned to stock
In order to keep track of stock
As a store owner
I want to add items back to stock when they are returned
Feature: Returned items go back to stock
Architectural approaches
1. The Inside job
2. The Bridge
Architectural approach
#1 The Inside job
Step#1: Identify change area
Step#1: Identify old logic
Step#2: Discuss old logic
1. What should this thing do
2. What if it suddenly stops doing it?
3. How would you know if it doesn't work?
4. How would you know if it does?
Step#3: Prepare for A change
1. Cover old behaviour in an end-to-end fashion
2. Make sure that scenarios/tests are green
3. Refactor code to make the upcoming change easier
4. Make scenarios/tests green
Moving away from legacy code with BDD
Step#4: Make a change
1. Automate new scenarios
2. Make scenarios green by applying BDD loops
Stories
Examples
Describe
Implement
Design
Architectural approach
#2 The bridge
Legacy system
Infrastructure
[GET] /products
Legacy system
Infrastructure
[GET] /products
[GET] /products/123
Legacy system
Infrastructure
[GET] /products
[GET] /products/123
New system
Legacy system
Infrastructure
[GET] /products
[GET] /products/123
New system
New system
Step#0: Prepare for any change
1. Prepare the application infrastructure for bridging
a. Share sessions
b. Share data
2. Prepare the server infrastructure for bridging
Step#1: Make a change
1. Automate new scenarios
2. Make scenarios green by applying BDD loops
#3: Income
6 months later…
#3: Same ashtrays, better car
Stop dreaming of a greater code
Find a way to deliver a greater value
We do that for clients
And coach / train others how to do it
http:// .com
Thank you!
@everzet

More Related Content

PDF
Being effective with legacy projects
PPTX
User Story Workshop
PDF
Specification by example - course summary
PDF
Rupicon2014 useful design patterns in rails
PDF
Min-Maxing Software Costs
PDF
Modern Agile Project Toolbox
PDF
Decoupling with Design Patterns and Symfony2 DIC
PDF
Moving away from legacy code (AgileCymru)
Being effective with legacy projects
User Story Workshop
Specification by example - course summary
Rupicon2014 useful design patterns in rails
Min-Maxing Software Costs
Modern Agile Project Toolbox
Decoupling with Design Patterns and Symfony2 DIC
Moving away from legacy code (AgileCymru)

Viewers also liked (9)

PDF
Taking back BDD
PDF
BDD by example
PDF
Enabling agile devliery through enabling BDD in PHP projects
PDF
Modern Project Toolbox
PDF
BDD в PHP с Behat и Mink
PDF
BDD для PHP проектов
PDF
Bridging The Communication Gap, Fast
PDF
Moving away from legacy code with BDD
PDF
Design how your objects talk through mocking
Taking back BDD
BDD by example
Enabling agile devliery through enabling BDD in PHP projects
Modern Project Toolbox
BDD в PHP с Behat и Mink
BDD для PHP проектов
Bridging The Communication Gap, Fast
Moving away from legacy code with BDD
Design how your objects talk through mocking
Ad

Similar to Moving away from legacy code with BDD (20)

PPTX
Руслан Плахута - Внедрение BDD в распределенные команды
PPTX
Prashant technical practices-tdd for xebia event
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
PDF
Disciplined Entrepreneurship: How Do You Design And Build Your Product? How D...
PPTX
Refactoring Legacy Code - true story
PPTX
Agile Israel 2017 bugs zero by Arlo Belshee
PPTX
Leading Your Business Customer
PPTX
Converting Your Legacy Data to S1000D
PDF
MongoDB .local Bengaluru 2019: A Complete Methodology to Data Modeling for Mo...
PPTX
Refactor your code: when, why and how (revisited)
PPTX
User Story Splitting.pptx
PDF
Embrace Community! Embrace a better life!
PDF
Patterns of the Lambda Architecture -- 2015 April - Hadoop Summit, Europe
PDF
Good Coding Practices with JavaScript
PDF
#lego4scrum with Large-Scale Scrum (LeSS)
PDF
The benefits of using Git
PPT
Kanban highlights
PPTX
Constantly Contributing Pretty Patches FLCD
PPTX
Design patterns
PPTX
Lecture_four-_Requirements_Modeling (1).pptx
Руслан Плахута - Внедрение BDD в распределенные команды
Prashant technical practices-tdd for xebia event
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
Disciplined Entrepreneurship: How Do You Design And Build Your Product? How D...
Refactoring Legacy Code - true story
Agile Israel 2017 bugs zero by Arlo Belshee
Leading Your Business Customer
Converting Your Legacy Data to S1000D
MongoDB .local Bengaluru 2019: A Complete Methodology to Data Modeling for Mo...
Refactor your code: when, why and how (revisited)
User Story Splitting.pptx
Embrace Community! Embrace a better life!
Patterns of the Lambda Architecture -- 2015 April - Hadoop Summit, Europe
Good Coding Practices with JavaScript
#lego4scrum with Large-Scale Scrum (LeSS)
The benefits of using Git
Kanban highlights
Constantly Contributing Pretty Patches FLCD
Design patterns
Lecture_four-_Requirements_Modeling (1).pptx
Ad

Recently uploaded (20)

PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
August Patch Tuesday
 
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Machine learning based COVID-19 study performance prediction
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Tartificialntelligence_presentation.pptx
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
August Patch Tuesday
 
NewMind AI Weekly Chronicles - August'25-Week II
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
cloud_computing_Infrastucture_as_cloud_p
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A comparative analysis of optical character recognition models for extracting...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Approach and Philosophy of On baking technology
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Machine learning based COVID-19 study performance prediction
SOPHOS-XG Firewall Administrator PPT.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Tartificialntelligence_presentation.pptx
OMC Textile Division Presentation 2021.pptx
Encapsulation_ Review paper, used for researhc scholars
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...

Moving away from legacy code with BDD