SlideShare a Scribd company logo
Slide 1
Structuring your Java application
黃俊喬 Woody Huang
woody0927@gmail.com
2019.10.4
Slide 2
Background
Our Product:
▪ Monolith
▪ More than 10 years of development
▪ More than 10 developers working on the project
Problems:
▪ Not possible to know/remember everything of the system
▪ Inefficient or even fail to find suitable reusable method
▪ Redundant code
▪ Wrong method invocation
▪ Runtime environment is not controlled by us
Slide 3
Outline
▪ Different approaches to structuring your application
▪ Pros and cons of each approach
▪ Common problems and solutions
▪ Example
Slide 4
Different approaches to structuring your application
▪ Everything in one or a few classes
▪ Packing by technical layers
▪ Packing by feature
▪ Grouping relevant features into module
Slide 5
Everything in one or a few classes
Concept: Putting all classes in one package
Pros:
▪ No-brainer design
Cons:
▪ Hard to maintain
▪ Hard to debug
▪ Changes are prone to error
Slide 6
Packing by technical layers
Concept: All classes in the package are of the same type, e.g. Service.
Collaboration among packages are usually required to complete a feature.
Pros:
▪ Easy and better structured
▪ Information is at certain level protected
▪ Changes sometimes can be localized to one layer
Cons:
▪ Low cohesion and high coupling
▪ High Ripple effects
▪ Modifiers have to be public for cross package access
▪ Internal information leaked via public modifier
Slide 7
Packing by feature
Concept: Classes get used together are putting together
Pros:
▪ Even better structured - high cohesion and low coupling
▪ Information is protected
▪ Minimizing ripple effects
Cons:
▪ Modifiers have to be public if we create sub-packages
▪ Internal information is leaked via public modifier
Slide 8
Grouping relevant features into module
Concept: Features having same domain concept are putting together
and form an multi-module project. This is used together with grouping
by feature / technical layers and inherits the pros and cons.
Pros:
▪ Most of changes can be isolated to one module
Slide 9
Common problems to different grouping approach
▪ Limited encapsulation
▪ public modifier is inevitable - enterprise application is unlikely to
be built without sub-packages
▪ Confusions and wrong method invocations due to leaked
information
Slide 10
Solutions
▪ internal package - works with interface and factory to get the
runtime instance (regulated by convention)
▪ api package - (regulated by convention and code analysis rule)
▪ Java 9 - Java Platform Module System whenever possible
Slide 11
Example: Overwhelmed by implementation detail
Module: Onboarding
Module:
Risk-assessment
ClientService
+ register
+ backgroundCheck
+ listProspectClients
+ listRealClients
+ …..
listRealClients
Slide 12
Example: API exposure - information hiding
Module: Onboarding Module: Risk
assessment
ClientSe
rvice
+ …... listRealClients
API
listRealClients
Slide 13
Reference
▪ Sample: https://github.com/woody0927/structuring-java-app
▪ Package by feature, not layer
▪ Package by type, -by layer, -by feature vs “Package by layered feature”
Slide 14
QUESTIONS & DISCUSSIONS

More Related Content

Similar to Structuring your java application

10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
mfrancis
 
Puppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgePuppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the Forge
Aaron Bernstein
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit Dey
Cefalo
 
9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss
Mark Papis
 
Design pattern
Design patternDesign pattern
Design pattern
Shreyance Jain
 
CQ5 Development Setup, Maven Build and Deployment
CQ5 Development Setup, Maven Build and DeploymentCQ5 Development Setup, Maven Build and Deployment
CQ5 Development Setup, Maven Build and Deployment
6D Global
 
CQ5 Development Setup, Maven Build and Deployment
CQ5 Development Setup, Maven Build and DeploymentCQ5 Development Setup, Maven Build and Deployment
CQ5 Development Setup, Maven Build and Deployment
klcodanr
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
Giorgio Zoppi
 
SDL Web DXA: A Vision for Modules
SDL Web DXA: A Vision for ModulesSDL Web DXA: A Vision for Modules
SDL Web DXA: A Vision for Modules
Alvin Reyes
 
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Nuxeo
 
Agility is the tool gilb vilnius 9 dec 2013
Agility is the tool gilb vilnius 9 dec 2013Agility is the tool gilb vilnius 9 dec 2013
Agility is the tool gilb vilnius 9 dec 2013
tom gilb
 
How Microsoft ALM Tools Can Improve Your Bottom Line
How Microsoft ALM Tools Can Improve Your Bottom LineHow Microsoft ALM Tools Can Improve Your Bottom Line
How Microsoft ALM Tools Can Improve Your Bottom Line
Imaginet
 
Fighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless php
Fabio Pellegrini
 
Web frameworks
Web frameworksWeb frameworks
Web frameworks
Arafat Hossan
 
Lekkie metodyki kontra duże projekty
Lekkie metodyki kontra duże projektyLekkie metodyki kontra duże projekty
Lekkie metodyki kontra duże projekty
studenckifestiwalinformatyczny
 
1. oop with c++ get 410 day 1
1. oop with c++ get 410   day 11. oop with c++ get 410   day 1
1. oop with c++ get 410 day 1Mukul kumar Neal
 
Tapta 2012-visualizations-lms
Tapta 2012-visualizations-lmsTapta 2012-visualizations-lms
Tapta 2012-visualizations-lmsdleony
 

Similar to Structuring your java application (20)

Modular enablement
Modular enablementModular enablement
Modular enablement
 
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
 
Puppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgePuppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the Forge
 
