SlideShare a Scribd company logo
1 of 14
Download to read offline
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 Molieremfrancis
 
Puppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgePuppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgeAaron 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 DeyCefalo
 
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 missMark Papis
 
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 Deployment6D 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 Deploymentklcodanr
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software DesignGiorgio 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 ModulesAlvin 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 2013tom 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 LineImaginet
 
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 phpFabio Pellegrini
 
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

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 

Recently uploaded (20)

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 

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