SlideShare une entreprise Scribd logo
1  sur  34
Restructuring
Improving the modularity of an existing code-base
                  Chris Chedgey
                   Structure101
Structure101 - People
•   Chris Chedgey, Dunmore East, Ireland
•   Paul Hickey, Toulouse, France
•   Paul O’Reilly, Enniscorthy, Ireland
•   Raghvendra Sahu, Delhi, India
•   + 3 contractors
•   No VC’s, no suits
Structure101 - Products
•   Restructure101
      •   Fix architecture
•   Structure101
      •   Define it
•   Structure101 Build
      •   Enforce it
•   Java, .NET, C/C++, Actionscript, php, …
•   1,000’s users in 100’s companies
Topics

•   What is “Restructuring”?
•   Motivation
•   Understanding structure
•   Restructuring strategies
•   Examples
What is restructuring?
Refactoring                           Restructuring
•   “Changing code without            •   “Reorganizing a code-base
    modifying behavior to improve         without modifying the code to
    nonfunctional attributes.”            improve modularity”
•   Code is readable                  •   Code-base is understandable
•   A lot of invasive code editing    •   Minimal invasive code editing
•   Scope: small worlds of a few      •   Scope: whole code base; what
    classes at a time; what you see       you don’t see in the IDE
    in the IDE.
What is structure?

•   Composition
•   Dependencies that roll up through composition
•   Nested “levels”
•   Quality factors
      •   1. Complexity           Complexity        Modularity
      •   2. Modularity
Why is structure important?
•   Determines cost of development
      •   Understandability

•   Predictable impact of changes
•   Testability
•   Reusability
•   Value of your code base
      •   Asset or liability?
Structural quality 1: complexity
•   Fat                                  •   Eliminate tangles by putting
                                             everything in one place -
      •   Too much stuff in one place        creates fat
          (method, class, package,
          bundle, …)                     •   Eliminate fat by simplistically
•   Tangles                                  partitioning fat items – creates
                                             tangles
      •   Cyclic dependencies
      •   Cumulative Component
          Dependency (CCD, Lakos)        Checked
          goes through the roof          automatically
      •   Acyclic Dependency Principle
          (ADP, Bob Martin) – morning
          after syndrome
Structural quality 2: modularity
•   High cohesion          •   S/W-eng 101
•   Low coupling           •   We ALL know about
                               modularity!
•   Information hiding
•   Interfaces
                           Checked
•   Clear responsibility
                           by human architect
•   …
Working with structure – core features
•   Composition + Dependency
•   Flow of dependency
•   Whole codebase
•   Filtering
•   Summarizing
•   Comprehension
Working with structure

•    Lists and treeview
•    Directed graph
•    Dependency Structure Matrix (DSM)
•    Levelized Structure Map (LSM)
Working with structure: list & treeview
•   Good to discover specific
    information
•   No dependency flow,
    manipulation
Visualizing structure: directed graphs
•   Info points: #items + #deps
•   Levelizable – good flow
•   #deps becomes a problem
      •   Indicate fat, not fix

•   Infinite nesting not feasible
•   Local comprehension, not for
    global/manipulation
Visualizing structure: DSM
•   Info points: #items2
•   “Scalable” - can be rendered for
    v large graphs
•   Infinite nesting possible
•   Whole code-base
•   Manipulation possible
•   Grow v large
•   Hard to read, bad for the neck
Visualizing structure - LSM
•   Info points: #items
•   Composition, dependency,
    flow, whole codebase,
    filtering, summarizing
•   Goldilocks – designed
    specifically for restructuring
The modularity wasteland
•   Methods ok
•   Classes ok
•   Handfuls of classes ok
       •   Overlapping “small worlds”
       •   Plenty of guidelines
       •   Smells and refactoring
•   But almost no logical organization
    of classes into higher level
    modules
•   This is not scalable
“But we use Java packages!”
•   Bollox!!
•   Hierarchical ok
•   Support visibility ok
•   BUT: used like a filesystem, not as an
    embodiment of module hierarchy
        •   Composition only

        •   No consideration of dependencies

        •   Little consideration of visibility

        •   Too easy to change (without rules/tools)

•   Becomes a big tangled mess
Modularity stops at class level?
•   Finite aggregation is not
    scalable
•   Oceans of classes
•   Still need to divide and
    conquer
•   Even more – affects the
    whole team
