SlideShare a Scribd company logo
1 of 27
BDD + Lambdaj
Andreas Enbohm, Capgemini
@enbohm
BDD
• Behavior-driven development (BDD) is an
increasingly popular variation on test-driven
development, which helps developers think
more in terms of “executable specifications”
than in terms of conventional tests
Why use BDD?
• Only build feature that add real value
• Less wasted effort
• Better communication
• Higher quality, better tested product
• Traceability
BDD
• BDD describes TDD done well
- removes word ’test’
- replace it with
behaviour, examples, scenarios etc.
• Good habits;
1. Working outside-in
2. Using examples to clarify requirements
(scenarios)
3. Using a common (ubiquitous) language
BDD – Value Driven
• A good goal should add value to business
- increase revenue
- reduce cost
- avoid future cost
- protect revenue
”Increase revenue by allowing
customers to…”
”Prevent current customers
switching to competing product
by …”
BDD – What Does the Customer Need?
• Good teams push back!
- users tend to express requirements as implementations
- we need to find the business need!
We need caching
Why?
So that the page
loads fast
So that the
customer will buy
stuff on our site and
doesn’t leave page
Why?
Ok, so to increase the chance a customer
will buy [stuff] it need to be ’fast’. Caching
might be one way to achive this, but
compressing images might be more
effective. Or another way might be
loaders, or ..
BDD – Better understanding
• Working outside-in
- if you need to explain to a computer how to check the
requirement, you’ll need to be damn sure understand it
yourself
• Business black-box testing is often done manually!
- BDD enables automated acceptance testing
• Mininum effort /code to fulfull requirement
BDD – Common Language
• Common Language
- communication often the biggest overhead
- even bigger if you allow different dialects of terminology
- takes time but gains significant advantage
BDD
BDD
BDD - Stories
Story: Basic Purchase flow - User purchases a Grundpaket (id 21)
Narrative:
In order to attract new CDK customers
As a leading channel reseller
I want to provide an easy way to buy our products through our website
Goal come first
Stakeholder is
secondary
The feature must be
required to achieve this
goal
BDD - Scenarios
• The ’perfect’ bridge between the business-
facing and technology-facing sides of a team
Scenario: User selects a channel package for purchase (id 21.2)
Given address search is done with address street Hantverkaregatan streetNo 28 and city
Helsingborg on page url http://...
When user select totalpaketet by clicking on choose button
Then the user starts a purchase flow where the first step is called Grundpaket och box is
shown
Common language which is
reflected all way down in the
code
BDD - Java
• CDK use Jbehave
- lots of documentation
- uses Gherkin language
BDD - Implementation
BDD – CDK Implementation
• No stories/scenarion from start
- Emma wrote a lot of BDD stories
- used by CDK as ’lightweight’ acceptance test
• Selenium
- browser automation
• Spring as embedded runner
- gives us DI
• Page template patterns (see code)
BDD – CDK Implementation
• Pros
- another way of thinking of test
- sentence instead of test (even for our Junit
tests)
- we could make our major refactoring with
confidence
• Cons
- selenium (engines)
- issus/bugs with JBehave (fetching
parameters, mapping to POJO)
- we should not come up with the goal
BDD
• Reports show 75%* less bugs and 30%* faster
to production
Lambdaj
• An internal DSL to manipulate collections
without loops
• Large part of business logic is always the
same; iteration over collections of business
objects to do a set of tasks
• Loops (especially nested and mixed with
conditions) are hard to read that to be written
• for loop is inherently serial
Lambdaj
• Business logic should be less technical and
closer to business fashion
Lambdaj
• Iterate over collections in order to:
- select
- aggregate
- sort
- filter
- group
- extract
- and more..
Lambdaj - Sort
List<Person> sortedByAgePersons = sort(persons, on(Person.class).getAge());
List<Person> sortedByAgePersons = new ArrayList<Person>(persons);
Collections.sort(sortedByAgePersons, new Comparator<Person>() {
public int compare(Person p1, Person p2) {
return Integer.valueOf(p1.getAge()).compareTo(p2.getAge());
}
});
Old Java style
Lambdaj
Lambdaj - Select
List<Sale> sales = select(sales, having(on(Sale.class).getBuyer(),
equalTo(selectMin(persons, on(Person.class).getAge()))));
Person youngest = null;
for (Person person : persons)
if (youngest == null || person.getAge() < youngest.getAge())
youngest = person;
List<Sale> buys = new ArrayList<Sale>();
for (Sale sale : sales)
if (sale.getBuyer().equals(youngest))
buys.add(sale);
Old Java style
Lambdaj
Lambdaj - Sum
Integer totalSumForStandaloneChannels =
sum(standaloneChannels,on(TvChannel.class).getPrice().getMonthlyFee());
Integer totalSumForStandaloneChannels = 0;
for (TvChannel channel: standaloneChannels) {
totalSumForStandaloneChannels += channel.getPrice.getMonthlyFee()
}
Old Java style
Lambdaj
Lambdaj - Group
Group<ChannelPackage> mutuallyExclusiveGroup =
group(selectedAddonPackages,
by(on(AddonChannelPackage.class).getGroup().getType()),
by(on(AddonChannelPackage.class).getGroup().getName()));
Don’t bother….
Old Java style
Lambdaj
Lambdaj - Index
Map<String, Car> carsByBrand = index(cars, on(Car.class).getBrand());
Map<String, Car> carsByBrand = new HashMap<String, Car>();
for (Car car : db.getCars())
carsByBrand.put(car.getBrand(), car);
Old Java style
Lambdaj
Lambdaj – Bulk Operations
List<Person> personInFamily = asList(new
Person(“Chuck"), new Person(“Lone Wolf"));
forEach(personInFamily).setLastName(“Norris");
Lambdaj - Closures
• Lambdaj Closures
Closure println = closure(); {
of(System.out).println(var(String.class));
}
//invoked by "closing" its free variable once:
println.apply("one");
//or more times:
println.each("one", "two", "three");

More Related Content

What's hot

A Guide To Offshore Development Center Set Up by Gramener Digital
A Guide To Offshore Development Center Set Up by Gramener DigitalA Guide To Offshore Development Center Set Up by Gramener Digital
A Guide To Offshore Development Center Set Up by Gramener DigitalCannyfore
 
Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd Sakares Saengkaew
 
Job-to-be-done theory to practice : Ch4 Process
Job-to-be-done theory to practice : Ch4 ProcessJob-to-be-done theory to practice : Ch4 Process
Job-to-be-done theory to practice : Ch4 ProcessPRADA Hsiung
 
EDD Management Services Deck
EDD Management Services DeckEDD Management Services Deck
EDD Management Services Deckbhupenderpratap
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)Rohit Bisht
 
