SlideShare a Scribd company logo
Java - Better with
Design
Narayann Swaami
Agile Technical Coach
Societe Generale
Currently work as :
Agile Technical Coach @
http://www.socgensolutions.com/
16 yrs poking around, 10+ years on
Java
Interests:
Clean code, TDD,
Parallel/Concurrent programming
About me
Summary
There are many ways of approaching best practices
Learn on your own
Learn from Industry standard books
Learn from conferences/meetups
How this came about
Coaching teams - working with them
Analyze what worked AND what did not work
Inspect and Adapt!
What we will learn today
Interesting best practices - From “Refactoring To Patterns”
How we do this
→ μ- Workshop
→ Two - three examples [ Time-Dependent ]
→ Refactoring workflow
→ Interactivity
Better OOP is better Java
Why?
Better Design is Better Java
Why?
What comes to mind?
S.O.L.I.D
S.O.L.I.D in 120 seconds
SRP - Responsibility/Ease of change of a class
OCP - Strategy/Template Method + Interface
LSP - Car Is-a Vehicle [ Square Is-a Rectangle? ]
ISP - Many specific Interfaces
DIP - High Level / Low level modules ⇒ abstractions ⇐ details
Creating classes - move away from
Constructor?
Creating classes
● Use creation methods [not necessarily factory method - overkill]
● Chain Constructors
● Collecting Parameter
Consider ⇒ 3D Printed Building
What comes to mind?
● 3D Printed Building
● Area
● Dimensions
● Floors
Highlights
⇒ Intention-revealing names for
creation Methods
⇒ One constructor calling others in a
chain that follows a logical
Sequence (move to creation
Method)
Replace Conditional logic with Strategy
● For one of several variants of an algorithm
● Use a separate strategy for each variant and call accordingly
● 3DPrinter - how to print a building?
Code Study: Encapsulate classes with Factory
● “Program to interface, not to
implementation”
● “Client does not need to know where
the class resides”
● “Access through a common
interface”
● Use intention-revealing creation
Methods
Why?
See
http://grepcode.com/file/repository.grepcod
e.com/java/root/jdk/openjdk/8u40-
b25/java/util/Collections.java
Collections.synchronizedXYZ()
How?
Encapsulate Composite with Builder
● Let’s evaluate a Spec for the 3D
Printed Building
● Like configuration files
● Creation of composites can be error-
prone
● The XML Tag is joined by a composite
● Loose Coupling between client and
composite
Why How
● Create a builder
● Use builder to produce a one-node
Composite . Add a method to the
builder to obtain the result of its build
● Make the builder capable of building
children.
● Make the builder capable of setting
those attributes and values.
● Refactor to make it simpler
Better java with design
Reference
धन्यवादः।

More Related Content

PPTX
Serverless meetup - OpenWhisk overview and architecture
PDF
DevOps - A Gentle Introduction
PDF
DevOps Toolchain v1.0
PPTX
DevOps Fundamentals: A perspective on DevOps Culture
PDF
Common blind spots on the journey to production vijay raghavan aravamudhan
PDF
Serverless Architecture Patterns - Manoj Ganapathi - Serverless Summit
PDF
Why Serverless?
PPTX
Modern Tools for Building Progressive Web Apps
Serverless meetup - OpenWhisk overview and architecture
DevOps - A Gentle Introduction
DevOps Toolchain v1.0
DevOps Fundamentals: A perspective on DevOps Culture
Common blind spots on the journey to production vijay raghavan aravamudhan
Serverless Architecture Patterns - Manoj Ganapathi - Serverless Summit
Why Serverless?
Modern Tools for Building Progressive Web Apps

What's hot (20)

