160

How can I write great code faster?

Profile picture
Senior Salesforce Engineer at Series B Startup2 years ago

My goal is to become extremely efficient at coding. I want to build a reputation as someone who is able to deliver tons of high-quality implementation and products very quickly. I want to build actual velocity where the actual rate of code per hour/day is really high as opposed to just being able to accomplish more from working extra hours.

What tactics can I use to level myself up in this way so that my old coding abilities feel unrecognizable when looking back 3-6 months in the future from my vast amount of improvement?

18.3K
4

Discussion

(4 comments)
  • 128
    Profile picture
    Tech Lead @ Robinhood, Meta, Course Hero
    2 years ago

    I built a reputation as a "code machine" back at Instagram - I had 250+ commits and 700+ diffs reviewed per half, even after growing into a tech lead with a bunch of meetings. So I'm happy to chime in here and share some reflections on how I was able to do this.

    At a high-level, you become a code machine by writing a ton of code. There's no way around this, 10,000 hours and all that. However, this raw coding effort does need to be guided in crucial ways - You can easily write a lot of code and still be slow and write low-quality code. Here's my advice on how to do that.

    Go Deep, Not Wide

    • After I found out that I truly loved doing Android development, my goal was to turn it into a superpower. This is why I've been doing Android for 8 years now.
    • More specifically, I love being close to users and putting pixels on screen. So my goal was to become extremely good at Android product/UI, which made my expertise even more focused.
    • Build the same components over and over again. When it comes to consumer apps for example, there are many common patterns, with the most common one being loading a list of items, usually from an API call. This organically led to me building things like a content list dozens of times, which turned it into muscle memory for me. Figure out what the "content list" equivalents are for you in your space and get extremely good at those.
      • Side note + benefit: I remember doing my Robinhood onsite interview, and the practical Android coding challenge was to build a small content list app. I was able to finish it 20+ minutes early, because I had become such a master of this component - This was easily the funnest and most trivial part of the interview for me.

    Make Things A Little Better Each Time

    • This is the next crucial ingredient. If you aren't seriously reflecting after every time you build something and trying to poke holes into it, you will write the same hacky code every time. This means your growth is only in the velocity axis instead of quality, which is less impressive as a code machine.
    • My first content list in Android was horrible. It had a very limited API, was buggy, and the code was very messy. Every time I rebuilt a list in my new Android project (which would involve me copy-pasting code), I would ask myself if I could make it just a little bit better (after all, I had this time save from the copy-paste). In particular, I would see what was painful in this new integration and try to solve that. And now after writing a content list in Android 100 times, my most modern iteration is very clean and performant (and it's still getting better).
    • If you're unsure how to make things a little better each iteration, here are some ideas:
      • Can we have the same effect with less code?
      • Is there a lot of duplicated code/boilerplate in the current approach?
      • Are there unhandled edge cases? Maybe it crashes with bad inputs, too many items in the list, etc.
      • Is the code easy to read?
      • Is the code performant? Does it do the core task within just a few milliseconds, or is it something longer that's very noticeable?

    Build Side Projects

    • Side projects are sort of a "hack" to get yourself better at coding without just over-working yourself. You get to write more code (and probably for a thing you're more passionate about) outside of a work setting.
    • For years, I would come home from work and do something in my side projects for 1-2 hours. This was usually addressing the latest user feedback.
    • However, YMMV with side projects. It was much easier for me as I work on the product/front-end side and Android apps are extremely easy to deploy. If you're further away from the average user, things get harder.

    Manage Your Time Very Deliberately

    • In particular, build a very strong flow state.
    • You want to have as many uninterrupted periods where you just code and build as possible. One very tactical work advice is to try to concentrate all your meetings on certain days, so you can have 1-2 days where you just code.
    • The goal is make it so that whenever you get 2+ hours on your code to build, you can get a lot done.

    Related resources:

    • 2
      Profile picture
      Staff Software Engineer at SS
      7 months ago

      This advice resonates well with me - many years back I was working on new area and I have learn lot of things by going depth due I am the early mover in the space. Initially it was difficult but in an year I built the similar muscle memory and I have become much much faster. This allign with your first point.

      Secondly, there have been some fundamental changes and I started doing things in much efficient manner and lesser code and highly performant. This has given me a good reputation.

      Back those days it was mostly working from office, so at times though I need to work for couple of hours I choose to go to office and have uninterrupted time to finish my tasks.

      I used to have pet projects but not in the same but in experimenting something very different.

  • 45
    Profile picture
    OpenAI Engineer (ChatGPT Team), Ex-Microsoft, Ex-Meta, Ex-CEO of tech nonprofit
    2 years ago

    Alex's answer to this is amazing.

    The one thing I'll add is that, as you progress in your career, it'll become far more important what you're working on, in addition to how. Every senior coder has seen the following two things:

    1. Months/years of code down the drain because the project was misguided.
    2. Hours/days of code with a fundamental architecture flaw that has to be rewritten.

    It's faster to walk in a straight line than to run serpentine. In addition to building out your skills around coding quickly (which I completely agree is essential early in career), also look to learn telltale signs that a project is headed the wrong direction, or a code path you're taking will need to get ripped out.

  • 21
    Profile picture
    Senior Software Engineer at Upstart
    7 months ago

    Do four things:

    1. Learn to use Search Techniques. It sounds like a simple two-word phrase, but undervaluing this is single biggest mistake you can make in trying to becoming a high-productivity engineer. All software, all architecture, all social skill, all knowledge acquisition is downstream of searching techniques.
    2. Learn to use your tools. Start with your IDE and multiple AI assistants. Use GPT-4. Use Copilot. Add Prettier in VS Code and the other extensions to make sure you have linting, formatting, syntax highlighting, version control support, and support for containers or whatever things your team is using.
    3. Learn time management and social techniques. Three specifically:
      1. Calendar Blocking. Our code jitsu works best when single tasking. Multitasking is a productivity killer. Block your calender.
      2. Timeboxing and Escalation Procedure. You say "My goal is to become extremely efficient at coding. I want to build a reputation as someone who is able to deliver tons of high-quality implementation and products very quickly." You need to realize the first sentence isn't the key to the second sentence. You need to learn how to escalate quickly and to the right people when you hit a wall. This is going to include soft skills. You need to be able to communicate well to motivate others to help you and so they can understand how to optimally help you once they are motivated.
    4. Practice, practice, practice.