•   Is it inevitable?
Inevitable?
•   No!
•   Spring:
Restructuring strategies
•   Merge parallel structure      •   Do as much as possible by
                                      moving classes and packages
•   Top-down or bottom-up
    decision                      •   Divide disjoint packages early
•   Tackle complexity before      •   Break up v. fat classes and
    modularity                        packages early
•   Break v large class tangles   •   Disentangle
    early
                                  •   Consider mixed granularity
•   Address tangles top-down
                                  •   …
Merge parallel structures
•   Common to separate interfaces/api
    from implementation
•   Perhaps attempt to increase
    awareness of visibility
•   Obscures module structure esp if
    higher in hierarchy
•   Better to consider module sub-items
    as siblings with visibility
•   Keep both if there is a strong
    need/desire for physical code to be
    separate
•   Use of transformations
Merge parallel structures
Bust v large class tangles early
•   Often there is 1 or a few v.large        •   Can the class tangle be contained
    tangles spanning many packages               within a single package?
       •   Making those packages acyclic            •   At least for now?
           means busting the class tangle
                                                    •   Not if classes span to much of the
•   Does it span multiple higher-level                  layering
    layers?
                                                    •   Not if it represents a significant
       •   Break the feedback dependencies              portion of your code base
           between the layers
                                             •   Can you break the tangle into several
                                                 acyclic subsets of tangles?
                                                    •   Each subset can be contained within
                                                        a single package
                                             •   Each subset can be contained within a
                                                 narrow range of ideal leveling
Do as much as you can by moving
classes/packages first
•   Low effort refactoring
•   Less invasive surgery so less risk of impacting behavior
•   Exception – static classes
•   Biggest bang for the buck, unless there are v.large class tangles
•   Option to manage architecture separate from physical code
      •   Map classes to physical components
      •   Can’t be done if model requires invasive class editing
Top-down or bottom-up?
•   Top-down                                     •   A bit of both
      •   Preserves as much of the package              •   Preserve top-level breakout
          hierarchy as possible
                                                              •   May reflect team structure
      •   Team can still find classes
                                                              •   Often reflects initial architecture
      •   Feasible if the target structure is
                                                                     •   Sub-modules were not explicitly
          close to the current                                           designed

•   Bottom-up                                           •   Preserve in regions where there is
                                                            relatively small amount of
      •   Current packaging is of little use                restructuring
      •   Target structure is far from current
      •   Often easiest to implement
Make items only using or used by a tangle
Move only used/using child items
Split disjoint packages
Split fat packages and classes
Move feeback from/top
Move feedback to/bottom
Move tangles together
Tackle complexity before (other)
modularity
•   A structure without tangles is much easier to manipulate
•   A milestone in its own right
•   A code-base that is much easier to understand
•   Many simply focus on keeping (over-)complexity out
•   Good basis for further modularization (coupling, cohesion,
    interfaces, …)
Summary
•   The modularity wasteland is normal
•   It costs
•   It can be salvaged
•   It is not easy, but the returns can be huge
•   Questions?
•   Thank you!

Contenu connexe

Similaire à Restructuring- improving the modularity of an existing code-base

SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1Julie Iskander
 
Bridging the divide between architecture and code (US version)
Bridging the divide between architecture and code (US version)Bridging the divide between architecture and code (US version)
Bridging the divide between architecture and code (US version)Chris Chedgey
 
Bridging the Divide between Architecture and Code (Germany JUGs version)
Bridging the Divide between Architecture and Code (Germany JUGs version)Bridging the Divide between Architecture and Code (Germany JUGs version)
Bridging the Divide between Architecture and Code (Germany JUGs version)Chris Chedgey
 
ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code
ATXPUG Meetup 11/11/14 - Managing complexity in Puppet CodeATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code
ATXPUG Meetup 11/11/14 - Managing complexity in Puppet CodeByron Miller
 
Docker in the Enterprise
Docker in the EnterpriseDocker in the Enterprise
Docker in the EnterpriseSaul Caganoff
 
Calling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayCalling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayTony Ng
 
Tool Driven Restructuring of Large Codebases
Tool Driven Restructuring of Large CodebasesTool Driven Restructuring of Large Codebases
Tool Driven Restructuring of Large CodebasesCodeOps Technologies LLP
 
Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Heartin Jacob
 
Calling all modularity solutions
Calling all modularity solutionsCalling all modularity solutions
Calling all modularity solutionsSangjin Lee
 
