Reference: Your Code as a Crime Scene

1 downloads 142 Views 25MB Size Report
Important. Reference: Predicting fault incidence using software change history (Graves, et. al, 2000) ... Analyzing Arch
Seven Secrets of Maintainable Codebases

@AdamTornhill [email protected] https://codescene.io

Let’s Turn The Microscope

Behavioural Data

#0: Maintainable Code goes Beyond Technology

The challenges of Scale

JavaScript CSS HTML

Automated Tests (Python/Ruby)

.NET/ Java

SQL

The challenges of Scale

JavaScript CSS HTML

Automated Tests (Python/Ruby)

.NET/ Java

SQL

#1: All Code is Equal …but some Code is more equal than others*

* Sorry, George Orwell

Change Distribution of Files 6 Years of Erlang

12 Years of Ruby on Rails

Change Frequency

1 Year in Roslyn (C#, VB)

Each file in the system

Focus on the Code that Matters Important

Less Important

Reference: Predicting fault incidence using software change history (Graves, et. al, 2000)

#2 - Complexity isn’t the problem …at least not on its own.

56 crimes! Probability surface

Most probable home location

Dragnet screenshot used with permission from David Canter

2437 commits, 67 authors! Probability surface

Most probable maintenance savings @AdamTornhill

Hotspot Code Complexity

Code Change Frequency @AdamTornhill

Hotspots in Roslyn

CommandLineTests.cs

C# VisualBasic CommandLineTests.vb

Different Kinds of Code?

Automated Checks

Complex Code

Prioritize with Hotspots

Important

Hotspots: ~3-6% of the total Code

Reference: Your Code as a Crime Scene, ISBN:1680500384

#3 Your Brain is not your friend

@AdamTornhill

Where Are your Hotspots?

Where’s the Gorilla in your Code?

We Don’t Know What We Do

Bonus

@AdamTornhill

Support Your Decisions with Data

#4 - Know Your Change Patterns

The Cost of Surprise VRTSTART TS WCHVERT # Page 801 CAF TWO # TS WCHPHOLD TS WCHPHASE TC BANKCALL # CADR STOPRATE # TC DOWNFLAG # ADRES XOVINFLG TC DOWNFLAG ADRES REDFLAG TCF VERTGUID

@AdamTornhill

WCHPHASE = 2 ---> VERTICAL: P65,P66,P67 TEMPORARY, I HOPE HOPE HOPE TEMPORARY, I HOPE HOPE HOPE PERMIT X-AXIS OVERRIDE

Temporal Coupling Code That Changes Together Over Time

Read More: http://www.empear.com/blog/software-revolution-part3/

Physical Coupling MvcOptionsSetup.cs

Expected to change together

MvcOptionsSetupTests.cs @AdamTornhill

Reference: https://codescene.io/showcase

Logical Coupling

Coupled in 89% of commits

ScriptTagHelper.cs

LinkTagHelper.cs

Reference: https://codescene.io/showcase

Analyzing Architectures Service #1

Service #2

Service #4

@AdamTornhill

Service #3

Service #5

Tem

po

ral C

Service #4 ou

Service #5

Client Lib

Service #3

plin