SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Specifications pattern
TungNT @ Septeni Technolgy
Specification Pattern by TungNT 2
Introduction
“In computer programming, the specification pattern is a
particular software design pattern, whereby business rules can
be recombined by chaining the business rules together using
boolean logic. The pattern is frequently used in the context of
domain-driven design.”
- Wikipedia -
Specification Pattern by TungNT 3
Hmmm...
Specification Pattern by TungNT 4
Let's start by example
● Let's assume we need to build a recruitment
system and we have a user story look like this:
– As recruiter I can check on the status of candidate
– As recruiter I can get list of candidate who passed
Note: Candidate passed if:
– Scala skill test score >= 80
– Interview passed
– ...
Specification Pattern by TungNT 5
Go! go! go!...
Specification Pattern by TungNT 6
OOP way
● In “As recruiter I can check on the status of candidate”
~> Created Candidate class which has isPassed
method to check status of candidate
Specification Pattern by TungNT 7
OOP way (cont.)
● In “As recruiter I can get list of candidate who passed”
~> Created Candidate Repository to get all
candidate who passed from persitence
Specification Pattern by TungNT 8
But...
Specification Pattern by TungNT 9
Is there a better way to do this?
Specification Pattern by TungNT 10
Specification way
● In “As recruiter I can check on the status of candidate”
~>
Specification Pattern by TungNT 11
Specification way (cont.)
● In “As recruiter I can get list of candidate who passed”
~>
Specification Pattern by TungNT 12
As you'll soon realize...
● specifications are:
– cheap to write
– easy to test
– encapsulate the business rule
– use the Specification Object anywhere
– can be combined to represent very complex
business rules
Specification Pattern by TungNT 13
How it work?
Specification Pattern by TungNT 14
By DDD sample
● Create a Specification interface:
Specification Pattern by TungNT 15
By DDD sample (cont.)
● Create a Specification abstract:
Specification Pattern by TungNT 16
By DDD sample (cont.)
● Create a AND Specification:
Specification Pattern by TungNT 17
By DDD sample (cont.)
● Create a OR Specification:
Specification Pattern by TungNT 18
By DDD sample (cont.)
● Create a NOT Specification:
Specification Pattern by TungNT 19
Using combined specs
● And operator
Specification Pattern by TungNT 20
Conclusion
● Some key benefits of the Specification Pattern
are:
– Loose coupling of the filter logic from the objects
being filtered
– Single responsibility: Interface of repository/data
provider isn’t polluted with lots of filter methods
– Encapsulate the business rule and...
– Can be combined to represent very complex
business rules
Specification Pattern by TungNT 21
References
● Links:
1. https://en.wikipedia.org/wiki/Specification_pattern
2. http://marcaube.ca/2015/05/specifications/
3. Is the Specification Pattern obsolete?
Specification Pattern by TungNT 22
Thank you!

Weitere ähnliche Inhalte

Was ist angesagt?

TUTORIAL PARA REALIZAR UN PSEUDOCODIGO
TUTORIAL PARA REALIZAR UN PSEUDOCODIGOTUTORIAL PARA REALIZAR UN PSEUDOCODIGO
TUTORIAL PARA REALIZAR UN PSEUDOCODIGOAlfaBVB98
 
Chemical bonding shape of the molecule
Chemical bonding shape of the moleculeChemical bonding shape of the molecule
Chemical bonding shape of the moleculeMOHAMED RIYAZUDEEN
 
Summary of Organic Chemistry .pdf
Summary of Organic Chemistry .pdfSummary of Organic Chemistry .pdf
Summary of Organic Chemistry .pdfloli232001
 
Arduino smtp envío de correo electrónico (email)
Arduino smtp envío de correo electrónico (email)Arduino smtp envío de correo electrónico (email)
Arduino smtp envío de correo electrónico (email)Israel Magaña
 
CONTADOR BINARIO DESCENDENTE DE 14 BITS CON ARDUINO
CONTADOR BINARIO DESCENDENTE DE 14 BITS CON ARDUINOCONTADOR BINARIO DESCENDENTE DE 14 BITS CON ARDUINO
CONTADOR BINARIO DESCENDENTE DE 14 BITS CON ARDUINOFernando Marcos Marcos
 
