This document discusses technical debt and code quality. It explains that software engineers spend most of their time reading code rather than writing it, and identifies factors that slow this down such as bad code structure, duplication, lack of architecture and lack of tests. These problems can be addressed through techniques like automated testing, test-driven development, and tools to analyze code quality. Recognizing where technical debt exists is the first step to improving code and paying it down.
25. Amdahl’s Law
S =
1
(1 − p) + p
s
Where:
p - portion of whole to speed up
s - speed up factor
25 / 41
26. Amdahl’s Law
S =
1
(1 − p) + p
s
Where:
p - portion of whole to speed up
s - speed up factor
Optimistic assumption 80% reading
20% writing
Speed up factor of 2
Double the speed to write code →
10% overall improvement
Double the speed to read code →
60% overall improvement
26 / 41
30. Bad structure : Ravioli Code
100s or 1000s of classes
No cohesion
Each code change affects
30-40 classes
Did we break anything by
the change?
30 / 41
31. Bad structure : Lasagna Code
A lot of layers
Hard to comprehend what happens
where
Hard to understand impact of the
change
31 / 41
32. Copy Pasta
Need new method similar to
existing one
NO PROBLEMO!
Copy paste existing method
Rename and modify
32 / 41
33. Lack of architecture
Let’s just write code
Planning slows things down
We need to get things out fast
This prototype is good enough to ship
33 / 41
34. Lack of common style
Even problem for projects of one
Mental switch delay looking at different parts
Huge restyling change sets for code reviews
Hard to compare history (git bisect)
34 / 41
35. Lack of tests
Unit, Integration, E2E
No safety net
Anxiety and resistance to change
Not clear which parts affected by change
35 / 41
39. Recognize the problem
Reckless Prudent
Deliberate We don’t have time for
design
We must ship now and
deal with consequences
later
Inadvertent What’s layering? Now we know how we
should’ve done it
From Robert Martin (Uncle Bob) technical debt quadrant5
5
https://bit.ly/2XDS2QZ
39 / 41
40. Techniques to use
Automated Testing
Unit
Integration
E2E
TDD
Pay down the debt
Throw away your prototypes
40 / 41
41. Tools to help
Py McCabe6
PyLint7
SonarQube8
6
https://bit.ly/3exl5g6
7
https://pypi.org/project/pylint/
8
https://bit.ly/2M707Iq
41 / 41