Slide 1

Slide 1 text

AngularArchitects.io | @ManfredSteyer Improving Your Architecture with Forensic Analysis

Slide 2

Slide 2 text

Architecture & Code Reviews Code Review Best Practices Architectural Goals Consequences/ Trade-offs Recomentations Joint Walkthrough Developer Interviews More general: Stakeholder Interviews

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Can we support Reviews with Code Metrics?

Slide 5

Slide 5 text

First Reaction … NO!

Slide 6

Slide 6 text

Which One is More Complex? [Adam Tornhill: Your Code as a Crime Scene, 2nd edition, 2024]

Slide 7

Slide 7 text

Same „Cyclomatic Complexity“ [Adam Tornhill: Your Code as a Crime Scene, 2nd edition, 2024]

Slide 8

Slide 8 text

Goodhart‘s Law: „When a measure becomes a target, it ceases to be a good measure.“ -- Charles A. E. Goodhart

Slide 9

Slide 9 text

What‘s Important for Architects? Minimal Dependencies Vertical 1 Vertical 2 Vertical 3 Feature UI Data Conway‘s Law Feature UI Data Feature UI Data

Slide 10

Slide 10 text

What‘s Important for Architects? Low Coupling Vertical 1 Vertical 2 Vertical 3 Conway‘s Law High Cohesion High Cohesion High Cohesion Single Responsibility? Most Changes: Within ONE Verical Reduce Cognitive Load!

Slide 11

Slide 11 text

Code Churn Code that changes often: Indicator for Issues

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Forensic Analysis Source Code History History History Forensic Analysis „Hidden“ Patterns e.g., Git History

Slide 14

Slide 14 text

Agenda • Ideas behind Forensic Analysis • Tools for Forensic Analysis • Limitations of Forensic Analysis • DEMO

Slide 15

Slide 15 text

About me… Manfred Steyer, ANGULARarchitects.io (Remote) Angular Workshops and Consulting Google Developer Expert for Angular Blog, Books, Articles, and Talks about Angular Manfred Steyer

Slide 16

Slide 16 text

Forensic Analysis

Slide 17

Slide 17 text

Hot Spots [Adam Tornhill: Your Code as a Crime Scene, 2nd edition, 2024] Hotspot High Code Churn + Complex Hotspot Index Count Changes * Complexity Important Focus on specific time frame Tools used here CodeScene

Slide 18

Slide 18 text

Hot Spots [Adam Tornhill: Your Code as a Crime Scene, 2nd edition, 2024] Possible Reasons Too many responsibilities? No clear modularization? Error-prone implementation? Too little domain knowledge?

Slide 19

Slide 19 text

Change Coupling Change Coupling Parts often change together Hidden Coupling Tool used here Detective

Slide 20

Slide 20 text

Change Coupling Possible Reasons Too many responsibilities? No clear modularization? Code duplication? Domain Understanding?

Slide 21

Slide 21 text

Team/Code-Alignment Vertical 1 Vertical 2 Vertical 3 Conway‘s Law

Slide 22

Slide 22 text

Team/Code-Alignment Vertical 1 Vertical 2 Possible Reasons Verticals work against Conway‘s Law Devs ignore the official team structure

Slide 23

Slide 23 text

Tools

Slide 24

Slide 24 text

Code Scene • By Adam Tornhill • Free for Open Source Projects • Lot‘s of analysis methods • Awesome visualization • Several Programming Languages • Code & Architecture Level • https://codescene.com/

Slide 25

Slide 25 text

Detective • Our take on Forensic Analysis • Open Source • Limited to a few methods • Architecture Level • Primarily TypeScript • Focus: Help for Reviews • Appetizer for CodeScene!

Slide 26

Slide 26 text

Detective npm i @softarc/detective –D npx detective

Slide 27

Slide 27 text

Limitations

Slide 28

Slide 28 text

Awesome, but not a replacement for … Code Review Best Practices Architectural Goals Consequences/ Trade-offs Recomentations Joint Walkthrough Developer Interviews More general: Stakeholder Interviews

Slide 29

Slide 29 text

However, a tempting addition … Code Review Best Practices Architectural Goals Consequences/ Trade-offs Recomentations Joint Walkthrough Developer Interviews More general: Stakeholder Interviews (Forensic) Analysis Better Questions

Slide 30

Slide 30 text

Conclusion • Metrics: Grain of Salt • Metrics should not become a target! • Low Coupling, High Cohesion, Conway’s Law

Slide 31

Slide 31 text

Conclusion • Hot Spots = High Change Rate + High Complexity • Change Coupling • Team/Code Alignment

Slide 32

Slide 32 text

Conclusion • No replacement for qualitative approaches! • … but a nice addition

Slide 33

Slide 33 text

Try it out Now in Your Project! npm i @softarc/detective –D npx detective https://github.com/angular-architects/detective/issues … and provide feedback:

Slide 34

Slide 34 text

Contact and Downloads [web] ANGULARarchitects.io [twitter] ManfredSteyer d Slides & Examples Remote and In-House http://softwarearchitekt.at/workshops