Architecture Principles CodeStock
Architecture Principles CodeStock Architecture Principles CodeStock
Architecture Principles CodeStock Steve Barbour
 
Onion Architecture / Clean Architecture
Onion Architecture / Clean ArchitectureOnion Architecture / Clean Architecture
Onion Architecture / Clean ArchitectureAttila Bertók
 
CAP Theorem - Theory, Implications and Practices
CAP Theorem - Theory, Implications and PracticesCAP Theorem - Theory, Implications and Practices
CAP Theorem - Theory, Implications and PracticesYoav Francis
 
Scala in practice
Scala in practiceScala in practice
Scala in practiceTomer Gabel
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Martijn Verburg
 
Factory and Class Cluster
Factory and Class ClusterFactory and Class Cluster
Factory and Class ClusterHSIEH CHING-FAN
 

Similaire à Restructuring- improving the modularity of an existing code-base (20)

SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
 
Bridging the divide between architecture and code (US version)
Bridging the divide between architecture and code (US version)Bridging the divide between architecture and code (US version)
Bridging the divide between architecture and code (US version)
 
Bridging the Divide between Architecture and Code (Germany JUGs version)
Bridging the Divide between Architecture and Code (Germany JUGs version)Bridging the Divide between Architecture and Code (Germany JUGs version)
Bridging the Divide between Architecture and Code (Germany JUGs version)
 
ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code
ATXPUG Meetup 11/11/14 - Managing complexity in Puppet CodeATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code
ATXPUG Meetup 11/11/14 - Managing complexity in Puppet Code
 
Docker in the Enterprise
Docker in the EnterpriseDocker in the Enterprise
Docker in the Enterprise
 
Calling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBayCalling All Modularity Solutions: A Comparative Study from eBay
Calling All Modularity Solutions: A Comparative Study from eBay
 
Shooting at a Moving Target
Shooting at a Moving TargetShooting at a Moving Target
Shooting at a Moving Target
 
Tool Driven Restructuring of Large Codebases
Tool Driven Restructuring of Large CodebasesTool Driven Restructuring of Large Codebases
Tool Driven Restructuring of Large Codebases
 
Week4 grasp-into
Week4 grasp-intoWeek4 grasp-into
Week4 grasp-into
 
Hpts 2011 flexible_oltp
Hpts 2011 flexible_oltpHpts 2011 flexible_oltp
Hpts 2011 flexible_oltp
 
Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)Solid Principles Of Design (Design Series 01)
Solid Principles Of Design (Design Series 01)
 
Calling all modularity solutions
Calling all modularity solutionsCalling all modularity solutions
Calling all modularity solutions
 
Architecture Principles CodeStock
Architecture Principles CodeStock Architecture Principles CodeStock
Architecture Principles CodeStock
 
Onion Architecture / Clean Architecture
Onion Architecture / Clean ArchitectureOnion Architecture / Clean Architecture
Onion Architecture / Clean Architecture
 
CAP Theorem - Theory, Implications and Practices
CAP Theorem - Theory, Implications and PracticesCAP Theorem - Theory, Implications and Practices
CAP Theorem - Theory, Implications and Practices
 
Week5 inhertiance
Week5 inhertianceWeek5 inhertiance
Week5 inhertiance
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)Modern Java Concurrency (OSCON 2012)
Modern Java Concurrency (OSCON 2012)
 
Factory and Class Cluster
Factory and Class ClusterFactory and Class Cluster
Factory and Class Cluster
 

Plus de Chris Chedgey

Monolith to Modular - The devil in the dependencies
Monolith to Modular - The devil in the dependenciesMonolith to Modular - The devil in the dependencies
Monolith to Modular - The devil in the dependenciesChris Chedgey
 
Rediscovering Modularity - .NET Edition
Rediscovering Modularity - .NET EditionRediscovering Modularity - .NET Edition
Rediscovering Modularity - .NET EditionChris Chedgey
 
Rediscovering modularity - JavaOne Brazil 2012
Rediscovering modularity - JavaOne Brazil 2012Rediscovering modularity - JavaOne Brazil 2012
Rediscovering modularity - JavaOne Brazil 2012Chris Chedgey
 
Retrofitting Architecture - Oredev 2012
Retrofitting Architecture - Oredev 2012Retrofitting Architecture - Oredev 2012
Retrofitting Architecture - Oredev 2012Chris Chedgey
 