PPTX
Introduction to chef
PPTX
The Automated Monolith
PDF
Apache Continuum Build, Test, and Release
PDF
Serverless Functions: Accelerating DevOps Adoption
PDF
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
PDF
Designing and Debugging Mobile Apps with an Embedded, Scriptable Web Server
PPTX
Cucumber jvm best practices v3
PPTX
Polyglot
PPTX
Continuous integration
PDF
Developer Experience Cloud Native - Become Efficient and Achieve Parity
PDF
IaC on AWS Cloud
PPTX
Modern CI/CD Pipeline Using Azure DevOps
PPTX
DevOps ci/cd with Microsoft vsts and azure
PPTX
VOLODYMYR TSAP, BAQ, "CI/CD Infrastructure as a Code"
PPTX
Roadmap to Enterprise Quality
PPTX
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
PDF
Developer Productivity Engineering with Gradle
PDF
Building the Web with Gradle
PPTX
Implementing FaaS on Kubernetes using Kubeless
PDF
Haufe Onboarding - Fast Iterating With the MERN Stack - TEC Day 2019
Introduction to chef
The Automated Monolith
Apache Continuum Build, Test, and Release
Serverless Functions: Accelerating DevOps Adoption
ECS19 - Daniel Neumann - AZURE FUNCTIONS 2.0 - RUNNING SERVERLESS EVERYWHERE
Designing and Debugging Mobile Apps with an Embedded, Scriptable Web Server
Cucumber jvm best practices v3
Polyglot
Continuous integration
Developer Experience Cloud Native - Become Efficient and Achieve Parity
IaC on AWS Cloud
Modern CI/CD Pipeline Using Azure DevOps
DevOps ci/cd with Microsoft vsts and azure
VOLODYMYR TSAP, BAQ, "CI/CD Infrastructure as a Code"
Roadmap to Enterprise Quality
Using PaaS for Continuous Delivery (Cloud Foundry Summit 2014)
Developer Productivity Engineering with Gradle
Building the Web with Gradle
Implementing FaaS on Kubernetes using Kubeless
Haufe Onboarding - Fast Iterating With the MERN Stack - TEC Day 2019
Ad

Viewers also liked (20)

PDF
Advanced Debugging Using Java Bytecodes
PDF
Java Generics - by Example
PPTX
Java 8 concurrency abstractions
PDF
Choosing Between Cross Platform of Native Development
PDF
7 best quotes on dev ops
PDF
DevOps - A Gentle Introduction
PDF
Refactoring for Software Design Smells - Tech Talk
PDF
Java Concurrency by Example
PDF
Software Architecture - Quiz Questions
PDF
Core Java - Quiz Questions - Bug Hunt
PPTX
Solid Principles Of Design (Design Series 01)
PPTX
Zero downtime release through DevOps Continuous Delivery
PPTX
DevOps game marshmallow challenge
PPTX
Effective DB Interaction
PDF
Productive Programming in Java 8 - with Lambdas and Streams
PDF
Sailing with Java 8 Streams
PPTX
Java concurrency questions and answers
PDF
Software Architecture - Principles Patterns and Practices - OSI Days Workshop...
PDF
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
PPTX
Mongo db
Advanced Debugging Using Java Bytecodes
Java Generics - by Example
Java 8 concurrency abstractions
Choosing Between Cross Platform of Native Development
7 best quotes on dev ops
DevOps - A Gentle Introduction
Refactoring for Software Design Smells - Tech Talk
Java Concurrency by Example
Software Architecture - Quiz Questions
Core Java - Quiz Questions - Bug Hunt
Solid Principles Of Design (Design Series 01)
Zero downtime release through DevOps Continuous Delivery
DevOps game marshmallow challenge
Effective DB Interaction
Productive Programming in Java 8 - with Lambdas and Streams
Sailing with Java 8 Streams
Java concurrency questions and answers
Software Architecture - Principles Patterns and Practices - OSI Days Workshop...
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Mongo db
Ad

Similar to Better java with design (20)

PDF
Create first android app with MVVM Architecture
PDF
PDF
From class to architecture
PPTX
Software Engineering Primer
PDF
The benefit of sneezing code into an editor vs clean code
PDF
Keeping code clean
PPTX
An introduction to Emulsify
PDF
JSFest 2019: Technology agnostic microservices at SPA frontend
PDF
Boston Startup School - OO Design
PPTX
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
PDF
Software Craftmanship - Cours Polytech
PPTX
Software Design Principles and Best Practices - Satyajit Dey
PPTX
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
PPTX
HOW TO START (ANYTHING ABOUT CODE).pptx
PPTX
Javascript Programming according to Industry Standards.pptx
PDF
Rapid app building with loopback framework
PDF
Xlab #2: wzorce projektowe
PPT
Model Driven Architectures
ODP
Dealing With Legacy: The Real-World Experience
PDF
Viktor Turskyi "Effective NodeJS Application Development"
Create first android app with MVVM Architecture
From class to architecture
Software Engineering Primer
The benefit of sneezing code into an editor vs clean code
Keeping code clean
An introduction to Emulsify
JSFest 2019: Technology agnostic microservices at SPA frontend
Boston Startup School - OO Design
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptx
Software Craftmanship - Cours Polytech
Software Design Principles and Best Practices - Satyajit Dey
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
HOW TO START (ANYTHING ABOUT CODE).pptx
Javascript Programming according to Industry Standards.pptx
Rapid app building with loopback framework
Xlab #2: wzorce projektowe
Model Driven Architectures
Dealing With Legacy: The Real-World Experience
Viktor Turskyi "Effective NodeJS Application Development"

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
Transform Your Business with a Software ERP System
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
top salesforce developer skills in 2025.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Introduction to Artificial Intelligence
PDF
Nekopoi APK 2025 free lastest update
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms I-SECS-1021-03
Odoo POS Development Services by CandidRoot Solutions
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Operating system designcfffgfgggggggvggggggggg
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Transform Your Business with a Software ERP System
How to Choose the Right IT Partner for Your Business in Malaysia
top salesforce developer skills in 2025.pdf
Softaken Excel to vCard Converter Software.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Introduction to Artificial Intelligence
Nekopoi APK 2025 free lastest update
Design an Analysis of Algorithms II-SECS-1021-03
Designing Intelligence for the Shop Floor.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
L1 - Introduction to python Backend.pptx

