SlideShare a Scribd company logo
1 of 61
Download to read offline
DDD with Behat 
by Anton Serdyuk
Agile project and team evolution 
1 2 3 4 5 6
1. No tests at all 
● You can write very good code, but this code 
WILL suck later 
● “Refactoring” is a swearword 
● That is why constant “No time for 
refactoring” 
● “We need to rewrite it from scratch” at the 
end 
1 2 3 4 5 6
2. So called “Unittests” 
● Not actual unittests 
● xUnit based tests for controllers, entities, 
repositories etc without any order 
● Complex fixtures 
● Hard to support 
● “There is no time for tests” because of no 
visible profit 
1 2 3 4 5 6
3. Selenium acceptance tests 
● Written by QA automators usually in Java 
even in PHP and .NET projects 
● This approach is widely spread, well known 
and may perform well, but I think autotests 
implementation is not a QA job 
1 2 3 4 5 6
4. Behat acceptance tests 
● This approach may perform very well 
● Can be written by QA (and even sometimes by BA) 
● Some people call it BDD, but it is not BDD actually 
Given there is registered user Bob 
And I am on homepage 
When I follow “Sign Up” 
And I fill “Bob” in “Username” 
And I press “Sign Up” 
Then I should see “This username is already in use” 
1 2 3 4 5 6
5. BDD 
● BDD is not about tests 
● It is the process of finding out and delivering features 
which provide value to users 
● Should be used not only in dev team but in whole team 
beginning from Product Owner 
Given there is registered user Bob 
When I try to sign up with username “Bob” 
Then I should get error that this user is already signed up 
1 2 3 4 5 6
6. Lean 
● The last point of Agile team and project 
journey 
● It is all about how to deliver more value to 
customer and how to build sustainable 
business around this product 
1 2 3 4 5 6
4,5. DDD with Behat 
● Not a BDD yet 
● Not just acceptance tests with Behat 
BDD 
Behat 
acceptance 
tests 
DDD with 
Behat
Functional tests with Behat 
https://github.com/diaspora/diaspora/blob/develop/features/desktop/change_email.feature
They are really cool 
● Provide Continuous Integration and 
Continuous Delivery possibility 
● Easy to write 
● Can be written by QA and even sometimes 
by BA
But... 
● Long execution time 
○ Less green builds 
○ Wasted developers’ time 
● Non-deterministic failures 
○ Developers try to rebuild every failing build instead 
of investigating 
○ Wasted developers’ time
But... 
● They are too specific 
○ It is difficult to dig up business value from them 
○ less benefits for use by (and with) business people 
(BA, Product Owner)
DDD can help
Model 
Model is a system of abstractions that 
describes selected aspects of a domain and 
can be used to solve problems related to this 
domain 
http://www.infoq.com/presentations/model-to-work-evans
Ubiquitous Language 
A language structured around the domain 
model and used by all team members to 
connect all the activities of the team with the 
software 
http://www.infoq.com/presentations/model-to-work-evans
Ubiquitous Language helps to find 
out model weaknesses 
If domain expert does not understand you when 
you use ubiquitous language, then your model 
does not describe domain as needed and 
should be corrected.
Multilayered Architecture 
http://dddsample.sourceforge.net/architecture.html
Layers in typical symfony2 project 
● Infrastructure 
○ Doctrine 
○ SwiftMailer 
● UI 
○ views 
○ JS 
● Application 
○ controllers 
○ some services 
● Domain 
○ entities
Entities are not enough to 
create a powerful domain 
model
Domain Model 
● Domain model is just Plain Old PHP Objects. 
● Framework-agnostic
Domain Model 
At its worst business logic can be very 
complex. Rules and logic describe many 
different cases and slants of behavior, and it's 
this complexity that objects were designed to 
work with. A Domain Model creates a web of 
interconnected objects, where each object 
represents some meaningful individual, 
whether as large as a corporation or as small 
as a single line on an order form. 
http://martinfowler.com/eaaCatalog/domainModel.html
Forget all you know about 
frameworks, controllers, 
forms, api etc. Just do 
OOP.
Behat can be used to 
drive Domain Model code
Warning 
This is real project code, so it is not ideal and 
can be possibly done better. But in real project 
we can not refactor our code infinitely because 
of obvious reasons.
Sample user private messages 
functionality 
● Registered user can send private message 
to any other registered user 
● Messages should be combined to dialogs 
● There should be email notifications about 
new messages
Scenario first 
Do not think about implementation, think about 
business value, use-cases and user stories 
first.
Tip: personalize your users in scenarios, remember their names and other 
private info and do not change them between scenarios
Note: I forgot about last message text in dialogs, and it will be added later. 
Note: “fetch messages” operation is part of our domain, because we want to 
know when to mark messages as read. So it should be explicitly added to the 
scenario
Note: Maybe it would be better to split this scenario to 1) total number of 
unread messages should be decreased; 2) message should not be unread 
when I fetch messages second time.
Note: Maybe it would be better to move last message text to dialog “properties” 
(see note to “I can send messages” scenario). Or we should remove “last 
message date” from dialog instead
Note: this is unusual situation. Doctrine 
Entities should be used as Domain 
Entities when possible.
Where is $em->flush()? 
Avoid using $em->flush() at the domain model level. This is 
against of UnitOfWork ideology 
http://martinfowler.com/eaaCatalog/unitOfWork.html
Notifications
Simple and framework agnostic 
Domain Model 
● Easy to write 
● Easy to read and understand 
● Can be guided by UnitTests if they have 
complex logic 
● Easy to migrate between frameworks (if you 
want to migrate, for example, from symfony2 
to silex + AngularJS)
Application and UI layers
Domain scenarios steps 
can easily be reused in UI 
tests
Profit 
● Everything needed by business can be done 
without a single Controller line 
● Simple and clear integration tests can be 
used as user stories by business people 
● Simple and thin controllers will not contain 
business rules 
● Little amount of complex and heavy UI tests 
(no need to test business expectations, only 
UI itself)
Thanks!