Rediscovering Modularity - JFall 2012 version
Rediscovering Modularity - JFall 2012 versionRediscovering Modularity - JFall 2012 version
Rediscovering Modularity - JFall 2012 versionChris Chedgey
 

Plus de Chris Chedgey (6)

Monolith to Modular - The devil in the dependencies
Monolith to Modular - The devil in the dependenciesMonolith to Modular - The devil in the dependencies
Monolith to Modular - The devil in the dependencies
 
Beautiful Structure
Beautiful StructureBeautiful Structure
Beautiful Structure
 
Rediscovering Modularity - .NET Edition
Rediscovering Modularity - .NET EditionRediscovering Modularity - .NET Edition
Rediscovering Modularity - .NET Edition
 
Rediscovering modularity - JavaOne Brazil 2012
Rediscovering modularity - JavaOne Brazil 2012Rediscovering modularity - JavaOne Brazil 2012
Rediscovering modularity - JavaOne Brazil 2012
 
Retrofitting Architecture - Oredev 2012
Retrofitting Architecture - Oredev 2012Retrofitting Architecture - Oredev 2012
Retrofitting Architecture - Oredev 2012
 
Rediscovering Modularity - JFall 2012 version
Rediscovering Modularity - JFall 2012 versionRediscovering Modularity - JFall 2012 version
Rediscovering Modularity - JFall 2012 version
 

