SlideShare a Scribd company logo
The modern view on
implementation of
classic design patterns in
Java
Mikalai Alimenkou
http://xpinjection.com
@xpinjection
The modern view on implementation of classic design patterns in Java
The modern view on implementation of classic design patterns in Java
Disclaimer
This is only my
personal experience
Familiar with design patterns?
Holy bible for developers 
Java have long/slow roadmap
You could follow code samples
https://github.com/xpinjection/design-patterns
#1: Singleton
DI fight against Singleton
This is common anti-
pattern now
Isolate existing
Singletons from new
code with DI
DI containers ‘killed’
Singleton pattern
The modern view on implementation of classic design patterns in Java
#2: Builder
‘Storing’ VS ‘runtime’
style builders
Builder is the most
common pattern
Java is still bad in
handling properties
The modern view on implementation of classic design patterns in Java
#3: Prototype
DI container handle
prototypes in their
own way
Clone method in
Object is confusing
Useful for domain
model with DDD style
The modern view on implementation of classic design patterns in Java
#4: Factory Method
Use basic functional
interfaces if possible
Doesn’t work for
abstract factory
Constructor is also a
function
The modern view on implementation of classic design patterns in Java
#5: Adapter
Functional interfaces
are interchangeable
Doesn’t work for
complex interfaces
Use basic functional
interfaces if possible
The modern view on implementation of classic design patterns in Java
#6: Proxy
May be done with
composite functions
Inline lambda
wrapping is also
available
Main usage with AOP
and DI containers
Libs for manual proxy creation
• java.lang.reflect.Proxy
• Byte Buddy (http://bytebuddy.net)
• cglib (https://github.com/cglib/cglib)
• javassist (https://github.com/jboss-
javassist/javassist)
The modern view on implementation of classic design patterns in Java
#7: Template Method
Utilize basic functional
interfaces
Inline needed parts
in tests and simple
clients
Use composition
instead of inheritance
The modern view on implementation of classic design patterns in Java
#8: Command
Collect commands in
collection or combine
them
Doesn’t work with
complex commands
(with ‘undo’)
Dude, this is just a
plain lambda!
The modern view on implementation of classic design patterns in Java
#9: Chain of Responsibility
Combine consumers
in the chain
Doesn’t work for
“workflow” handlers
May be use typed
functions pipeline?
The modern view on implementation of classic design patterns in Java
#10: Strategy
Inline strategy in tests
and other light clients
Store strategies in
single holder as
static methods
Dude, this is just a
plain lambda again!
The modern view on implementation of classic design patterns in Java
#11: Iterator
Use Streams
everywhere
Create own streams
with Spliterator
Forget about manual
iterations
The modern view on implementation of classic design patterns in Java
#12: Decorator
Wrap function with
lambda
Combine functions
to provide additional
behavior
Use the Proxy
approaches
The modern view on implementation of classic design patterns in Java
#13: Observer
Pass methods as
listeners
Observer and
Listener are
functional interfaces
Inline listener logic
in lambda
The modern view on implementation of classic design patterns in Java
#14: Visitor
Use general
implementation
Try to use default
methods where
applicable
Very rarely used design
pattern
The modern view on implementation of classic design patterns in Java
And remember…
@xpinjection
http://xpinjection.com
mikalai.alimenkou@xpinjection.com

More Related Content

PPTX
Java concurrency in practice
PDF
JUnit & Mockito, first steps
PPTX
Introduction to Selenium Web Driver
PPTX
Automation - web testing with selenium
PDF
What Is React | ReactJS Tutorial for Beginners | ReactJS Training | Edureka
PDF
AOT and Native with Spring Boot 3.0
PDF
Web Services Automated Testing via SoapUI Tool
PDF
Spring Framework - MVC
Java concurrency in practice
JUnit & Mockito, first steps
Introduction to Selenium Web Driver
Automation - web testing with selenium
What Is React | ReactJS Tutorial for Beginners | ReactJS Training | Edureka
AOT and Native with Spring Boot 3.0
Web Services Automated Testing via SoapUI Tool
Spring Framework - MVC

What's hot (20)

PDF
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
KEY
Spring AOP
PDF
Intro to GraphQL
PPTX
Getting Started with React.js
PDF
Reactjs Basics
PDF
Selenium cheat sheet
PPTX
Laravel
PDF
Test Automation Using Python | Edureka
PPSX
Advanced Web Development in PHP - Understanding REST API
PPT
Jsp(java server pages)
PPTX
Spring & hibernate
PDF
Kotlin Coroutines and Android sitting in a tree
PDF
React js t7 - forms-events
PDF
Java Concurrency Gotchas
PPTX
Katalon Studio - GUI Overview
PDF
React JS and why it's awesome
PPTX
Functional testing vs non functional testing | Difference Between Functional ...
PPTX
OWASP Zed Attack Proxy
PDF
Java spring framework
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring AOP
Intro to GraphQL
Getting Started with React.js
Reactjs Basics
Selenium cheat sheet
Laravel
Test Automation Using Python | Edureka
Advanced Web Development in PHP - Understanding REST API
Jsp(java server pages)
Spring & hibernate
Kotlin Coroutines and Android sitting in a tree
React js t7 - forms-events
Java Concurrency Gotchas
Katalon Studio - GUI Overview
React JS and why it's awesome
Functional testing vs non functional testing | Difference Between Functional ...
OWASP Zed Attack Proxy
Java spring framework
Ad

Viewers also liked (14)

PPTX
Бытовая классификация тестировщиков с точки зрения разработчика
PPT
Baocao ltm
PDF
Lezione 6a: Design Pattern Strutturali
PPTX
Full Scale Automation Using Selenium
PPTX
Why do I hate Hibernate?
PPTX
TDD for DB integration
PPTX
OOP paradigm, principles of good design and architecture of Java applications
PPTX
Tech Lead role for Agile success
PPTX
Continuous Delivery
PPTX
Why testing take so long
PPTX
How to make your functional tests really quick
ODP
ORM, JPA, & Hibernate Overview
PPTX
Design patterns in test automation
PPTX
Do we need JMS in 21st century?
Бытовая классификация тестировщиков с точки зрения разработчика
Baocao ltm
Lezione 6a: Design Pattern Strutturali
Full Scale Automation Using Selenium
Why do I hate Hibernate?
TDD for DB integration
OOP paradigm, principles of good design and architecture of Java applications
Tech Lead role for Agile success
Continuous Delivery
Why testing take so long
How to make your functional tests really quick
ORM, JPA, & Hibernate Overview
Design patterns in test automation
Do we need JMS in 21st century?
Ad

Similar to The modern view on implementation of classic design patterns in Java (20)

PPTX
L09 Frameworks
PDF
L07 Frameworks
PDF
Java Design Patterns Interview Questions PDF By ScholarHat
PPTX
L05 Frameworks
PPT
Design pattern
PDF
The maze of Design Patterns & SOLID Principles
PDF
Basic design pattern interview questions
PPT
Design_Patterns_Dr.CM.ppt
PDF
Design Patterns
PDF
Gof design pattern
DOCX
Java Design Pattern Interview Questions
PPT
P Training Presentation
PDF
[meetup] Mastering Java enhancements like a Pro: practical design patterns an...
PDF
Design Patterns - GOF
PPTX
Desing pattern prototype-Factory Method, Prototype and Builder
PPT
Introduction to design_patterns
PPTX
Creational pattern 2
DOCX
Patterns (contd)Software Development ProcessDesign patte.docx
PPTX
Creational Design Patterns.pptx
PPT
Software Design Patterns
L09 Frameworks
L07 Frameworks
Java Design Patterns Interview Questions PDF By ScholarHat
L05 Frameworks
Design pattern
The maze of Design Patterns & SOLID Principles
Basic design pattern interview questions
Design_Patterns_Dr.CM.ppt
Design Patterns
Gof design pattern
Java Design Pattern Interview Questions
P Training Presentation
[meetup] Mastering Java enhancements like a Pro: practical design patterns an...
Design Patterns - GOF
Desing pattern prototype-Factory Method, Prototype and Builder
Introduction to design_patterns
Creational pattern 2
Patterns (contd)Software Development ProcessDesign patte.docx
Creational Design Patterns.pptx
Software Design Patterns

More from Mikalai Alimenkou (20)

PPTX
Rise and fall of Story Points. Capacity based planning from the trenches.
PPTX
Static analysis tools as the best friend of QA
PPTX
Modern CI/CD in the microservices world with Kubernetes
PPTX
Saga about distributed business transactions in microservices world
PPTX
Effectiveness tips from Kubernetes trenches by Captain Obvious
PPTX
Ride the database in JUnit tests with Database Rider
PPTX
Wastful waste or why everything is so slow in development
PPTX
Hexagonal architecture with Spring Boot
PPTX
Wastful waste or why everything is so slow in development
PPTX
DevOps checklist or how to understand where is your team in DevOps landscape ...
PPTX
DevOps checklist or how to understand where is your team in DevOps landscape
PDF
Практические трудности в разработке Медкарты для целой страны
PPTX
Hexagonal architecture with Spring Boot [EPAM Java online conference]
PPTX
Bro, manage test data like a pro! [QA Fest 2018]
PPTX
Agile antipatterns: review after 10 years of practice
PPTX
Hexagonal architecture with Spring Boot
PPTX
Bro, manage test data like a pro!
PPTX
Бытовая классификация тестировщиков с точки зрения разработчика
PPTX
Code Review tool for personal effectiveness and waste analysis
PDF
Funny stories and anti-patterns from DevOps landscape
Rise and fall of Story Points. Capacity based planning from the trenches.
Static analysis tools as the best friend of QA
Modern CI/CD in the microservices world with Kubernetes
Saga about distributed business transactions in microservices world
Effectiveness tips from Kubernetes trenches by Captain Obvious
Ride the database in JUnit tests with Database Rider
Wastful waste or why everything is so slow in development
Hexagonal architecture with Spring Boot
Wastful waste or why everything is so slow in development
DevOps checklist or how to understand where is your team in DevOps landscape ...
DevOps checklist or how to understand where is your team in DevOps landscape
Практические трудности в разработке Медкарты для целой страны
Hexagonal architecture with Spring Boot [EPAM Java online conference]
Bro, manage test data like a pro! [QA Fest 2018]
Agile antipatterns: review after 10 years of practice
Hexagonal architecture with Spring Boot
Bro, manage test data like a pro!
Бытовая классификация тестировщиков с точки зрения разработчика
Code Review tool for personal effectiveness and waste analysis
Funny stories and anti-patterns from DevOps landscape

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
cuic standard and advanced reporting.pdf
PPTX
1. Introduction to Computer Programming.pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
Teaching material agriculture food technology
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
cuic standard and advanced reporting.pdf
1. Introduction to Computer Programming.pptx
SOPHOS-XG Firewall Administrator PPT.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Group 1 Presentation -Planning and Decision Making .pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Assigned Numbers - 2025 - Bluetooth® Document
Spectral efficient network and resource selection model in 5G networks
Teaching material agriculture food technology
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...

The modern view on implementation of classic design patterns in Java