More Related Content

What's hot

CQRS and event sourcing
CQRS and event sourcingCQRS and event sourcing
CQRS and event sourcingJeppe Cramon
 
Api gateway in microservices
Api gateway in microservicesApi gateway in microservices
Api gateway in microservicesKunal Hire
 
Advanced Bootstrapping and Integrations - Chennai OutSystems User Group 27th ...
Advanced Bootstrapping and Integrations - Chennai OutSystems User Group 27th ...Advanced Bootstrapping and Integrations - Chennai OutSystems User Group 27th ...
Advanced Bootstrapping and Integrations - Chennai OutSystems User Group 27th ...OutSystemsNeo
 
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...Vietnam Open Infrastructure User Group
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREAraf Karsh Hamid
 
Kubernetes in Docker
Kubernetes in DockerKubernetes in Docker
Kubernetes in DockerDocker, Inc.
 
Introduction To Microservices
Introduction To MicroservicesIntroduction To Microservices
Introduction To MicroservicesLalit Kale
 
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Simplilearn
 
도커 컨테이너 활용 사례 Codigm - 남 유석 개발팀장 :: AWS Container Day
도커 컨테이너 활용 사례 Codigm - 남 유석 개발팀장 :: AWS Container Day도커 컨테이너 활용 사례 Codigm - 남 유석 개발팀장 :: AWS Container Day
도커 컨테이너 활용 사례 Codigm - 남 유석 개발팀장 :: AWS Container DayAmazon Web Services Korea
 
Clean architecture
Clean architectureClean architecture
Clean architectureandbed
 
Go micro framework to build microservices
Go micro framework to build microservicesGo micro framework to build microservices
Go micro framework to build microservicesTechMaster Vietnam
 
API Management within a Microservice Architecture
API Management within a Microservice ArchitectureAPI Management within a Microservice Architecture
API Management within a Microservice ArchitectureWSO2
 
Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker, Inc.
 
Kubernetes Problem-Solving
Kubernetes Problem-SolvingKubernetes Problem-Solving
Kubernetes Problem-SolvingAll Things Open
 
AWS January 2016 Webinar Series - Introduction to Docker on AWS
AWS January 2016 Webinar Series - Introduction to Docker on AWSAWS January 2016 Webinar Series - Introduction to Docker on AWS
AWS January 2016 Webinar Series - Introduction to Docker on AWSAmazon Web Services
 
Dallas Mulesoft Meetup - Log Aggregation and Elastic Stack on Anypoint Platform
Dallas Mulesoft Meetup - Log Aggregation and Elastic Stack on Anypoint PlatformDallas Mulesoft Meetup - Log Aggregation and Elastic Stack on Anypoint Platform
Dallas Mulesoft Meetup - Log Aggregation and Elastic Stack on Anypoint PlatformAdam DesJardin
 
Git interview questions | Edureka
Git interview questions | EdurekaGit interview questions | Edureka
Git interview questions | EdurekaEdureka!
 
Training Webinars - Secret hacks for OutSystems 10
Training Webinars - Secret hacks for OutSystems 10Training Webinars - Secret hacks for OutSystems 10
Training Webinars - Secret hacks for OutSystems 10OutSystems
 

What's hot (20)

CQRS and event sourcing
CQRS and event sourcingCQRS and event sourcing
CQRS and event sourcing
 
Api gateway in microservices
Api gateway in microservicesApi gateway in microservices
Api gateway in microservices
 
Advanced Bootstrapping and Integrations - Chennai OutSystems User Group 27th ...
Advanced Bootstrapping and Integrations - Chennai OutSystems User Group 27th ...Advanced Bootstrapping and Integrations - Chennai OutSystems User Group 27th ...
Advanced Bootstrapping and Integrations - Chennai OutSystems User Group 27th ...
 
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
Room 2 - 4 - Juncheng Anthony Lin - Redhat - A Practical Approach to Traditio...
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SREMicroservices Docker Kubernetes Istio Kanban DevOps SRE
Microservices Docker Kubernetes Istio Kanban DevOps SRE
 
Kubernetes in Docker
Kubernetes in DockerKubernetes in Docker
Kubernetes in Docker
 
Introduction To Microservices
Introduction To MicroservicesIntroduction To Microservices
Introduction To Microservices
 
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
Chef vs Puppet vs Ansible vs Saltstack | Configuration Management Tools | Dev...
 
도커 컨테이너 활용 사례 Codigm - 남 유석 개발팀장 :: AWS Container Day
도커 컨테이너 활용 사례 Codigm - 남 유석 개발팀장 :: AWS Container Day도커 컨테이너 활용 사례 Codigm - 남 유석 개발팀장 :: AWS Container Day
도커 컨테이너 활용 사례 Codigm - 남 유석 개발팀장 :: AWS Container Day
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
Go micro framework to build microservices
Go micro framework to build microservicesGo micro framework to build microservices
Go micro framework to build microservices
 
API Management within a Microservice Architecture
API Management within a Microservice ArchitectureAPI Management within a Microservice Architecture
API Management within a Microservice Architecture
 
Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker Swarm 0.2.0
Docker Swarm 0.2.0
 
Kubernetes Problem-Solving
Kubernetes Problem-SolvingKubernetes Problem-Solving
Kubernetes Problem-Solving
 
AWS January 2016 Webinar Series - Introduction to Docker on AWS
AWS January 2016 Webinar Series - Introduction to Docker on AWSAWS January 2016 Webinar Series - Introduction to Docker on AWS
AWS January 2016 Webinar Series - Introduction to Docker on AWS
 
Dallas Mulesoft Meetup - Log Aggregation and Elastic Stack on Anypoint Platform
Dallas Mulesoft Meetup - Log Aggregation and Elastic Stack on Anypoint PlatformDallas Mulesoft Meetup - Log Aggregation and Elastic Stack on Anypoint Platform
Dallas Mulesoft Meetup - Log Aggregation and Elastic Stack on Anypoint Platform
 
Istio a service mesh
Istio   a service meshIstio   a service mesh
Istio a service mesh
 
Git interview questions | Edureka
Git interview questions | EdurekaGit interview questions | Edureka
Git interview questions | Edureka
 
Training Webinars - Secret hacks for OutSystems 10
Training Webinars - Secret hacks for OutSystems 10Training Webinars - Secret hacks for OutSystems 10
Training Webinars - Secret hacks for OutSystems 10
 
Monitoring Solutions for APIs
Monitoring Solutions for APIsMonitoring Solutions for APIs
Monitoring Solutions for APIs
 

Viewers also liked

Contao Open Source CMS -- 新しいメジャーリリースとLTSリリース
Contao Open Source CMS -- 新しいメジャーリリースとLTSリリースContao Open Source CMS -- 新しいメジャーリリースとLTSリリース
Contao Open Source CMS -- 新しいメジャーリリースとLTSリリースTakahiro Kambe
 
