Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Compassionate Refactoring, NewCrafts Paris 2023

Compassionate Refactoring, NewCrafts Paris 2023

Most coders wish they were refactoring their code more than they are.

Many things stand in our way (or so we think): The obvious one is time, and the associated pressure from our stakeholders. This is a real problem, and in this talk I will discuss ways of addressing it.

But one constraint that isn't often discussed is a lack of compassion. This doesn't only come from others, it comes from ourselves. We don't forgive ourselves when we write bad code. We think it's all or nothing. We mutter about the trail of bad code left by our forbears and feel guilty about the bad code we leave behind ourselves.

Refactoring shouldn't be something that happens after the fact - it should be, and can be, part of every day development. But before we write good code we have to write bad code, and that's OK. As with most creative endeavours if you insist on making the first draft perfect you will never get anything out the door.

This talk is about kindness and forgiveness, and the paradox that the more you accept and handle bad code, the more likely it is that you will end up with good code.

Key takeaways:

• Refactoring is something that can be done continuously, in tiny steps

• Compassion makes refactoring easier and more likely

• Rewrites are often not refactoring

Clare Sudbery

December 19, 2023
Tweet

More Decks by Clare Sudbery

Other Decks in Technology

Transcript

  1. @ClareSudbery Refactoring • What it is • What it isn’t

    • Why it’s desirable • How to do it Why it doesn’t happen How to make it happen • COMPASSION
  2. @ClareSudbery What refactoring isn’t • Rewriting from scratch • Performance

    gains • Improving user experience • Adding new features • Bug fixing
  3. @ClareSudbery @ClareSudbery Useful refactoring principles • Refactor in small chunks

    • Make testable first • Always keep tests green • Refactor the parts that have an impact
  4. @ClareSudbery How Use compassion to… • Mitigate external pressure •

    Balance impatience • Embrace imperfection • Believe in ourselves • Seek joy How to facilitate refactoring
  5. @ClareSudbery "There are things that I think are good but

    that I don’t always do, and things that I think are not so good, that I sometimes do.“ – Ron Jeffries https://ronjeffries.com/articles/-z022/0222ff/my-mistakes/
  6. Ilianna: Terraform Kirsty: Hadoop Mircea: iOS Native Esra: SonarQube Georgia:

    Golang Rob: AWS Scott: AiOps Andy: Encryption Anik: PySpark Jon: CentOS 7 THE WHEEL OF CONFUSION
  7. Terraform CentOS 7 Hadoop iOS Native SonarQube Golang AWS AiOps

    PySpark Recursion THE WHEEL OF CONFUSION
  8. Terraform CentOS 7 Hadoop iOS Native SonarQube Golang AWS AiOps

    Recursion Encryption THE WHEEL OF CONFUSION
  9. Terraform CentOS 7 Hadoop iOS Native Golang AWS AiOps 398373

    Encryption PySpark THE WHEEL OF CONFUSION
  10. @ClareSudbery Refactoring: Easier to understand / cheaper to modify •

    Continuous • Tiny low-risk steps • Testable Less likely when… • Low compassion • Unreasonable deadlines • Unrealistically high standards • Feeling guilt or shame More likely with… • COMPASSION • Time • Embrace imperfection • Focus on tiny improvements (MMMSS) • Believe in ourselves • Find ways of enjoying what we do Summary
  11. Sudbery Software Engineering Ltd Helping teams improve their software delivery

    Delivering keynotes and workshops Events and info: tinyurl.com/csudbery Mastodon: mastodon.social/@ClareSudbery Twitter: @ClareSudbery LinkedIn: tinyurl.com/lin-csudbery Podcast: tinyurl.com/tech-better-pod