Better java with design

  • 1. Java - Better with Design Narayann Swaami Agile Technical Coach Societe Generale
  • 2. Currently work as : Agile Technical Coach @ http://www.socgensolutions.com/ 16 yrs poking around, 10+ years on Java Interests: Clean code, TDD, Parallel/Concurrent programming About me
  • 3. Summary There are many ways of approaching best practices Learn on your own Learn from Industry standard books Learn from conferences/meetups
  • 4. How this came about Coaching teams - working with them Analyze what worked AND what did not work Inspect and Adapt!
  • 5. What we will learn today Interesting best practices - From “Refactoring To Patterns”
  • 6. How we do this → μ- Workshop → Two - three examples [ Time-Dependent ] → Refactoring workflow → Interactivity
  • 7. Better OOP is better Java Why?
  • 8. Better Design is Better Java Why?
  • 9. What comes to mind? S.O.L.I.D
  • 10. S.O.L.I.D in 120 seconds SRP - Responsibility/Ease of change of a class OCP - Strategy/Template Method + Interface LSP - Car Is-a Vehicle [ Square Is-a Rectangle? ] ISP - Many specific Interfaces DIP - High Level / Low level modules ⇒ abstractions ⇐ details
  • 11. Creating classes - move away from Constructor? Creating classes ● Use creation methods [not necessarily factory method - overkill] ● Chain Constructors ● Collecting Parameter Consider ⇒ 3D Printed Building What comes to mind? ● 3D Printed Building ● Area ● Dimensions ● Floors Highlights ⇒ Intention-revealing names for creation Methods ⇒ One constructor calling others in a chain that follows a logical Sequence (move to creation Method)
  • 12. Replace Conditional logic with Strategy ● For one of several variants of an algorithm ● Use a separate strategy for each variant and call accordingly ● 3DPrinter - how to print a building?
  • 13. Code Study: Encapsulate classes with Factory ● “Program to interface, not to implementation” ● “Client does not need to know where the class resides” ● “Access through a common interface” ● Use intention-revealing creation Methods Why? See http://grepcode.com/file/repository.grepcod e.com/java/root/jdk/openjdk/8u40- b25/java/util/Collections.java Collections.synchronizedXYZ() How?
  • 14. Encapsulate Composite with Builder ● Let’s evaluate a Spec for the 3D Printed Building ● Like configuration files ● Creation of composites can be error- prone ● The XML Tag is joined by a composite ● Loose Coupling between client and composite Why How ● Create a builder ● Use builder to produce a one-node Composite . Add a method to the builder to obtain the result of its build ● Make the builder capable of building children. ● Make the builder capable of setting those attributes and values. ● Refactor to make it simpler

Editor's Notes

  • #11: ISP - Clients should not depend on things they do not need
  • #12: https://github.com/nswaami/CoreJavaMeetup12Nov2016/blob/master/3DPrintedBuilding/3DPrintedBuilding.java
  • #13: https://en.wikipedia.org/wiki/3D_Print_Canal_House
  • #14: http://softwareengineering.stackexchange.com/questions/240351/using-a-simple-static-factory-vs-instantiating-directly-new-thing-vs-factor
  • #15: http://www.informit.com/articles/article.aspx?p=1398606&seqNum=5
  • #17: http://softwareengineering.stackexchange.com/questions/240351/using-a-simple-static-factory-vs-instantiating-directly-new-thing-vs-factor