Построение индексов Redis
Построение индексов RedisПостроение индексов Redis
Построение индексов RedisPetr Trofimov
 
REST in practice with Symfony2
REST in practice with Symfony2REST in practice with Symfony2
REST in practice with Symfony2Daniel Londero
 
Применение CQRS и EventSourcing в DDD-проекте
Применение CQRS и EventSourcing в DDD-проектеПрименение CQRS и EventSourcing в DDD-проекте
Применение CQRS и EventSourcing в DDD-проектеIgor Lubenets
 
Yet Another Continuous Integration Story
Yet Another Continuous Integration StoryYet Another Continuous Integration Story
Yet Another Continuous Integration StoryAnton Serdyuk
 
Применение DDD подхода в Symfony 2 приложении
Применение DDD подхода в Symfony 2 приложенииПрименение DDD подхода в Symfony 2 приложении
Применение DDD подхода в Symfony 2 приложенииАнтон Шабовта
 
Doctrine 2 - Not The Same Old Php Orm
Doctrine 2 - Not The Same Old Php OrmDoctrine 2 - Not The Same Old Php Orm
Doctrine 2 - Not The Same Old Php OrmJonathan Wage
 

Viewers also liked (9)

TDD with phpspec2
TDD with phpspec2TDD with phpspec2
TDD with phpspec2
 
Contao Open Source CMS -- 新しいメジャーリリースとLTSリリース
Contao Open Source CMS -- 新しいメジャーリリースとLTSリリースContao Open Source CMS -- 新しいメジャーリリースとLTSリリース
Contao Open Source CMS -- 新しいメジャーリリースとLTSリリース
 
Построение индексов Redis
Построение индексов RedisПостроение индексов Redis
Построение индексов Redis
 
REST in practice with Symfony2
REST in practice with Symfony2REST in practice with Symfony2
REST in practice with Symfony2
 
презентация Bdd
презентация Bddпрезентация Bdd
презентация Bdd
 
Применение CQRS и EventSourcing в DDD-проекте
Применение CQRS и EventSourcing в DDD-проектеПрименение CQRS и EventSourcing в DDD-проекте
Применение CQRS и EventSourcing в DDD-проекте
 
Yet Another Continuous Integration Story
Yet Another Continuous Integration StoryYet Another Continuous Integration Story
Yet Another Continuous Integration Story
 
Применение DDD подхода в Symfony 2 приложении
Применение DDD подхода в Symfony 2 приложенииПрименение DDD подхода в Symfony 2 приложении
Применение DDD подхода в Symfony 2 приложении
 
Doctrine 2 - Not The Same Old Php Orm
Doctrine 2 - Not The Same Old Php OrmDoctrine 2 - Not The Same Old Php Orm
Doctrine 2 - Not The Same Old Php Orm
 

Similar to DDD with Behat

Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Fwdays
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecturekhushbu thakker
 
The working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийThe working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийSigma Software
 
The working architecture of node js applications open tech week javascript ...
The working architecture of node js applications   open tech week javascript ...The working architecture of node js applications   open tech week javascript ...
The working architecture of node js applications open tech week javascript ...Viktor Turskyi
 
Instant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesInstant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesYshay Yaacobi
 
Tests immutable when refactoring - SegFault Unconference Cracow 2019
Tests immutable when refactoring - SegFault Unconference Cracow 2019Tests immutable when refactoring - SegFault Unconference Cracow 2019
Tests immutable when refactoring - SegFault Unconference Cracow 2019Grzegorz Miejski
 
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020OdessaJS Conf
 
Not my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructureNot my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructureYshay Yaacobi
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with RailsPaul Gallagher
 
From class to architecture
From class to architectureFrom class to architecture
From class to architectureMarcin Hawraniak
 
"The working architecture of NodeJs applications" Viktor Turskyi
"The working architecture of NodeJs applications" Viktor Turskyi"The working architecture of NodeJs applications" Viktor Turskyi
"The working architecture of NodeJs applications" Viktor TurskyiJulia Cherniak
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumLiraz Shay
 
Advantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworksAdvantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworksKaty Slemon
 
Serverless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionServerless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionSteve Hogg
 
Keeping business logic out of your UIs
Keeping business logic out of your UIsKeeping business logic out of your UIs
Keeping business logic out of your UIsPetter Holmström
 
