SlideShare una empresa de Scribd logo
1 de 55
Descargar para leer sin conexión
Rewrite or Refactor
When to declare technical bankruptcy
Laura Thomson (laura@mozilla.com)
OSCON - July 22, 2010
                                       1
Technical debt

“Shipping first time code is like going into debt. A little debt speeds
development so long as it is paid back promptly with a rewrite... The
danger occurs when the debt is not repaid. Every minute spent on
not-quite-right code counts as interest on that debt. Entire engineering
organizations can be brought to a stand-still under the debt load of an
unconsolidated implementation, object-oriented or otherwise.”

        - Ward Cunningham, “The WyCash Portfolio Management
        System”, OOPSLA 1992



                                                                       2
“Doing things the quick and dirty way sets us up with a technical
debt, which is similar to a financial debt. Like a financial debt, the
technical debt incurs interest payments, which come in the form of
the extra effort that we have to do in future development because of
the quick and dirty design choice. We can choose to continue paying
the interest, or we can pay down the principal by refactoring the
quick and dirty design into the better design. Although it costs to pay
down the principal, we gain by reduced interest payments in the
future.”

                 - Martin Fowler
                (Source: http://martinfowler.com/bliki/TechnicalDebt.html

                                                                            3
Technical Inflation


 "Technical Inflation could be viewed as the ground lost when the
 current level of technology surpasses that of the foundation of your
 product to the extent that it begins losing compatibility with the
 industry. Examples of this would be falling behind in versions of a
 language to the point where your code is no longer compatible with
 main stream compilers."

                - Scott Wood



                                                                        4
Technical bankruptcy

“Technical bankruptcy is a level of technical debt where at least one of
the following applies:

   ✤   debt is accumulating faster than it can be cleared

   ✤   the time to clear debt would be longer than re-implementing the
       system from scratch cleanly

   ✤   sustainable people power to clear debt is unavailable”

               - me, 2010

                                                                         5
You might have a technical debt
if...




                                  6
“We’ll write the documentation later.”




                                         7
“We’ll write the documentation later.”

“Where’s the documentation?”




                                         8
“We’ll write the documentation later.”

“Where’s the documentation?”

“There are some comments, a wiki page someone put
together over there, and you should read these five bug
reports.”




                                                     9
“We don’t have any tests.”




                             10
“We don’t have any tests.”

“It’s normal to have 86 failing tests. Those are out of
date. If you have 87 fail, then you have something to
worry about.”




                                                          11
“We don’t have any tests.”

“It’s normal to have 86 failing tests. Those are out of
date. If you have 87 fail, then you have something to
worry about.”

“We have some Selenium tests for the front end. It was
the only way to start testing 500K lines of code.”



                                                          12
“You can just leave a TODO.”




                               13
“You can just leave a TODO.”

“Better mark that HACKHACKHACK. We’ll fix it
later.”




                                              14
“You can just leave a TODO.”

“Better mark that HACKHACKHACK. We’ll fix it
later.”

“Don’t touch that code marked XXX. Nobody knows
how it works and last time we tried to change it
everything broke.”



                                                   15
“Ignore the deprecation warnings from the compiler.”




                                                       16
“Ignore the deprecation warnings from the compiler.”




“You’d better turn the error reporting level down.”




                                                       17
“In order to upgrade to the newest version of the
framework, we’ll need to port our local changes.”




                                                    18
“In order to upgrade to the newest version of the
framework, we’ll need to port our local changes.”

“This upgrade will take about six months. Maybe
longer.”




                                                    19
“In order to upgrade to the newest version of the
framework, we’ll need to port our local changes.”

“This upgrade will take about six months. Maybe
longer.”

“We need to decide whether to use their
implementation or ours.”



                                                    20
“This cycle we closed 25 bugs. 37 new bugs were
filed.”




                                                  21
“This cycle we closed 25 bugs. 37 new bugs were
filed.”

“Adding that new feature will take 3 months. Yes, I
know it’s trivial.”




                                                      22
“Joe went to work for Google. Mary quit to do a
knitting startup. We don’t know what happened to
Phong, he just stopped showing up.”




                                                   23
“Joe went to work for Google. Mary quit to do a
knitting startup. We don’t know what happened to
Phong, he just stopped showing up.”

“Nobody wants to work on the project.”




                                                   24
“Joe went to work for Google. Mary quit to do a
knitting startup. We don’t know what happened to
Phong, he just stopped showing up.”

“Nobody wants to work on the project.”

“Which one of you sent that to dailywtf/Coding
Horror?”



                                                   25
Debt reduction strategies




                            26
Getting out of debt

✤   What would we need to do to:

    ✤   write the missing documentation?

    ✤   fix the tests / get decent test coverage?

    ✤   make the code less ugly /fragile?

✤   How long would this take?

✤   Should we refactor, or just rewrite it?

                                                   27
Take stock

✤   Audit what you have:

    ✤   Documentation? Tests? Ugly/fragile modules?

    ✤   Process?

✤   What’s the worst part? (What do you dread?)

✤   How long would each of these take to fix?

    ✤   If it’s as simple as catching up on tests or docs, hire a contractor/
        intern and just do it
                                                                                28
Refactoring project plan

✤   Treat refactoring like any other project or feature:

    ✤   Break into a series of achievable tasks

    ✤   Come up with a realistic timeline and resource requirements

    ✤   Work on the pieces in isolation or in parallel with other projects

    ✤   Staff it seriously

    ✤   If working in parallel, account for dependencies

                                                                             29
Starting over

✤   If we threw the system away and started over:

    ✤   How long would it take to get to where we are now? Is this less or
        more time than getting totally out of debt?

    ✤   Can we cope with a lack of visible forward progress for that
        amount of time?

        ✤   Still need to fix critical and security bugs on old system

    ✤   What makes us think a new system will be any better?

                                                                         30
Starting over with new tools

✤   Are there platforms or components which will get us there faster?

✤   Common argument is that switching toolset will improve all kinds of
    things:

    ✤   Is it just greener grass?

    ✤   Does the team have the skills to pull it off?

    ✤   Will a system written by novices look better in 2-3 years?

    ✤   Is our potential use of the new tool weird/different/larger scale
        than existing users?
                                                                            31
SUMO:
a case study in technical debt




                                 32
SUMO: a case study


✤   SUMO is support.mozilla.com

✤   SUMO began in 2007 and was launched in 2008 in time for the release
    of Firefox 3

✤   Based on TikiWiki 1.10 with (necessary) extensive customizations

✤   In 2009 we reached the camel point (more on this in a minute)



                                                                       33
Scaling SUMO

✤   Lot of work done to make TikiWiki scale:

    ✤   replication

    ✤   memcache

    ✤   tons of profiling, query changes, code rewrites, cutting includes

    ✤   rewrote security code to make it faster

    ✤   I have an hour long presentation on this but basically we went
        from serving 8 requests per second per webhead to 300+
                                                                           34
Camel point

✤   TikiWiki was now at version 3 (with 4 in the oven)

✤   Our patches had not made it into trunk, making it hard to upgrade

✤   Still slow; timeouts on admin and edit pages in particular made
    localizers sad

✤   Adding new features made developers sad too

✤   Our debt had become unmanageable; we needed to find some relief
    (and not from a late night 1-800 number)

                                                                        35
Possible options


✤   Upgrade: work hard on upstreaming all our changes into trunk, then
    switch to 4.1

✤   Fork: Refactor and rewrite the app as needed, heading in a different
    direction from the Tiki project

✤   Port: go to a completely different platform



                                                                           36
Upgrade


✤   We decided initially to go with this option, working with the Tiki
    community to get our changes into trunk (being good Open Source
    citizens)

✤   All our changes were reviewed (18 months worth of code) to see if
    they were appropriate for Tiki, and upstreamed

✤   We reviewed Tiki 4 to see how it had changed



                                                                         37
Revisiting our decision

✤   After several months decided to revisit decision:

    ✤   Many of our local changes were not accepted into trunk, so would
        have to be maintained locally

    ✤   Some of our issues with the code had not changed, and some had
        become worse

    ✤   Many features in the code we didn’t use, and these were expanding
        rapidly

    ✤   Still limited tests
                                                                           38
Rewrite

✤   Evaluated possible solutions as part of the initial process; upgrade
    initially looked good for the same reason we chose TikiWiki in the
    first place

✤   If no upgrade possible, then only one choice remained: rewrite from
    scratch.

    ✤   Developers hugely enthusiastic

✤   Project begain at the end of Q1 and has now partially launched;
    SUMO is now running on a hybrid of TikiWiki and Django

    ✤   addons.mozilla.org also being rewritten in Django (from CakePHP)
                                                                           39
Morals of the story

✤   It’s not always as simple as “write some tests”

✤   Developer happiness is a critical factor

✤   Maintaining local changes is always painful



✤   Sometimes your debt is just too big to recover from. You need to
    declare technical bankruptcy and start over.

                                                                       40
Some other minor case studies

✤   Trade magazine (Joomla -> Wordpress)

    ✤   Speed, developer availability

✤   addons.mozilla.org (CakePHP -> Django)

    ✤   Too many local modifications, developer happiness

✤   Electric company website (perl -> PHP)

    ✤   Death march project, needed fresh start

                                                           41
Why rewrites fail




                    42
“This will solve all our problems”

 “This new language is faster/cooler/more maintainable/scales better”




                                                                        43
“This will solve all our problems”

 “This new language is faster/cooler/more maintainable/scales better”

 “This new platform/framework is better/faster/cooler/more maintainable/scales
 better”




                                                                                 44
“This will solve all our problems”

 “This new language is faster/cooler/more maintainable/scales better”

 “This new platform/framework is better/faster/cooler/more maintainable/scales
 better”

 “This new database is better/faster/doesn’t use SQL”




                                                                                 45
“This will solve all our problems”

 “This new language is faster/cooler/more maintainable/scales better”

 “This new platform/framework is better/faster/cooler/more maintainable/scales
 better”

 “This new database is better/faster/doesn’t use SQL”

 “This new development team is better/more experienced/wear cooler hats”




                                                                                 46
“This will solve all our problems”

 “This new language is faster/cooler/more maintainable/scales better”

 “This new platform/framework is better/faster/cooler/more maintainable/scales
 better”

 “This new database is better/faster/doesn’t use SQL”

 “This new development team is better/more experienced/wear cooler hats”

 “This new project manager is better/certified/always says yes”




                                                                                 47
“This will solve all our problems”

 “This new language is faster/cooler/more maintainable/scales better”

 “This new platform/framework is better/faster/cooler/more maintainable/scales
 better”

 “This new database is better/faster/doesn’t use SQL”

 “This new development team is better/more experienced/wear cooler hats”

 “This new project manager is better/certified/always says yes”

 “Now that we’re agile, we won’t have any problems.”



                                                                                 48
“Now that we’re rewriting it...”


 “...we may as well add all these new features we’ve wanted for a long
 time, and couldn’t build because the old system was so hard to work
 with.”




                                                                     49
“Now that we’re rewriting it...”


 “...we may as well add all these new features we’ve wanted for a long
 time, and couldn’t build because the old system was so hard to work
 with.”

 “...let’s incorporate these five other systems and just have one system
 that does everything. It will reduce duplication of effort.”




                                                                      50
“Now that we’re rewriting it...”


 “...we may as well add all these new features we’ve wanted for a long
 time, and couldn’t build because the old system was so hard to work
 with.”

 “...let’s incorporate these five other systems and just have one system
 that does everything. It will reduce duplication of effort.”

 “We won’t need any documentation because FooPlatform is so easy to
 understand/self-documenting/more maintainable.”


                                                                      51
“A rewrite will take less time...”



 “...because we’ve already built the system once, so we know what
 we’re doing.”




                                                                    52
“A rewrite will take less time...”



 “...because we’ve already built the system once, so we know what
 we’re doing.”

 “...because our new toolkit allows for faster development.”




                                                                    53
Think

✤   What will we do differently this time?

    ✤   Will we tweak the environment to ensure we write docs and tests?

    ✤   Will we allow enough time to build the system properly?

    ✤   Will we beat scope creep to death every time it appears?

✤   Simply rewriting or changing platforms won’t solve structural,
    environmental, or cultural problems (here be dragons)

                                                                           54
A brave new world...



✤   Questions, feedback, comments...

✤   laura@mozilla.com




                                       55

Más contenido relacionado

Similar a Rewrite or refactor: When to declare technical bankruptcy

DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCEDEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DrupalCamp Kyiv
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
estefana2345678
 

Similar a Rewrite or refactor: When to declare technical bankruptcy (20)

Managing Technical Debt
Managing Technical DebtManaging Technical Debt
Managing Technical Debt
 
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCEDEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
 
Clone Clone Make: a better way to build
Clone Clone Make: a better way to buildClone Clone Make: a better way to build
Clone Clone Make: a better way to build
 
How to justify technical debt mitigations in Software Engineering
How to justify technical debt mitigations in Software EngineeringHow to justify technical debt mitigations in Software Engineering
How to justify technical debt mitigations in Software Engineering
 
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
.NET Fest 2019. Леонид Молотиевский. DotNet Core in production
 
Beyond Technical Debt: Unconventional techniques to uncover technical and soc...
Beyond Technical Debt: Unconventional techniques to uncover technical and soc...Beyond Technical Debt: Unconventional techniques to uncover technical and soc...
Beyond Technical Debt: Unconventional techniques to uncover technical and soc...
 
Everyone wants (someone else) to do it: writing documentation for open source...
Everyone wants (someone else) to do it: writing documentation for open source...Everyone wants (someone else) to do it: writing documentation for open source...
Everyone wants (someone else) to do it: writing documentation for open source...
 
From hello world to goodbye code
From hello world to goodbye codeFrom hello world to goodbye code
From hello world to goodbye code
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
 
stackconf 2023 | Better Living by Changing Less – IncrativeOps by Michael Cot...
stackconf 2023 | Better Living by Changing Less – IncrativeOps by Michael Cot...stackconf 2023 | Better Living by Changing Less – IncrativeOps by Michael Cot...
stackconf 2023 | Better Living by Changing Less – IncrativeOps by Michael Cot...
 
2013: Trends from the Trenches
2013: Trends from the Trenches2013: Trends from the Trenches
2013: Trends from the Trenches
 
Where refactoring meets big $$$
Where refactoring meets big $$$Where refactoring meets big $$$
Where refactoring meets big $$$
 
AWS Community Day: From Monolith to Microservices - What Could Go Wrong?
AWS Community Day: From Monolith to Microservices - What Could Go Wrong?AWS Community Day: From Monolith to Microservices - What Could Go Wrong?
AWS Community Day: From Monolith to Microservices - What Could Go Wrong?
 
Monolith to serverless service based architectures in the enterprise
Monolith to serverless  service based architectures in the enterpriseMonolith to serverless  service based architectures in the enterprise
Monolith to serverless service based architectures in the enterprise
 
From 🤦 to 🐿️
From 🤦 to 🐿️From 🤦 to 🐿️
From 🤦 to 🐿️
 
SRE Topics with Charity Majors and Liz Fong-Jones of Honeycomb
SRE Topics with Charity Majors and Liz Fong-Jones of HoneycombSRE Topics with Charity Majors and Liz Fong-Jones of Honeycomb
SRE Topics with Charity Majors and Liz Fong-Jones of Honeycomb
 
What is this cloud thing?
What is this cloud thing?What is this cloud thing?
What is this cloud thing?
 
From Duke of DevOps to Queen of Chaos - Api days 2018
From Duke of DevOps to Queen of Chaos - Api days 2018From Duke of DevOps to Queen of Chaos - Api days 2018
From Duke of DevOps to Queen of Chaos - Api days 2018
 
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...
Your Testing Is Flawed: Introducing A New Open Source Tool For Accurate Kuber...
 
Technical debt management strategies
Technical debt management strategiesTechnical debt management strategies
Technical debt management strategies
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Rewrite or refactor: When to declare technical bankruptcy

  • 1. Rewrite or Refactor When to declare technical bankruptcy Laura Thomson (laura@mozilla.com) OSCON - July 22, 2010 1
  • 2. Technical debt “Shipping first time code is like going into debt. A little debt speeds development so long as it is paid back promptly with a rewrite... The danger occurs when the debt is not repaid. Every minute spent on not-quite-right code counts as interest on that debt. Entire engineering organizations can be brought to a stand-still under the debt load of an unconsolidated implementation, object-oriented or otherwise.” - Ward Cunningham, “The WyCash Portfolio Management System”, OOPSLA 1992 2
  • 3. “Doing things the quick and dirty way sets us up with a technical debt, which is similar to a financial debt. Like a financial debt, the technical debt incurs interest payments, which come in the form of the extra effort that we have to do in future development because of the quick and dirty design choice. We can choose to continue paying the interest, or we can pay down the principal by refactoring the quick and dirty design into the better design. Although it costs to pay down the principal, we gain by reduced interest payments in the future.” - Martin Fowler (Source: http://martinfowler.com/bliki/TechnicalDebt.html 3
  • 4. Technical Inflation "Technical Inflation could be viewed as the ground lost when the current level of technology surpasses that of the foundation of your product to the extent that it begins losing compatibility with the industry. Examples of this would be falling behind in versions of a language to the point where your code is no longer compatible with main stream compilers." - Scott Wood 4
  • 5. Technical bankruptcy “Technical bankruptcy is a level of technical debt where at least one of the following applies: ✤ debt is accumulating faster than it can be cleared ✤ the time to clear debt would be longer than re-implementing the system from scratch cleanly ✤ sustainable people power to clear debt is unavailable” - me, 2010 5
  • 6. You might have a technical debt if... 6
  • 7. “We’ll write the documentation later.” 7
  • 8. “We’ll write the documentation later.” “Where’s the documentation?” 8
  • 9. “We’ll write the documentation later.” “Where’s the documentation?” “There are some comments, a wiki page someone put together over there, and you should read these five bug reports.” 9
  • 10. “We don’t have any tests.” 10
  • 11. “We don’t have any tests.” “It’s normal to have 86 failing tests. Those are out of date. If you have 87 fail, then you have something to worry about.” 11
  • 12. “We don’t have any tests.” “It’s normal to have 86 failing tests. Those are out of date. If you have 87 fail, then you have something to worry about.” “We have some Selenium tests for the front end. It was the only way to start testing 500K lines of code.” 12
  • 13. “You can just leave a TODO.” 13
  • 14. “You can just leave a TODO.” “Better mark that HACKHACKHACK. We’ll fix it later.” 14
  • 15. “You can just leave a TODO.” “Better mark that HACKHACKHACK. We’ll fix it later.” “Don’t touch that code marked XXX. Nobody knows how it works and last time we tried to change it everything broke.” 15
  • 16. “Ignore the deprecation warnings from the compiler.” 16
  • 17. “Ignore the deprecation warnings from the compiler.” “You’d better turn the error reporting level down.” 17
  • 18. “In order to upgrade to the newest version of the framework, we’ll need to port our local changes.” 18
  • 19. “In order to upgrade to the newest version of the framework, we’ll need to port our local changes.” “This upgrade will take about six months. Maybe longer.” 19
  • 20. “In order to upgrade to the newest version of the framework, we’ll need to port our local changes.” “This upgrade will take about six months. Maybe longer.” “We need to decide whether to use their implementation or ours.” 20
  • 21. “This cycle we closed 25 bugs. 37 new bugs were filed.” 21
  • 22. “This cycle we closed 25 bugs. 37 new bugs were filed.” “Adding that new feature will take 3 months. Yes, I know it’s trivial.” 22
  • 23. “Joe went to work for Google. Mary quit to do a knitting startup. We don’t know what happened to Phong, he just stopped showing up.” 23
  • 24. “Joe went to work for Google. Mary quit to do a knitting startup. We don’t know what happened to Phong, he just stopped showing up.” “Nobody wants to work on the project.” 24
  • 25. “Joe went to work for Google. Mary quit to do a knitting startup. We don’t know what happened to Phong, he just stopped showing up.” “Nobody wants to work on the project.” “Which one of you sent that to dailywtf/Coding Horror?” 25
  • 27. Getting out of debt ✤ What would we need to do to: ✤ write the missing documentation? ✤ fix the tests / get decent test coverage? ✤ make the code less ugly /fragile? ✤ How long would this take? ✤ Should we refactor, or just rewrite it? 27
  • 28. Take stock ✤ Audit what you have: ✤ Documentation? Tests? Ugly/fragile modules? ✤ Process? ✤ What’s the worst part? (What do you dread?) ✤ How long would each of these take to fix? ✤ If it’s as simple as catching up on tests or docs, hire a contractor/ intern and just do it 28
  • 29. Refactoring project plan ✤ Treat refactoring like any other project or feature: ✤ Break into a series of achievable tasks ✤ Come up with a realistic timeline and resource requirements ✤ Work on the pieces in isolation or in parallel with other projects ✤ Staff it seriously ✤ If working in parallel, account for dependencies 29
  • 30. Starting over ✤ If we threw the system away and started over: ✤ How long would it take to get to where we are now? Is this less or more time than getting totally out of debt? ✤ Can we cope with a lack of visible forward progress for that amount of time? ✤ Still need to fix critical and security bugs on old system ✤ What makes us think a new system will be any better? 30
  • 31. Starting over with new tools ✤ Are there platforms or components which will get us there faster? ✤ Common argument is that switching toolset will improve all kinds of things: ✤ Is it just greener grass? ✤ Does the team have the skills to pull it off? ✤ Will a system written by novices look better in 2-3 years? ✤ Is our potential use of the new tool weird/different/larger scale than existing users? 31
  • 32. SUMO: a case study in technical debt 32
  • 33. SUMO: a case study ✤ SUMO is support.mozilla.com ✤ SUMO began in 2007 and was launched in 2008 in time for the release of Firefox 3 ✤ Based on TikiWiki 1.10 with (necessary) extensive customizations ✤ In 2009 we reached the camel point (more on this in a minute) 33
  • 34. Scaling SUMO ✤ Lot of work done to make TikiWiki scale: ✤ replication ✤ memcache ✤ tons of profiling, query changes, code rewrites, cutting includes ✤ rewrote security code to make it faster ✤ I have an hour long presentation on this but basically we went from serving 8 requests per second per webhead to 300+ 34
  • 35. Camel point ✤ TikiWiki was now at version 3 (with 4 in the oven) ✤ Our patches had not made it into trunk, making it hard to upgrade ✤ Still slow; timeouts on admin and edit pages in particular made localizers sad ✤ Adding new features made developers sad too ✤ Our debt had become unmanageable; we needed to find some relief (and not from a late night 1-800 number) 35
  • 36. Possible options ✤ Upgrade: work hard on upstreaming all our changes into trunk, then switch to 4.1 ✤ Fork: Refactor and rewrite the app as needed, heading in a different direction from the Tiki project ✤ Port: go to a completely different platform 36
  • 37. Upgrade ✤ We decided initially to go with this option, working with the Tiki community to get our changes into trunk (being good Open Source citizens) ✤ All our changes were reviewed (18 months worth of code) to see if they were appropriate for Tiki, and upstreamed ✤ We reviewed Tiki 4 to see how it had changed 37
  • 38. Revisiting our decision ✤ After several months decided to revisit decision: ✤ Many of our local changes were not accepted into trunk, so would have to be maintained locally ✤ Some of our issues with the code had not changed, and some had become worse ✤ Many features in the code we didn’t use, and these were expanding rapidly ✤ Still limited tests 38
  • 39. Rewrite ✤ Evaluated possible solutions as part of the initial process; upgrade initially looked good for the same reason we chose TikiWiki in the first place ✤ If no upgrade possible, then only one choice remained: rewrite from scratch. ✤ Developers hugely enthusiastic ✤ Project begain at the end of Q1 and has now partially launched; SUMO is now running on a hybrid of TikiWiki and Django ✤ addons.mozilla.org also being rewritten in Django (from CakePHP) 39
  • 40. Morals of the story ✤ It’s not always as simple as “write some tests” ✤ Developer happiness is a critical factor ✤ Maintaining local changes is always painful ✤ Sometimes your debt is just too big to recover from. You need to declare technical bankruptcy and start over. 40
  • 41. Some other minor case studies ✤ Trade magazine (Joomla -> Wordpress) ✤ Speed, developer availability ✤ addons.mozilla.org (CakePHP -> Django) ✤ Too many local modifications, developer happiness ✤ Electric company website (perl -> PHP) ✤ Death march project, needed fresh start 41
  • 43. “This will solve all our problems” “This new language is faster/cooler/more maintainable/scales better” 43
  • 44. “This will solve all our problems” “This new language is faster/cooler/more maintainable/scales better” “This new platform/framework is better/faster/cooler/more maintainable/scales better” 44
  • 45. “This will solve all our problems” “This new language is faster/cooler/more maintainable/scales better” “This new platform/framework is better/faster/cooler/more maintainable/scales better” “This new database is better/faster/doesn’t use SQL” 45
  • 46. “This will solve all our problems” “This new language is faster/cooler/more maintainable/scales better” “This new platform/framework is better/faster/cooler/more maintainable/scales better” “This new database is better/faster/doesn’t use SQL” “This new development team is better/more experienced/wear cooler hats” 46
  • 47. “This will solve all our problems” “This new language is faster/cooler/more maintainable/scales better” “This new platform/framework is better/faster/cooler/more maintainable/scales better” “This new database is better/faster/doesn’t use SQL” “This new development team is better/more experienced/wear cooler hats” “This new project manager is better/certified/always says yes” 47
  • 48. “This will solve all our problems” “This new language is faster/cooler/more maintainable/scales better” “This new platform/framework is better/faster/cooler/more maintainable/scales better” “This new database is better/faster/doesn’t use SQL” “This new development team is better/more experienced/wear cooler hats” “This new project manager is better/certified/always says yes” “Now that we’re agile, we won’t have any problems.” 48
  • 49. “Now that we’re rewriting it...” “...we may as well add all these new features we’ve wanted for a long time, and couldn’t build because the old system was so hard to work with.” 49
  • 50. “Now that we’re rewriting it...” “...we may as well add all these new features we’ve wanted for a long time, and couldn’t build because the old system was so hard to work with.” “...let’s incorporate these five other systems and just have one system that does everything. It will reduce duplication of effort.” 50
  • 51. “Now that we’re rewriting it...” “...we may as well add all these new features we’ve wanted for a long time, and couldn’t build because the old system was so hard to work with.” “...let’s incorporate these five other systems and just have one system that does everything. It will reduce duplication of effort.” “We won’t need any documentation because FooPlatform is so easy to understand/self-documenting/more maintainable.” 51
  • 52. “A rewrite will take less time...” “...because we’ve already built the system once, so we know what we’re doing.” 52
  • 53. “A rewrite will take less time...” “...because we’ve already built the system once, so we know what we’re doing.” “...because our new toolkit allows for faster development.” 53
  • 54. Think ✤ What will we do differently this time? ✤ Will we tweak the environment to ensure we write docs and tests? ✤ Will we allow enough time to build the system properly? ✤ Will we beat scope creep to death every time it appears? ✤ Simply rewriting or changing platforms won’t solve structural, environmental, or cultural problems (here be dragons) 54
  • 55. A brave new world... ✤ Questions, feedback, comments... ✤ laura@mozilla.com 55