Minimum Viable Replacement: April 25, 2021
Minimum Viable Replacement: April 25, 2021Minimum Viable Replacement: April 25, 2021
Minimum Viable Replacement: April 25, 2021kevinjmireles
 
Offshore development center (odc) setup up by faichi solutions - Case Study
Offshore development center (odc) setup up by faichi solutions - Case StudyOffshore development center (odc) setup up by faichi solutions - Case Study
Offshore development center (odc) setup up by faichi solutions - Case StudyFaichi Solutions
 
How to successfully execute fixed price agile projects
How to successfully execute fixed price agile projectsHow to successfully execute fixed price agile projects
How to successfully execute fixed price agile projectsKaty Slemon
 

What's hot (10)

A Guide To Offshore Development Center Set Up by Gramener Digital
A Guide To Offshore Development Center Set Up by Gramener DigitalA Guide To Offshore Development Center Set Up by Gramener Digital
A Guide To Offshore Development Center Set Up by Gramener Digital
 
Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd
 
Job-to-be-done theory to practice : Ch4 Process
Job-to-be-done theory to practice : Ch4 ProcessJob-to-be-done theory to practice : Ch4 Process
Job-to-be-done theory to practice : Ch4 Process
 
EDD Management Services Deck
EDD Management Services DeckEDD Management Services Deck
EDD Management Services Deck
 
Behavior driven development (bdd)
Behavior driven development (bdd)Behavior driven development (bdd)
Behavior driven development (bdd)
 
Minimum Viable Replacement: April 25, 2021
Minimum Viable Replacement: April 25, 2021Minimum Viable Replacement: April 25, 2021
Minimum Viable Replacement: April 25, 2021
 
Offshore development center (odc) setup up by faichi solutions - Case Study
Offshore development center (odc) setup up by faichi solutions - Case StudyOffshore development center (odc) setup up by faichi solutions - Case Study
Offshore development center (odc) setup up by faichi solutions - Case Study
 
FlexPod and Enterprise IT
FlexPod and Enterprise ITFlexPod and Enterprise IT
FlexPod and Enterprise IT
 