Top Tips Every Notes Developer Needs To Know
Top Tips Every Notes Developer Needs To KnowTop Tips Every Notes Developer Needs To Know
Top Tips Every Notes Developer Needs To KnowKathy Brown
 
meetup version of Paving the road to production
  meetup version of Paving the road to production    meetup version of Paving the road to production
meetup version of Paving the road to production Matthew Reynolds
 
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedJoão Pedro Martins
 

Similar to DDD with Behat (20)

Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
Create first android app with MVVM Architecture
Create first android app with MVVM ArchitectureCreate first android app with MVVM Architecture
Create first android app with MVVM Architecture
 
The working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор ТурскийThe working architecture of NodeJS applications, Виктор Турский
The working architecture of NodeJS applications, Виктор Турский
 
The working architecture of node js applications open tech week javascript ...
The working architecture of node js applications   open tech week javascript ...The working architecture of node js applications   open tech week javascript ...
The working architecture of node js applications open tech week javascript ...
 
Instant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesInstant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositories
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
 
Tests immutable when refactoring - SegFault Unconference Cracow 2019
Tests immutable when refactoring - SegFault Unconference Cracow 2019Tests immutable when refactoring - SegFault Unconference Cracow 2019
Tests immutable when refactoring - SegFault Unconference Cracow 2019
 
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
'Effective node.js development' by Viktor Turskyi at OdessaJS'2020
 
Not my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructureNot my problem - Delegating responsibility to infrastructure
Not my problem - Delegating responsibility to infrastructure
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with Rails
 
From class to architecture
From class to architectureFrom class to architecture
From class to architecture
 
"The working architecture of NodeJs applications" Viktor Turskyi
"The working architecture of NodeJs applications" Viktor Turskyi"The working architecture of NodeJs applications" Viktor Turskyi
"The working architecture of NodeJs applications" Viktor Turskyi
 
BDD with SpecFlow and Selenium
BDD with SpecFlow and SeleniumBDD with SpecFlow and Selenium
BDD with SpecFlow and Selenium
 
Dust.js
Dust.jsDust.js
Dust.js
 
Advantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworksAdvantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworks
 
Serverless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionServerless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From Production
 
Keeping business logic out of your UIs
Keeping business logic out of your UIsKeeping business logic out of your UIs
Keeping business logic out of your UIs
 
Top Tips Every Notes Developer Needs To Know
Top Tips Every Notes Developer Needs To KnowTop Tips Every Notes Developer Needs To Know
Top Tips Every Notes Developer Needs To Know
 
meetup version of Paving the road to production
  meetup version of Paving the road to production    meetup version of Paving the road to production
meetup version of Paving the road to production
 
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons LearnedITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
ITARC15 Workshop - Architecting a Large Software Project - Lessons Learned
 

Recently uploaded

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 

Recently uploaded (20)

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 