hund's rule
hund's rulehund's rule
hund's rulevxiiayah
 
Quantum Chemistry
Quantum ChemistryQuantum Chemistry
Quantum Chemistrybaoilleach
 

Was ist angesagt? (10)

CODIGO DE HUFFMAN
CODIGO DE HUFFMANCODIGO DE HUFFMAN
CODIGO DE HUFFMAN
 
TUTORIAL PARA REALIZAR UN PSEUDOCODIGO
TUTORIAL PARA REALIZAR UN PSEUDOCODIGOTUTORIAL PARA REALIZAR UN PSEUDOCODIGO
TUTORIAL PARA REALIZAR UN PSEUDOCODIGO
 
Chemical bonding shape of the molecule
Chemical bonding shape of the moleculeChemical bonding shape of the molecule
Chemical bonding shape of the molecule
 
Summary of Organic Chemistry .pdf
Summary of Organic Chemistry .pdfSummary of Organic Chemistry .pdf
Summary of Organic Chemistry .pdf
 
Arduino smtp envío de correo electrónico (email)
Arduino smtp envío de correo electrónico (email)Arduino smtp envío de correo electrónico (email)
Arduino smtp envío de correo electrónico (email)
 
CONTADOR BINARIO DESCENDENTE DE 14 BITS CON ARDUINO
CONTADOR BINARIO DESCENDENTE DE 14 BITS CON ARDUINOCONTADOR BINARIO DESCENDENTE DE 14 BITS CON ARDUINO
CONTADOR BINARIO DESCENDENTE DE 14 BITS CON ARDUINO
 
hund's rule
hund's rulehund's rule
hund's rule
 
Quantum Chemistry
Quantum ChemistryQuantum Chemistry
Quantum Chemistry
 
Qué es el temporizador 555
Qué es el temporizador 555Qué es el temporizador 555
Qué es el temporizador 555
 
Trabajo colaborativo dos 168
Trabajo colaborativo dos 168Trabajo colaborativo dos 168
Trabajo colaborativo dos 168
 

Andere mochten auch

Andere mochten auch (8)

ScrumStudy-ScrumFundamentals Certification
ScrumStudy-ScrumFundamentals CertificationScrumStudy-ScrumFundamentals Certification
ScrumStudy-ScrumFundamentals Certification
 
Contaminación del medio ambiente
Contaminación del medio ambienteContaminación del medio ambiente
Contaminación del medio ambiente
 
Publicidad
PublicidadPublicidad
Publicidad
 
All economic assigment
All economic assigmentAll economic assigment
All economic assigment
 
Unwanted pregnancy
Unwanted pregnancyUnwanted pregnancy
Unwanted pregnancy
 
Portfolio
PortfolioPortfolio
Portfolio
 
主日投影片
主日投影片主日投影片
主日投影片
 
Maria Renström, Ministry of Health and Social Affairs, Sweden
Maria Renström, Ministry of Health and Social Affairs, SwedenMaria Renström, Ministry of Health and Social Affairs, Sweden
Maria Renström, Ministry of Health and Social Affairs, Sweden
 

Ähnlich wie Specifications pattern

New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNico Ludwig
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Chris Laning
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytechyannick grenzinger
 
Best practice for magento programming by shankar konar
Best practice for magento programming by shankar konarBest practice for magento programming by shankar konar
Best practice for magento programming by shankar konarvijaygolani
 
Simplified Troubleshooting through API Scripting
Simplified Troubleshooting through API Scripting Simplified Troubleshooting through API Scripting
Simplified Troubleshooting through API Scripting Network Automation Forum
 
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...Codemotion
 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCCarlo Bonamico
 
CD in Machine Learning Systems
CD in Machine Learning SystemsCD in Machine Learning Systems
CD in Machine Learning SystemsThoughtworks
 
Information Extraction from the Web - Algorithms and Tools
Information Extraction from the Web - Algorithms and ToolsInformation Extraction from the Web - Algorithms and Tools
Information Extraction from the Web - Algorithms and ToolsBenjamin Habegger
 
Introduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on RailsIntroduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on Railspmatsinopoulos
 
OutSystems Tips and Tricks
OutSystems Tips and TricksOutSystems Tips and Tricks
OutSystems Tips and TricksOutSystems
 
Willump: Optimizing Feature Computation in ML Inference
Willump: Optimizing Feature Computation in ML InferenceWillump: Optimizing Feature Computation in ML Inference
Willump: Optimizing Feature Computation in ML InferenceDatabricks
 
Hexagonal Architecture.pdf
Hexagonal Architecture.pdfHexagonal Architecture.pdf
Hexagonal Architecture.pdfVladimirRadzivil
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratchWen-Shih Chao
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative ProgrammingSchalk Cronjé
 
Testing stage. being ahead business with cucumber
Testing stage. being ahead business with cucumberTesting stage. being ahead business with cucumber
Testing stage. being ahead business with cucumberAlex Mikitenko
 
Gatling Performance Workshop
Gatling Performance WorkshopGatling Performance Workshop
Gatling Performance WorkshopSai Krishna
 

Ähnlich wie Specifications pattern (20)

New c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_ivNew c sharp3_features_(linq)_part_iv
New c sharp3_features_(linq)_part_iv
 
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
Taming the Legacy Beast: Turning wild old code into a sleak new thoroughbread.
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 
Best practice for magento programming by shankar konar
Best practice for magento programming by shankar konarBest practice for magento programming by shankar konar
Best practice for magento programming by shankar konar
 
Simplified Troubleshooting through API Scripting
Simplified Troubleshooting through API Scripting Simplified Troubleshooting through API Scripting
Simplified Troubleshooting through API Scripting
 
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
Real World AngularJS recipes: beyond TodoMVC - Carlo Bonamico, Sonia Pini - C...
 
Real World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVCReal World AngularJS recipes: beyond TodoMVC
Real World AngularJS recipes: beyond TodoMVC
 
Better java with design
Better java with designBetter java with design
Better java with design
 
CD in Machine Learning Systems
CD in Machine Learning SystemsCD in Machine Learning Systems
CD in Machine Learning Systems
 
Information Extraction from the Web - Algorithms and Tools
Information Extraction from the Web - Algorithms and ToolsInformation Extraction from the Web - Algorithms and Tools
Information Extraction from the Web - Algorithms and Tools
 
Introduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on RailsIntroduction to Web Development with Ruby on Rails
Introduction to Web Development with Ruby on Rails
 
2nd presantation
2nd presantation2nd presantation
2nd presantation
 
OutSystems Tips and Tricks
OutSystems Tips and TricksOutSystems Tips and Tricks
OutSystems Tips and Tricks
 
Willump: Optimizing Feature Computation in ML Inference
Willump: Optimizing Feature Computation in ML InferenceWillump: Optimizing Feature Computation in ML Inference
Willump: Optimizing Feature Computation in ML Inference
 
Hexagonal Architecture.pdf
Hexagonal Architecture.pdfHexagonal Architecture.pdf
Hexagonal Architecture.pdf
 
Write unit test from scratch
Write unit test from scratchWrite unit test from scratch
Write unit test from scratch
 
Dust.js
Dust.jsDust.js
Dust.js
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative Programming
 
Testing stage. being ahead business with cucumber
Testing stage. being ahead business with cucumberTesting stage. being ahead business with cucumber
Testing stage. being ahead business with cucumber
 
Gatling Performance Workshop
Gatling Performance WorkshopGatling Performance Workshop
Gatling Performance Workshop
 

Mehr von Tung Nguyen

An overview of modern scalable web development
An overview of modern scalable web developmentAn overview of modern scalable web development
An overview of modern scalable web developmentTung Nguyen
 
Circuit Breaker Pattern
Circuit Breaker PatternCircuit Breaker Pattern
Circuit Breaker PatternTung Nguyen
 
Distributed unique id generation
Distributed unique id generationDistributed unique id generation
Distributed unique id generationTung Nguyen
 