How to successfully execute fixed price agile projects
How to successfully execute fixed price agile projectsHow to successfully execute fixed price agile projects
How to successfully execute fixed price agile projects
 
Odc setup
Odc setupOdc setup
Odc setup
 

Similar to Behavior-driven Development and Lambdaj

Building In Quality: The Beauty Of Behavior Driven Development (BDD)
Building In Quality: The Beauty Of Behavior Driven Development (BDD)Building In Quality: The Beauty Of Behavior Driven Development (BDD)
Building In Quality: The Beauty Of Behavior Driven Development (BDD)Synerzip
 
BA and Beyond 20 - Elke Steegmans and David Vandenbroeck - Behaviour-driven d...
BA and Beyond 20 - Elke Steegmans and David Vandenbroeck - Behaviour-driven d...BA and Beyond 20 - Elke Steegmans and David Vandenbroeck - Behaviour-driven d...
BA and Beyond 20 - Elke Steegmans and David Vandenbroeck - Behaviour-driven d...BA and Beyond
 
Topic tdd-and-bdd b4usolution
Topic tdd-and-bdd b4usolutionTopic tdd-and-bdd b4usolution
Topic tdd-and-bdd b4usolutionHoa Le
 
DRUPAL AUDITS MADE FASTR
DRUPAL AUDITS MADE FASTRDRUPAL AUDITS MADE FASTR
DRUPAL AUDITS MADE FASTRDrupalCamp Kyiv
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDDKonstantin Kudryashov
 
Agile acceptance testing with f sharp
Agile acceptance testing with f sharpAgile acceptance testing with f sharp
Agile acceptance testing with f sharpSkills Matter
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introductionwojtek_s
 
L’architettura di Classe Enterprise di Nuova Generazione
L’architettura di Classe Enterprise di Nuova GenerazioneL’architettura di Classe Enterprise di Nuova Generazione
L’architettura di Classe Enterprise di Nuova GenerazioneMongoDB
 
Model Driven Architectures
Model Driven ArchitecturesModel Driven Architectures
Model Driven ArchitecturesLalit Kale
 
Making the Move to Behavior Driven Development
Making the Move to Behavior Driven DevelopmentMaking the Move to Behavior Driven Development
Making the Move to Behavior Driven DevelopmentQASymphony
 
Myths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentMyths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentPankaj Nakhat
 
Converting Your Legacy Data to S1000D
Converting Your Legacy Data to S1000DConverting Your Legacy Data to S1000D
Converting Your Legacy Data to S1000Ddclsocialmedia
 
German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...Bastian Seehaus
 
Challenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop EngineChallenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop EngineNicolas Morales
 
Canadian Experts Discuss Modern Data Stacks and Cloud Computing for 5 Years o...
Canadian Experts Discuss Modern Data Stacks and Cloud Computing for 5 Years o...Canadian Experts Discuss Modern Data Stacks and Cloud Computing for 5 Years o...
Canadian Experts Discuss Modern Data Stacks and Cloud Computing for 5 Years o...Daniel Zivkovic
 
Challenges of Implementing an Advanced SQL Engine on Hadoop
Challenges of Implementing an Advanced SQL Engine on HadoopChallenges of Implementing an Advanced SQL Engine on Hadoop
Challenges of Implementing an Advanced SQL Engine on HadoopDataWorks Summit
 

Similar to Behavior-driven Development and Lambdaj (20)

Building In Quality: The Beauty Of Behavior Driven Development (BDD)
Building In Quality: The Beauty Of Behavior Driven Development (BDD)Building In Quality: The Beauty Of Behavior Driven Development (BDD)
Building In Quality: The Beauty Of Behavior Driven Development (BDD)
 
BA and Beyond 20 - Elke Steegmans and David Vandenbroeck - Behaviour-driven d...
BA and Beyond 20 - Elke Steegmans and David Vandenbroeck - Behaviour-driven d...BA and Beyond 20 - Elke Steegmans and David Vandenbroeck - Behaviour-driven d...
BA and Beyond 20 - Elke Steegmans and David Vandenbroeck - Behaviour-driven d...
 
Topic tdd-and-bdd b4usolution
Topic tdd-and-bdd b4usolutionTopic tdd-and-bdd b4usolution
Topic tdd-and-bdd b4usolution
 
DRUPAL AUDITS MADE FASTR
DRUPAL AUDITS MADE FASTRDRUPAL AUDITS MADE FASTR
DRUPAL AUDITS MADE FASTR
 