Software Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit DeySoftware Design Principles and Best Practices - Satyajit Dey
Software Design Principles and Best Practices - Satyajit Dey
 
9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss9 crucial Java Design Principles you cannot miss
9 crucial Java Design Principles you cannot miss
 
Design pattern
Design patternDesign pattern
Design pattern
 
CQ5 Development Setup, Maven Build and Deployment
CQ5 Development Setup, Maven Build and DeploymentCQ5 Development Setup, Maven Build and Deployment
CQ5 Development Setup, Maven Build and Deployment
 
CQ5 Development Setup, Maven Build and Deployment
CQ5 Development Setup, Maven Build and DeploymentCQ5 Development Setup, Maven Build and Deployment
CQ5 Development Setup, Maven Build and Deployment
 
Solid
SolidSolid
Solid
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
 
SDL Web DXA: A Vision for Modules
SDL Web DXA: A Vision for ModulesSDL Web DXA: A Vision for Modules
SDL Web DXA: A Vision for Modules
 
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
Creating Large Scale Software Platforms with OSGi and an Extension Point Mode...
 
Agility is the tool gilb vilnius 9 dec 2013
Agility is the tool gilb vilnius 9 dec 2013Agility is the tool gilb vilnius 9 dec 2013
Agility is the tool gilb vilnius 9 dec 2013
 
How Microsoft ALM Tools Can Improve Your Bottom Line
How Microsoft ALM Tools Can Improve Your Bottom LineHow Microsoft ALM Tools Can Improve Your Bottom Line
How Microsoft ALM Tools Can Improve Your Bottom Line
 
Fighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless phpFighting legacy with hexagonal architecture and frameworkless php
Fighting legacy with hexagonal architecture and frameworkless php
 
Web frameworks
Web frameworksWeb frameworks
Web frameworks
 
1.
1. 1.
1.
 
Lekkie metodyki kontra duże projekty
Lekkie metodyki kontra duże projektyLekkie metodyki kontra duże projekty
Lekkie metodyki kontra duże projekty
 
1. oop with c++ get 410 day 1
1. oop with c++ get 410   day 11. oop with c++ get 410   day 1
1. oop with c++ get 410 day 1
 
Tapta 2012-visualizations-lms
Tapta 2012-visualizations-lmsTapta 2012-visualizations-lms
Tapta 2012-visualizations-lms
 

Recently uploaded

Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 

Recently uploaded (20)

Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 

Structuring your java application

  • 1. Slide 1 Structuring your Java application 黃俊喬 Woody Huang woody0927@gmail.com 2019.10.4
  • 2. Slide 2 Background Our Product: ▪ Monolith ▪ More than 10 years of development ▪ More than 10 developers working on the project Problems: ▪ Not possible to know/remember everything of the system ▪ Inefficient or even fail to find suitable reusable method ▪ Redundant code ▪ Wrong method invocation ▪ Runtime environment is not controlled by us
  • 3. Slide 3 Outline ▪ Different approaches to structuring your application ▪ Pros and cons of each approach ▪ Common problems and solutions ▪ Example
  • 4. Slide 4 Different approaches to structuring your application ▪ Everything in one or a few classes ▪ Packing by technical layers ▪ Packing by feature ▪ Grouping relevant features into module
  • 5. Slide 5 Everything in one or a few classes Concept: Putting all classes in one package Pros: ▪ No-brainer design Cons: ▪ Hard to maintain ▪ Hard to debug ▪ Changes are prone to error
  • 6. Slide 6 Packing by technical layers Concept: All classes in the package are of the same type, e.g. Service. Collaboration among packages are usually required to complete a feature. Pros: ▪ Easy and better structured ▪ Information is at certain level protected ▪ Changes sometimes can be localized to one layer Cons: ▪ Low cohesion and high coupling ▪ High Ripple effects ▪ Modifiers have to be public for cross package access ▪ Internal information leaked via public modifier
  • 7. Slide 7 Packing by feature Concept: Classes get used together are putting together Pros: ▪ Even better structured - high cohesion and low coupling ▪ Information is protected ▪ Minimizing ripple effects Cons: ▪ Modifiers have to be public if we create sub-packages ▪ Internal information is leaked via public modifier
  • 8. Slide 8 Grouping relevant features into module Concept: Features having same domain concept are putting together and form an multi-module project. This is used together with grouping by feature / technical layers and inherits the pros and cons. Pros: ▪ Most of changes can be isolated to one module
  • 9. Slide 9 Common problems to different grouping approach ▪ Limited encapsulation ▪ public modifier is inevitable - enterprise application is unlikely to be built without sub-packages ▪ Confusions and wrong method invocations due to leaked information
  • 10. Slide 10 Solutions ▪ internal package - works with interface and factory to get the runtime instance (regulated by convention) ▪ api package - (regulated by convention and code analysis rule) ▪ Java 9 - Java Platform Module System whenever possible
  • 11. Slide 11 Example: Overwhelmed by implementation detail Module: Onboarding Module: Risk-assessment ClientService + register + backgroundCheck + listProspectClients + listRealClients + ….. listRealClients
  • 12. Slide 12 Example: API exposure - information hiding Module: Onboarding Module: Risk assessment ClientSe rvice + …... listRealClients API listRealClients
  • 13. Slide 13 Reference ▪ Sample: https://github.com/woody0927/structuring-java-app ▪ Package by feature, not layer ▪ Package by type, -by layer, -by feature vs “Package by layered feature”
  • 14. Slide 14 QUESTIONS & DISCUSSIONS