(As presented at Boston, New York, San Francisco JUGs 2018)
Static diagrams on wikis and white-boards might capture the vision of architects, but they don’t much help programmers to understand how the code they’re working on right now fits into the architecture. Nor are the programmers warned when they violate the diagrams as they forge changes, line-by-line.
This is a huge problem – it is ultimately individual lines of code that make or break an architecture; and we know that a clean architecture will help teams develop a more flexible product, with less complexity, less wasted effort, etc. Worse, without practical architectural guidance, programmers wrestle with invisible structures that emerge from thousands of inter-dependent lines of code. And being invisible, these structures become ever more complex, coupled, and tangled.
In fact, uncontrolled structure actively fights against productive development.
This talk shows how to rein in emergent code-base structures and gradually transform them into a cogent, defined architecture.
5. • Map for developers
• Phased development
• Divide work
• Modularity
• Reuse/replace subsystems
• Impact/regression control
• Productive development
Architecture - remind me why…
7. • Any architecture is not really real
– No mapping from diagrams to the code
– No mapping from code to diagrams
8. • Any architecture is not really real
– No mapping from diagrams to the code
– No mapping from code to diagrams
• Any structure/architecture is invisible
– No help to developers
– Gets more tangled and complex
– Fights against development
9. Bridging the gap v1
• Expose what is real now
• Attach a bit of architecture to the goodness
• Let the goodness grow
22. Bridging the gap v2
1. Start visualizing the structure you have now
23. Bridging the gap v2
1. Start visualizing the structure you have now
2. Lock-in and shore-up any good architecture
you have now – overlay the visualization
24. Bridging the gap v2
1. Start visualizing the structure you have now
2. Lock-in and shore-up any good architecture
you have now – overlay the visualization
3. Improve/extend the architecture –
development gets easier and easier
25. • You’re going to need a tool…
• That parses code
• Hierarchical dependency model
• Architectural overlays
26. • You’re going to need a tool…
• That parses code
• Hierarchical dependency model
• Architectural overlays
• SonarGraph
Hierarchical
dependency graph
27. DSM - Dependency Structure Matrix
• You’re going to need a tool…
• That parses code
• Hierarchical dependency model
• Architectural overlays
• SonarGraph
• Lattix
• IntelliJ Idea Ultimate
Hierarchical
dependency graph
28. DSM - Dependency Structure Matrix
LSM – Levelized Structure Map
• You’re going to need a tool…
• That parses code
• Hierarchical dependency model
• Architectural overlays
• SonarGraph
• Lattix
• IntelliJ Idea Ultimate
• Structure101
Hierarchical
dependency graph
30. Step 1: Visualize what you have
• Immediate productivity boost
– A (filtered) map of the codebase
31. Step 1: Visualize what you have
• Immediate productivity boost
– A (filtered) map of the codebase
• See the details in the context of the de facto
architecture, e.g.
– Eclipse projects
– IntelliJ modules
– Maven POMs
– Java 9 modules
– …
32. Step 1: Visualize what you have
• Immediate productivity boost
– A (filtered) map of the codebase
• See the details in the context of the de facto
architecture, e.g.
– Eclipse projects
– IntelliJ modules
– Maven POMs
– Java 9 modules
– …
• Raise structural awareness
– Start simplifying the codebase - reduce coupling and
complexity
33. Step 2: Lock in and shore up de facto
architecture
• Organize modules into groups
• Specify module dependency constraints
• Overlay onto the visualization
– Understand the details in the context of the spec’d
architecture
– Warned immediately if edits violate spec
34. Step 3: Incrementally improve the
architecture/structure
• Deal with the monoliths
– Increase %specified
• Lift lower packages into modules
• Disentangle packages…
– Small/easy: In the code
– Broader: Simulate first
– Move classes, then refactor for dependencies
• … and/or Extract modules
– Simulate first
– Add new module to spec
– Refactor for dependencies, then move classes
36. Bridging the gap…
Summary
1. Start visualizing the structure you have now
2. Lock-in and shore-up any good architecture
you have now – overlay the visualization
3. Improve/extend the architecture –
development gets easier and easier