Moving away from legacy code with BDD
Moving away from legacy code with BDDMoving away from legacy code with BDD
Moving away from legacy code with BDD
 
Agile acceptance testing with f sharp
Agile acceptance testing with f sharpAgile acceptance testing with f sharp
Agile acceptance testing with f sharp
 
Dataweek-Talk-2014
Dataweek-Talk-2014Dataweek-Talk-2014
Dataweek-Talk-2014
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Creo GD&T 5
Creo GD&T 5Creo GD&T 5
Creo GD&T 5
 
L’architettura di Classe Enterprise di Nuova Generazione
L’architettura di Classe Enterprise di Nuova GenerazioneL’architettura di Classe Enterprise di Nuova Generazione
L’architettura di Classe Enterprise di Nuova Generazione
 
Behavior-Driven Development with JGiven
Behavior-Driven Development with JGivenBehavior-Driven Development with JGiven
Behavior-Driven Development with JGiven
 
Model Driven Architectures
Model Driven ArchitecturesModel Driven Architectures
Model Driven Architectures
 
Making the Move to Behavior Driven Development
Making the Move to Behavior Driven DevelopmentMaking the Move to Behavior Driven Development
Making the Move to Behavior Driven Development
 
Domain Driven Design
Domain Driven Design Domain Driven Design
Domain Driven Design
 
Myths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentMyths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven Development
 
Converting Your Legacy Data to S1000D
Converting Your Legacy Data to S1000DConverting Your Legacy Data to S1000D
Converting Your Legacy Data to S1000D
 
German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...
 
Challenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop EngineChallenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop Engine
 
Canadian Experts Discuss Modern Data Stacks and Cloud Computing for 5 Years o...
Canadian Experts Discuss Modern Data Stacks and Cloud Computing for 5 Years o...Canadian Experts Discuss Modern Data Stacks and Cloud Computing for 5 Years o...
Canadian Experts Discuss Modern Data Stacks and Cloud Computing for 5 Years o...
 
Challenges of Implementing an Advanced SQL Engine on Hadoop
Challenges of Implementing an Advanced SQL Engine on HadoopChallenges of Implementing an Advanced SQL Engine on Hadoop
Challenges of Implementing an Advanced SQL Engine on Hadoop
 

More from Andreas Enbohm

More from Andreas Enbohm (8)

Hybrid Applications
Hybrid ApplicationsHybrid Applications
Hybrid Applications
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Java7 - Top 10 Features
Java7 - Top 10 FeaturesJava7 - Top 10 Features
Java7 - Top 10 Features
 
Java Extension Methods
Java Extension MethodsJava Extension Methods
Java Extension Methods
 
Scala
ScalaScala
Scala
 
Project Lambda - Closures after all?
Project Lambda - Closures after all?Project Lambda - Closures after all?
Project Lambda - Closures after all?
 
Fest
FestFest
Fest
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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 DevelopmentsTrustArc
 
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 WorkerThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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...Martijn de Jong
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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...Igalia
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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 Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 