DDD with Behat

  • 1. DDD with Behat by Anton Serdyuk
  • 2. Agile project and team evolution 1 2 3 4 5 6
  • 3. 1. No tests at all ● You can write very good code, but this code WILL suck later ● “Refactoring” is a swearword ● That is why constant “No time for refactoring” ● “We need to rewrite it from scratch” at the end 1 2 3 4 5 6
  • 4. 2. So called “Unittests” ● Not actual unittests ● xUnit based tests for controllers, entities, repositories etc without any order ● Complex fixtures ● Hard to support ● “There is no time for tests” because of no visible profit 1 2 3 4 5 6
  • 5. 3. Selenium acceptance tests ● Written by QA automators usually in Java even in PHP and .NET projects ● This approach is widely spread, well known and may perform well, but I think autotests implementation is not a QA job 1 2 3 4 5 6
  • 6. 4. Behat acceptance tests ● This approach may perform very well ● Can be written by QA (and even sometimes by BA) ● Some people call it BDD, but it is not BDD actually Given there is registered user Bob And I am on homepage When I follow “Sign Up” And I fill “Bob” in “Username” And I press “Sign Up” Then I should see “This username is already in use” 1 2 3 4 5 6
  • 7. 5. BDD ● BDD is not about tests ● It is the process of finding out and delivering features which provide value to users ● Should be used not only in dev team but in whole team beginning from Product Owner Given there is registered user Bob When I try to sign up with username “Bob” Then I should get error that this user is already signed up 1 2 3 4 5 6
  • 8. 6. Lean ● The last point of Agile team and project journey ● It is all about how to deliver more value to customer and how to build sustainable business around this product 1 2 3 4 5 6
  • 9. 4,5. DDD with Behat ● Not a BDD yet ● Not just acceptance tests with Behat BDD Behat acceptance tests DDD with Behat
  • 10. Functional tests with Behat https://github.com/diaspora/diaspora/blob/develop/features/desktop/change_email.feature
  • 11. They are really cool ● Provide Continuous Integration and Continuous Delivery possibility ● Easy to write ● Can be written by QA and even sometimes by BA
  • 12. But... ● Long execution time ○ Less green builds ○ Wasted developers’ time ● Non-deterministic failures ○ Developers try to rebuild every failing build instead of investigating ○ Wasted developers’ time
  • 13. But... ● They are too specific ○ It is difficult to dig up business value from them ○ less benefits for use by (and with) business people (BA, Product Owner)
  • 15. Model Model is a system of abstractions that describes selected aspects of a domain and can be used to solve problems related to this domain http://www.infoq.com/presentations/model-to-work-evans
  • 16. Ubiquitous Language A language structured around the domain model and used by all team members to connect all the activities of the team with the software http://www.infoq.com/presentations/model-to-work-evans
  • 17. Ubiquitous Language helps to find out model weaknesses If domain expert does not understand you when you use ubiquitous language, then your model does not describe domain as needed and should be corrected.
  • 19. Layers in typical symfony2 project ● Infrastructure ○ Doctrine ○ SwiftMailer ● UI ○ views ○ JS ● Application ○ controllers ○ some services ● Domain ○ entities
  • 20. Entities are not enough to create a powerful domain model
  • 21. Domain Model ● Domain model is just Plain Old PHP Objects. ● Framework-agnostic
  • 22. Domain Model At its worst business logic can be very complex. Rules and logic describe many different cases and slants of behavior, and it's this complexity that objects were designed to work with. A Domain Model creates a web of interconnected objects, where each object represents some meaningful individual, whether as large as a corporation or as small as a single line on an order form. http://martinfowler.com/eaaCatalog/domainModel.html
  • 23. Forget all you know about frameworks, controllers, forms, api etc. Just do OOP.
  • 24. Behat can be used to drive Domain Model code
  • 25. Warning This is real project code, so it is not ideal and can be possibly done better. But in real project we can not refactor our code infinitely because of obvious reasons.
  • 26. Sample user private messages functionality ● Registered user can send private message to any other registered user ● Messages should be combined to dialogs ● There should be email notifications about new messages
  • 27.
  • 28. Scenario first Do not think about implementation, think about business value, use-cases and user stories first.
  • 29. Tip: personalize your users in scenarios, remember their names and other private info and do not change them between scenarios
  • 30. Note: I forgot about last message text in dialogs, and it will be added later. Note: “fetch messages” operation is part of our domain, because we want to know when to mark messages as read. So it should be explicitly added to the scenario
  • 31.
  • 32.
  • 33. Note: Maybe it would be better to split this scenario to 1) total number of unread messages should be decreased; 2) message should not be unread when I fetch messages second time.
  • 34. Note: Maybe it would be better to move last message text to dialog “properties” (see note to “I can send messages” scenario). Or we should remove “last message date” from dialog instead
  • 35.
  • 36.
  • 37.
  • 38. Note: this is unusual situation. Doctrine Entities should be used as Domain Entities when possible.
  • 39.
  • 40.
  • 41. Where is $em->flush()? Avoid using $em->flush() at the domain model level. This is against of UnitOfWork ideology http://martinfowler.com/eaaCatalog/unitOfWork.html
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 51.
  • 52.
  • 53.
  • 54. Simple and framework agnostic Domain Model ● Easy to write ● Easy to read and understand ● Can be guided by UnitTests if they have complex logic ● Easy to migrate between frameworks (if you want to migrate, for example, from symfony2 to silex + AngularJS)
  • 56.
  • 57.
  • 58. Domain scenarios steps can easily be reused in UI tests
  • 59.
  • 60. Profit ● Everything needed by business can be done without a single Controller line ● Simple and clear integration tests can be used as user stories by business people ● Simple and thin controllers will not contain business rules ● Little amount of complex and heavy UI tests (no need to test business expectations, only UI itself)