Dernier

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Restructuring- improving the modularity of an existing code-base

  • 1. Restructuring Improving the modularity of an existing code-base Chris Chedgey Structure101
  • 2. Structure101 - People • Chris Chedgey, Dunmore East, Ireland • Paul Hickey, Toulouse, France • Paul O’Reilly, Enniscorthy, Ireland • Raghvendra Sahu, Delhi, India • + 3 contractors • No VC’s, no suits
  • 3. Structure101 - Products • Restructure101 • Fix architecture • Structure101 • Define it • Structure101 Build • Enforce it • Java, .NET, C/C++, Actionscript, php, … • 1,000’s users in 100’s companies
  • 4. Topics • What is “Restructuring”? • Motivation • Understanding structure • Restructuring strategies • Examples
  • 5. What is restructuring? Refactoring Restructuring • “Changing code without • “Reorganizing a code-base modifying behavior to improve without modifying the code to nonfunctional attributes.” improve modularity” • Code is readable • Code-base is understandable • A lot of invasive code editing • Minimal invasive code editing • Scope: small worlds of a few • Scope: whole code base; what classes at a time; what you see you don’t see in the IDE in the IDE.
  • 6. What is structure? • Composition • Dependencies that roll up through composition • Nested “levels” • Quality factors • 1. Complexity Complexity Modularity • 2. Modularity
  • 7. Why is structure important? • Determines cost of development • Understandability • Predictable impact of changes • Testability • Reusability • Value of your code base • Asset or liability?
  • 8. Structural quality 1: complexity • Fat • Eliminate tangles by putting everything in one place - • Too much stuff in one place creates fat (method, class, package, bundle, …) • Eliminate fat by simplistically • Tangles partitioning fat items – creates tangles • Cyclic dependencies • Cumulative Component Dependency (CCD, Lakos) Checked goes through the roof automatically • Acyclic Dependency Principle (ADP, Bob Martin) – morning after syndrome
  • 9. Structural quality 2: modularity • High cohesion • S/W-eng 101 • Low coupling • We ALL know about modularity! • Information hiding • Interfaces Checked • Clear responsibility by human architect • …
  • 10. Working with structure – core features • Composition + Dependency • Flow of dependency • Whole codebase • Filtering • Summarizing • Comprehension
  • 11. Working with structure • Lists and treeview • Directed graph • Dependency Structure Matrix (DSM) • Levelized Structure Map (LSM)
  • 12. Working with structure: list & treeview • Good to discover specific information • No dependency flow, manipulation
  • 13. Visualizing structure: directed graphs • Info points: #items + #deps • Levelizable – good flow • #deps becomes a problem • Indicate fat, not fix • Infinite nesting not feasible • Local comprehension, not for global/manipulation
  • 14. Visualizing structure: DSM • Info points: #items2 • “Scalable” - can be rendered for v large graphs • Infinite nesting possible • Whole code-base • Manipulation possible • Grow v large • Hard to read, bad for the neck
  • 15. Visualizing structure - LSM • Info points: #items • Composition, dependency, flow, whole codebase, filtering, summarizing • Goldilocks – designed specifically for restructuring
  • 16. The modularity wasteland • Methods ok • Classes ok • Handfuls of classes ok • Overlapping “small worlds” • Plenty of guidelines • Smells and refactoring • But almost no logical organization of classes into higher level modules • This is not scalable
  • 17. “But we use Java packages!” • Bollox!! • Hierarchical ok • Support visibility ok • BUT: used like a filesystem, not as an embodiment of module hierarchy • Composition only • No consideration of dependencies • Little consideration of visibility • Too easy to change (without rules/tools) • Becomes a big tangled mess
  • 18. Modularity stops at class level? • Finite aggregation is not scalable • Oceans of classes • Still need to divide and conquer • Even more – affects the whole team • Is it inevitable?
  • 19. Inevitable? • No! • Spring:
  • 20. Restructuring strategies • Merge parallel structure • Do as much as possible by moving classes and packages • Top-down or bottom-up decision • Divide disjoint packages early • Tackle complexity before • Break up v. fat classes and modularity packages early • Break v large class tangles • Disentangle early • Consider mixed granularity • Address tangles top-down • …
  • 21. Merge parallel structures • Common to separate interfaces/api from implementation • Perhaps attempt to increase awareness of visibility • Obscures module structure esp if higher in hierarchy • Better to consider module sub-items as siblings with visibility • Keep both if there is a strong need/desire for physical code to be separate • Use of transformations
  • 23. Bust v large class tangles early • Often there is 1 or a few v.large • Can the class tangle be contained tangles spanning many packages within a single package? • Making those packages acyclic • At least for now? means busting the class tangle • Not if classes span to much of the • Does it span multiple higher-level layering layers? • Not if it represents a significant • Break the feedback dependencies portion of your code base between the layers • Can you break the tangle into several acyclic subsets of tangles? • Each subset can be contained within a single package • Each subset can be contained within a narrow range of ideal leveling
  • 24. Do as much as you can by moving classes/packages first • Low effort refactoring • Less invasive surgery so less risk of impacting behavior • Exception – static classes • Biggest bang for the buck, unless there are v.large class tangles • Option to manage architecture separate from physical code • Map classes to physical components • Can’t be done if model requires invasive class editing
  • 25. Top-down or bottom-up? • Top-down • A bit of both • Preserves as much of the package • Preserve top-level breakout hierarchy as possible • May reflect team structure • Team can still find classes • Often reflects initial architecture • Feasible if the target structure is • Sub-modules were not explicitly close to the current designed • Bottom-up • Preserve in regions where there is relatively small amount of • Current packaging is of little use restructuring • Target structure is far from current • Often easiest to implement
  • 26. Make items only using or used by a tangle
  • 27. Move only used/using child items
  • 29. Split fat packages and classes
  • 33. Tackle complexity before (other) modularity • A structure without tangles is much easier to manipulate • A milestone in its own right • A code-base that is much easier to understand • Many simply focus on keeping (over-)complexity out • Good basis for further modularization (coupling, cohesion, interfaces, …)
  • 34. Summary • The modularity wasteland is normal • It costs • It can be salvaged • It is not easy, but the returns can be huge • Questions? • Thank you!

Notes de l'éditeur

  1. Guten abendIch bin ein berlinerDarmstadterGood few years agoBit for freedomLast bit of useless info We dev tools – talk not about these – talk after formal pres
  2. 6 components to the company, 4 human, 2 beautifulWe don’t own suitsLove what we doRelentless innovation to solve a big problem
  3. What – relate to refactoringMotivation – modularity/scalabilityUnderstanding – quantifying over complexityRestructuring strategies – emerging from experience, dozens of client engagements and use casesShow parts of products to illustrate principles, not a tutorial on the products
  4. Don’t care whether you use inheritance or aggregationThink of a mass of lines of code, currently organized in one way into methods, classes, packages – we want to reorganize the same lines of code into a different hierarchy of methods, classes, packages.
  5. Can you test a tangle of hundreds of classes?Can’t reuse subsets if everything uses everythingWhen a code-base becomes a liability, sw-engineering has failed
  6. Structural complexity can be assigned thresholds and checked objectively/automatically
  7. We learn about modularity in SW-eng101Builds on complexity principles
  8. Another representation of a graphManipulation involves dragging rows and columns around