Behavior-driven Development and Lambdaj

  • 1. BDD + Lambdaj Andreas Enbohm, Capgemini @enbohm
  • 2. BDD • Behavior-driven development (BDD) is an increasingly popular variation on test-driven development, which helps developers think more in terms of “executable specifications” than in terms of conventional tests
  • 3. Why use BDD? • Only build feature that add real value • Less wasted effort • Better communication • Higher quality, better tested product • Traceability
  • 4. BDD • BDD describes TDD done well - removes word ’test’ - replace it with behaviour, examples, scenarios etc. • Good habits; 1. Working outside-in 2. Using examples to clarify requirements (scenarios) 3. Using a common (ubiquitous) language
  • 5. BDD – Value Driven • A good goal should add value to business - increase revenue - reduce cost - avoid future cost - protect revenue ”Increase revenue by allowing customers to…” ”Prevent current customers switching to competing product by …”
  • 6. BDD – What Does the Customer Need? • Good teams push back! - users tend to express requirements as implementations - we need to find the business need! We need caching Why? So that the page loads fast So that the customer will buy stuff on our site and doesn’t leave page Why? Ok, so to increase the chance a customer will buy [stuff] it need to be ’fast’. Caching might be one way to achive this, but compressing images might be more effective. Or another way might be loaders, or ..
  • 7. BDD – Better understanding • Working outside-in - if you need to explain to a computer how to check the requirement, you’ll need to be damn sure understand it yourself • Business black-box testing is often done manually! - BDD enables automated acceptance testing • Mininum effort /code to fulfull requirement
  • 8. BDD – Common Language • Common Language - communication often the biggest overhead - even bigger if you allow different dialects of terminology - takes time but gains significant advantage
  • 9. BDD
  • 10. BDD
  • 11. BDD - Stories Story: Basic Purchase flow - User purchases a Grundpaket (id 21) Narrative: In order to attract new CDK customers As a leading channel reseller I want to provide an easy way to buy our products through our website Goal come first Stakeholder is secondary The feature must be required to achieve this goal
  • 12. BDD - Scenarios • The ’perfect’ bridge between the business- facing and technology-facing sides of a team Scenario: User selects a channel package for purchase (id 21.2) Given address search is done with address street Hantverkaregatan streetNo 28 and city Helsingborg on page url http://... When user select totalpaketet by clicking on choose button Then the user starts a purchase flow where the first step is called Grundpaket och box is shown Common language which is reflected all way down in the code
  • 13. BDD - Java • CDK use Jbehave - lots of documentation - uses Gherkin language
  • 15. BDD – CDK Implementation • No stories/scenarion from start - Emma wrote a lot of BDD stories - used by CDK as ’lightweight’ acceptance test • Selenium - browser automation • Spring as embedded runner - gives us DI • Page template patterns (see code)
  • 16. BDD – CDK Implementation • Pros - another way of thinking of test - sentence instead of test (even for our Junit tests) - we could make our major refactoring with confidence • Cons - selenium (engines) - issus/bugs with JBehave (fetching parameters, mapping to POJO) - we should not come up with the goal
  • 17. BDD • Reports show 75%* less bugs and 30%* faster to production
  • 18. Lambdaj • An internal DSL to manipulate collections without loops • Large part of business logic is always the same; iteration over collections of business objects to do a set of tasks • Loops (especially nested and mixed with conditions) are hard to read that to be written • for loop is inherently serial
  • 19. Lambdaj • Business logic should be less technical and closer to business fashion
  • 20. Lambdaj • Iterate over collections in order to: - select - aggregate - sort - filter - group - extract - and more..
  • 21. Lambdaj - Sort List<Person> sortedByAgePersons = sort(persons, on(Person.class).getAge()); List<Person> sortedByAgePersons = new ArrayList<Person>(persons); Collections.sort(sortedByAgePersons, new Comparator<Person>() { public int compare(Person p1, Person p2) { return Integer.valueOf(p1.getAge()).compareTo(p2.getAge()); } }); Old Java style Lambdaj
  • 22. Lambdaj - Select List<Sale> sales = select(sales, having(on(Sale.class).getBuyer(), equalTo(selectMin(persons, on(Person.class).getAge())))); Person youngest = null; for (Person person : persons) if (youngest == null || person.getAge() < youngest.getAge()) youngest = person; List<Sale> buys = new ArrayList<Sale>(); for (Sale sale : sales) if (sale.getBuyer().equals(youngest)) buys.add(sale); Old Java style Lambdaj
  • 23. Lambdaj - Sum Integer totalSumForStandaloneChannels = sum(standaloneChannels,on(TvChannel.class).getPrice().getMonthlyFee()); Integer totalSumForStandaloneChannels = 0; for (TvChannel channel: standaloneChannels) { totalSumForStandaloneChannels += channel.getPrice.getMonthlyFee() } Old Java style Lambdaj
  • 24. Lambdaj - Group Group<ChannelPackage> mutuallyExclusiveGroup = group(selectedAddonPackages, by(on(AddonChannelPackage.class).getGroup().getType()), by(on(AddonChannelPackage.class).getGroup().getName())); Don’t bother…. Old Java style Lambdaj
  • 25. Lambdaj - Index Map<String, Car> carsByBrand = index(cars, on(Car.class).getBrand()); Map<String, Car> carsByBrand = new HashMap<String, Car>(); for (Car car : db.getCars()) carsByBrand.put(car.getBrand(), car); Old Java style Lambdaj
  • 26. Lambdaj – Bulk Operations List<Person> personInFamily = asList(new Person(“Chuck"), new Person(“Lone Wolf")); forEach(personInFamily).setLastName(“Norris");
  • 27. Lambdaj - Closures • Lambdaj Closures Closure println = closure(); { of(System.out).println(var(String.class)); } //invoked by "closing" its free variable once: println.apply("one"); //or more times: println.each("one", "two", "three");