Pay off Technical Debt by Good Code
Pay off Technical Debt by Good CodePay off Technical Debt by Good Code
Pay off Technical Debt by Good CodeTung Nguyen
 
Implementing Domain Event with Akka
Implementing Domain Event with AkkaImplementing Domain Event with Akka
Implementing Domain Event with AkkaTung Nguyen
 

Mehr von Tung Nguyen (6)

An overview of modern scalable web development
An overview of modern scalable web developmentAn overview of modern scalable web development
An overview of modern scalable web development
 
Circuit Breaker Pattern
Circuit Breaker PatternCircuit Breaker Pattern
Circuit Breaker Pattern
 
Distributed unique id generation
Distributed unique id generationDistributed unique id generation
Distributed unique id generation
 
Pay off Technical Debt by Good Code
Pay off Technical Debt by Good CodePay off Technical Debt by Good Code
Pay off Technical Debt by Good Code
 
Implementing Domain Event with Akka
Implementing Domain Event with AkkaImplementing Domain Event with Akka
Implementing Domain Event with Akka
 
Why scala?
Why scala?Why scala?
Why scala?
 

Kürzlich hochgeladen

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 

Kürzlich hochgeladen (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 

Specifications pattern

  • 2. Specification Pattern by TungNT 2 Introduction “In computer programming, the specification pattern is a particular software design pattern, whereby business rules can be recombined by chaining the business rules together using boolean logic. The pattern is frequently used in the context of domain-driven design.” - Wikipedia -
  • 3. Specification Pattern by TungNT 3 Hmmm...
  • 4. Specification Pattern by TungNT 4 Let's start by example ● Let's assume we need to build a recruitment system and we have a user story look like this: – As recruiter I can check on the status of candidate – As recruiter I can get list of candidate who passed Note: Candidate passed if: – Scala skill test score >= 80 – Interview passed – ...
  • 5. Specification Pattern by TungNT 5 Go! go! go!...
  • 6. Specification Pattern by TungNT 6 OOP way ● In “As recruiter I can check on the status of candidate” ~> Created Candidate class which has isPassed method to check status of candidate
  • 7. Specification Pattern by TungNT 7 OOP way (cont.) ● In “As recruiter I can get list of candidate who passed” ~> Created Candidate Repository to get all candidate who passed from persitence
  • 8. Specification Pattern by TungNT 8 But...
  • 9. Specification Pattern by TungNT 9 Is there a better way to do this?
  • 10. Specification Pattern by TungNT 10 Specification way ● In “As recruiter I can check on the status of candidate” ~>
  • 11. Specification Pattern by TungNT 11 Specification way (cont.) ● In “As recruiter I can get list of candidate who passed” ~>
  • 12. Specification Pattern by TungNT 12 As you'll soon realize... ● specifications are: – cheap to write – easy to test – encapsulate the business rule – use the Specification Object anywhere – can be combined to represent very complex business rules
  • 13. Specification Pattern by TungNT 13 How it work?
  • 14. Specification Pattern by TungNT 14 By DDD sample ● Create a Specification interface:
  • 15. Specification Pattern by TungNT 15 By DDD sample (cont.) ● Create a Specification abstract:
  • 16. Specification Pattern by TungNT 16 By DDD sample (cont.) ● Create a AND Specification:
  • 17. Specification Pattern by TungNT 17 By DDD sample (cont.) ● Create a OR Specification:
  • 18. Specification Pattern by TungNT 18 By DDD sample (cont.) ● Create a NOT Specification:
  • 19. Specification Pattern by TungNT 19 Using combined specs ● And operator
  • 20. Specification Pattern by TungNT 20 Conclusion ● Some key benefits of the Specification Pattern are: – Loose coupling of the filter logic from the objects being filtered – Single responsibility: Interface of repository/data provider isn’t polluted with lots of filter methods – Encapsulate the business rule and... – Can be combined to represent very complex business rules
  • 21. Specification Pattern by TungNT 21 References ● Links: 1. https://en.wikipedia.org/wiki/Specification_pattern 2. http://marcaube.ca/2015/05/specifications/ 3. Is the Specification Pattern obsolete?
  • 22. Specification Pattern by TungNT 22 Thank you!