When I was a jr engineer at AWS my PR’s went through 100+ comments and 7+ revisions due to poor code quality. The friendly, helpful feedback helped me improve.

Now as a mid-level I tend to ship code in <= 2 revisions with minimal comments.

Here’s how I’m doing it. 🧵👇
1️⃣ I understand why code quality matters.

We read code 10x more than we write it. Our code must be understandable so our team can maintain and add features.

Poorly written code causes PR churn, which results in delayed delivery and can block other team members.

👇
2️⃣ I take on small tasks.

A good PR starts before any code is written. The task should be small, resulting in an easily reviewable PR.

Bad task: UpdateWidget API

Better: split into 4 separate tasks - UpdateWidget model; AuthN/AuthZ; input validation; implementation

👇
3️⃣ I invest time up front to ensure my local development environment is ready to code effectively.

- Pull down the latest code.
- Ensure local builds and tests are passing.
- Configure my IDE to working smoothly.

This saves time and headaches while coding.

👇
4️⃣ I read the existing code.

Before implementing UpdateWidget, I look in the codebase to understand the current paradigm.

What design patterns are being used? Is there code from GetWidget or UpdateItem that should be reused? Will refactoring be necessary?

👇
5️⃣ I plan my code.

I write skeleton interfaces, classes and methods for my code structure.

I realize I won’t get this perfect, and may need refactoring later. But it gets me started.

👇
6️⃣ I write lots of ugly code.

I try to use decent names. This way I know where things are when I read, iterate and refactor later.

I write automated unit tests. Manual testing during this step is tedious, time consuming, and leaves the door open for bugs during refactor.

👇
7️⃣ I refactor heavily.

This is where I name intelligently. I segment the code into small functions and finalize my class structure. If anything looks weird or awkward, I search for an elegant solution.

This includes the implementation *and* the unit tests.

👇
8️⃣ I perform manual tests after refactoring.

I make sure all the classes are working together properly. I cover basic functionality. I don’t rely on catching granular edge cases with this step - these should be covered by the unit tests.

👇
9️⃣ I prepare and review my own PR before sending it.

I hold myself to a relentless standard. I often discard and recreate the PR with even a single nitpick.

In the summary I include relevant Jira or trouble tickets. I document manual testing steps.

👇
🔟 I listen to feedback with objective self criticism.

I make sure I fully understand a teammate's perspective before addressing their comments in a new revision.

Even if their comment is wrong, I understand that it’s likely due to a lack of clarity in my code.

👇
The above steps will improve your code quality and drive down churn on PR’s. This allows you and your team to deliver software faster.

What are some of your tips to improve your own code quality?
You can follow @curtiseinsmann.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: