SlideShare a Scribd company logo
tung_nt@septeni-technology.jp
Pay off Technical Debt by
Good Code
...and more
TechTalk 10 - 2016
tung_nt@septeni-technology.jp
Agenda
I. Technical Debt
– What’s technical debt & why it’s important
– Bad smells
– Consequences
– Where does it come from?
II. How to deal with it?
– Supple & Clean Design
– Clean Code Principles
– Agile method
III. Measuring & Tools
– Metrics
– Code analyzer tool
IV. Resources
– Good books
tung_nt@septeni-technology.jp
I. Technical Debt
tung_nt@septeni-technology.jp
Technical Debt ?
Technical Debt is a metaphor
developed by Ward
Cunningham in 1992 to
communicate problems due
to "developing not in the right
way" with non-technical
stakeholder
tung_nt@septeni-technology.jp
2 ways to do things
Quick and Dirty Slow and Clean
tung_nt@septeni-technology.jp
You may be thinking…
tung_nt@septeni-technology.jp
Debt isn’t always a bad thing...
But don't underestimate your risks.
tung_nt@septeni-technology.jp
Cancer & Diabetes
● The top two causes of death.
● Cannot be cured.
● Difficult to diagnose: we are failing to spot them until it’s
too late ~> The Silent Killer
tung_nt@septeni-technology.jp
tung_nt@septeni-technology.jp
Because...
Technical Debt like Cancer or Diabetes, It’s a
Silent Killer too. And nobody cares until it’s to
late.
tung_nt@septeni-technology.jp
What’s your choice?
Tradeoff: Pay it now or later (...with interest)?
tung_nt@septeni-technology.jp
Don’t let the debt kill your project
tung_nt@septeni-technology.jp
Bad smells
tung_nt@septeni-technology.jp
“Only he know how to change it.”
tung_nt@septeni-technology.jp
“If I touch, everything will break.”
tung_nt@septeni-technology.jp
Too many Todos
tung_nt@septeni-technology.jp
Legacy Codebase
The code is simply unreadable, and borders on
indecipherable.
tung_nt@septeni-technology.jp
Data structures are haphazardly
constructed, or non-existent
tung_nt@septeni-technology.jp
Hard to change or scale
tung_nt@septeni-technology.jp
Code duplication
tung_nt@septeni-technology.jp
Lack of documentation
- Did we mention documentation?
- What documentation?
tung_nt@septeni-technology.jp
Consequences
tung_nt@septeni-technology.jp
Big ball of Mud
… alias Shantytown or Spaghetti Code. A big ball of mud is a
software system that lacks a perceivable architecture
tung_nt@septeni-technology.jp
Loss of Productivity
tung_nt@septeni-technology.jp
Reduce your software quality
tung_nt@septeni-technology.jp
Being scared of changing anything
tung_nt@septeni-technology.jp
Can be stress
tung_nt@septeni-technology.jp
Cost increases
tung_nt@septeni-technology.jp
Uhm, So...
tung_nt@septeni-technology.jp
Where does debt & mud come from?
tung_nt@septeni-technology.jp
Common causes
● Business pressures
● Lack of process or understanding
● Lack of building loosely coupled components
● Lack of a test suite
● Lack of documentation
● Lack of collaboration
● Parallel development
tung_nt@septeni-technology.jp
Common Causes (cont.)
● Delayed refactoring
● Lack of alignment to standards
● Lack of knowledge
● Lack of ownership
● Poor technological leadership
● Last minute specification changes
● Scope Doping
tung_nt@septeni-technology.jp
II. How to deal with them
tung_nt@septeni-technology.jp
Supple and Clean Design
tung_nt@septeni-technology.jp
Making Behavior Obvious
tung_nt@septeni-technology.jp
Intention-revealing interfaces
● Name classes and operations to describe their
effect and purpose
● These names should conform to the
Ubiquitous Language so that team members
can quickly infer their meaning.
tung_nt@septeni-technology.jp
Side-effect-free functions
● Place as much of the logic of the program as
possible into functions
● Strictly segregate commands into very simple
operations that do not return domain
information.
tung_nt@septeni-technology.jp
Assertions
● State post-conditions of operations and invariants of
classes and Aggregates.
● If Assertions cannot be coded directly in your
programming language, write automated unit tests for
them.
● Write them into documentation or diagrams where it fits
the style of the project’s development process.
● Accelerating the learning curve and reducing the risk of
contradictory code.
tung_nt@septeni-technology.jp
Reducing Cost of Change
tung_nt@septeni-technology.jp
Conceptual Contours
● Decompose design elements (operations,
interfaces, classes, and Aggregates) into
cohesive units.
tung_nt@septeni-technology.jp
Standalone Classes
● The class will be completely self-contained and
can be studied and understood alone.
● Self-contained class significantly eases the
burden of understanding a Module.
tung_nt@septeni-technology.jp
Design By Contract
● Defensive programming style
tung_nt@septeni-technology.jp
Clean code
tung_nt@septeni-technology.jp
DRY
● Don’t repeat yourself
tung_nt@septeni-technology.jp
SOLID
● S - Single responsibility principle
– a class should have only a single responsibility (i.e. only one potential change in the software's
specification should be able to affect the specification of the class)
● O - Open/closed principle
– “software entities … should be open for extension, but closed for modification.”
● L - Liskov substitution principle
– “objects in a program should be replaceable with instances of their subtypes without altering the
correctness of that program.”
● I - Interface segregation principle
– “many client-specific interfaces are better than one general-purpose interface.”
● D - Dependency inversion principle
– one should “Depend upon Abstractions. Do not depend upon concretions.”
tung_nt@septeni-technology.jp
High cohesion & Low coupling
● Loose coupling makes it possible to:
– Understand one class without reading others
– Change one class without affecting others
– Improves maintainability
● High cohesion makes it easier to:
– Understand what a class or method does
– Reuse classes or methods
tung_nt@septeni-technology.jp
YAGNI & KISS
● You aren't gonna need it
● Keep it simple, stupid
tung_nt@septeni-technology.jp
TDD
● Focus into acceptance criteria
● Make code testable
tung_nt@septeni-technology.jp
Agile method
tung_nt@septeni-technology.jp
Definition of Done (DoD)
● Clear DoD make Design By Contract and TDD
coding style applied easier
tung_nt@septeni-technology.jp
Technical backlog
● Manage by PM or Technical Leader
● Easy to monitor
– Debt size
– The velocities of debt fixing
– Fix by debt priority
● No mixture between technical and feature task
● Visible and clear to everybody
tung_nt@septeni-technology.jp
Cost of Change
● Code of change curve with the feedback cycle
tung_nt@septeni-technology.jp
Fail fast
tung_nt@septeni-technology.jp
Refactor AS SOON AS POSSIBLE
tung_nt@septeni-technology.jp
III. Measuring & Tools
tung_nt@septeni-technology.jp
Measurement
tung_nt@septeni-technology.jp
Only one rule you need remember
tung_nt@septeni-technology.jp
That’s the joke
tung_nt@septeni-technology.jp
Metric 1
● Compiler warning / error
tung_nt@septeni-technology.jp
Metric 2
● TODOs
tung_nt@septeni-technology.jp
Metric 3
● Amount of Duplicate code
tung_nt@septeni-technology.jp
Metric 4
● Test coverage & C.R.A.P index (Change Risk
Analysis and Predictions)
tung_nt@septeni-technology.jp
Metric 5
● Total Line Of Code in 1 file
@Bulk members: BulkLogicComponent.php, do you remember?
tung_nt@septeni-technology.jp
Evaluate Debt
Debt (in man days) =
cost_to_fix_duplications +
cost_to_fix_violations +
cost_to_comment_public_API +
cost_to_fix_uncovered_complexity +
cost_to_bring_complexity_below_threshold
Where :
Duplications = cost_to_fix_one_block * duplicated_blocks
Violations = cost_to fix_one_violation * mandatory_violations
Comments = cost_to_comment_one_API * public_undocumented_api
Coverage = cost_to_cover_one_of_complexity * uncovered_complexity_by_tests (80% of
coverage is the objective)
Complexity = cost_to_split_a_method * (function_complexity_distribution >= 8) + cost_to_split_a_class
* (class_complexity_distribution >= 60)
tung_nt@septeni-technology.jp
Tools
tung_nt@septeni-technology.jp
Sonarqube
● SonarQube(sonarqube.org) is an open platform to
manage code quality.
tung_nt@septeni-technology.jp
PMD - Don't shoot the messenger
● Is a source code analyzer.
● Only CPD (the copy-paste-detector) is supported for Scala :(
tung_nt@septeni-technology.jp
Jacoco – Scoverage
● Both of them are code coverage tool
● Jenkin plugin is supported
tung_nt@septeni-technology.jp
Gatling – Stress test tool
● Gatling is an open-source load testing framework based on Scala, Akka and Netty
● Scenario recorder and developer-friendly DSL
● Ready-to-present HTML reports
tung_nt@septeni-technology.jp
Resources
● Read these:
tung_nt@septeni-technology.jp
One more thing...
tung_nt@septeni-technology.jp
tung_nt@septeni-technology.jp
References
1.https://en.wikipedia.org/wiki/Technical_debt
2.http://www.levihackwith.com/how-to-read-and-improve-the-c-r-a-p-index-o
3.http://www.sonarqube.org/evaluate-your-technical-debt-with-sonar/
4.https://blog.codinghorror.com/paying-down-your-technical-debt/
5.https://dzone.com/articles/real-cost-change-software
6.http://www.agilemodeling.com/essays/costOfChange.htm
7.http://www.dodgycoder.net/2013/01/big-ball-of-mud-design-pattern.html
8.https://pressupinc.com/blog/2015/04/why-software-becomes-a-big-ball-of
9.http://www.slideshare.net/lemiorhan/technical-debt-do-not-underestimate-
10.http://www.gregerwikstrand.com/technical-debt-reduction/
tung_nt@septeni-technology.jp
Thank you!

More Related Content

PDF
Technical Debt Management
PDF
Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012
DOC
Thuy_Tran_Ngoc_-_SD0585
PPT
Effective Quality Facilitation | Beyond Normal
PDF
Interview questions-for-planning-engineers
PPTX
PDF
tony_liao_CV
PDF
Og0 091 ass2
Technical Debt Management
Campbell & Readman - TDD It's Not Tester Driven Development - EuroSTAR 2012
Thuy_Tran_Ngoc_-_SD0585
Effective Quality Facilitation | Beyond Normal
Interview questions-for-planning-engineers
tony_liao_CV
Og0 091 ass2

Viewers also liked (9)

PPTX
Marielle Briz
PPTX
Módulo 1: ¡Bienvenido!
PPT
Aino-Inkeri Hansson, Director-General of Ministry of Social Affairs and Healt...
DOC
Global warming
PDF
Intermittent Certainty Final
PDF
Robert Executive Master Trainer Cert
PDF
Sistem tata surya
PDF
Games for Business learning platform
PDF
Pekeliling spi bil 3 1999 penyediaan rph
Marielle Briz
Módulo 1: ¡Bienvenido!
Aino-Inkeri Hansson, Director-General of Ministry of Social Affairs and Healt...
Global warming
Intermittent Certainty Final
Robert Executive Master Trainer Cert
Sistem tata surya
Games for Business learning platform
Pekeliling spi bil 3 1999 penyediaan rph
Ad

Similar to Pay off Technical Debt by Good Code (20)

PPTX
Technical Debt.pptx
PDF
How to justify technical debt mitigations in Software Engineering
PDF
What scrum masters and product owners should know about software quality and ...
PDF
Technical debt management strategies
PDF
Managing technical debt
PPTX
Technical stories v1.2
PDF
Indix Engineering Culture Code (2015)
PPTX
Eliminate 7 Mudas
PDF
Agile_Project_Management_Methods_for_ERP.pdf
PDF
Technical Debt: Measured and Implied
PPTX
Software Design Principles and Best Practices - Satyajit Dey
PPTX
2015 03-siia-iin-byte9-v1
PDF
ALN_Nepal-Agile_for_the_real_world
ODP
Effective cplusplus
PDF
Distilling Agile for Effective Execution
PPTX
6 Red Flags to Watch Out for When Hiring IT Talent.pptx
PDF
Lessons learned in surviving to Technical Debt
PDF
Test driven development (TDD) in product development.pdf
PDF
Why change code that works - On Technical Debt and Refactoring
PPTX
How To Manage And Reduce Development Techical Debt
Technical Debt.pptx
How to justify technical debt mitigations in Software Engineering
What scrum masters and product owners should know about software quality and ...
Technical debt management strategies
Managing technical debt
Technical stories v1.2
Indix Engineering Culture Code (2015)
Eliminate 7 Mudas
Agile_Project_Management_Methods_for_ERP.pdf
Technical Debt: Measured and Implied
Software Design Principles and Best Practices - Satyajit Dey
2015 03-siia-iin-byte9-v1
ALN_Nepal-Agile_for_the_real_world
Effective cplusplus
Distilling Agile for Effective Execution
6 Red Flags to Watch Out for When Hiring IT Talent.pptx
Lessons learned in surviving to Technical Debt
Test driven development (TDD) in product development.pdf
Why change code that works - On Technical Debt and Refactoring
How To Manage And Reduce Development Techical Debt
Ad

More from Tung Nguyen (6)

PDF
An overview of modern scalable web development
PPTX
Circuit Breaker Pattern
PPTX
Distributed unique id generation
ODP
Implementing Domain Event with Akka
ODP
Why scala?
ODP
Specifications pattern
An overview of modern scalable web development
Circuit Breaker Pattern
Distributed unique id generation
Implementing Domain Event with Akka
Why scala?
Specifications pattern

Recently uploaded (20)

PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
August Patch Tuesday
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Digital-Transformation-Roadmap-for-Companies.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
August Patch Tuesday
Machine learning based COVID-19 study performance prediction
Group 1 Presentation -Planning and Decision Making .pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cloud_computing_Infrastucture_as_cloud_p
SOPHOS-XG Firewall Administrator PPT.pptx
Encapsulation theory and applications.pdf
Heart disease approach using modified random forest and particle swarm optimi...
MIND Revenue Release Quarter 2 2025 Press Release

Pay off Technical Debt by Good Code