1

Seeking Advice to Improve Diff Quality and Efficiency in PHP Codebase

Profile picture
Senior Software Engineer [E5] at Meta7 months ago

Hello everyone,

I joined Meta a couple of months ago as an IC5, coming from a predominantly Java background. Recently, I've started working with the PHP codebase, which is somewhat new to me. I've noticed that my diffs tend to undergo several rounds of revisions, which not only delays their integration but also consumes more engineering time than I'd like.

A fellow engineer pointed out that my diffs are often too lengthy, leading to extensive feedback and additional iterations. I'm actively looking for ways to streamline my review process and improve the quality of my submissions.

Here’s what I’m considering to reduce the review cycles and improve my coding approach:

  1. Reducing the Size of Diffs
  2. Pre-Review Checks: -- Any suggestions here would be great

I would greatly appreciate any advice on:

  • Strategies or tools that could help in catching potential issues early.
  • Best practices for structuring PHP code and managing larger changes in a PHP environment.
  • Any insights on transitioning from Java to PHP, particularly with regard to common pitfalls or key differences I should be aware of.

Thanks in advance for your help! I'm eager to learn from your experiences and improve my contributions to our projects.

150
4

Discussion

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

    This is one of the examples of classic Meta culture shock, so don't worry, many engineers have gone through this before and successfully come out the other end (I mentored many engineers through this).

    Your teammate is right in that your diffs are too big. The good news is that once you start pushing more atomic diffs, you'll almost certainly find all of these code quality problems going away. Your overall strategy here should be to:

    1. Decompose every task/project you get into tiny chunks where each chunk is 1-3 diffs
    2. Get feedback on your decomposition before writing any code
    3. Execute and push out super clean, focused, and relatively small diffs

    I made an entire course about this process (and more) which you can go through here: [Course] Level Up Your Code Quality As A Software Engineer

    If you're crunched for time, you can start straight at the "Break It Down" section: https://www.jointaro.com/course/level-up-your-code-quality-as-a-software-engineer/break-it-down/

    As for specific tips on transitioning from Java to PHP, I unfortunately don't have much. I also joined Meta with a Java background, but I didn't have to write much PHP as I do Android. Java and PHP are pretty different languages, and to be 100% honest, I think PHP is sort of a janky programming language. My advice is to be a feedback sponge in code review, identify patterns from experience, and just keep on improving. More thoughts here: "What is the effective way to understand new repository in order to make the required changes in that repo?"

    • 1
      Profile picture
      Senior Software Engineer [E5] [OP]
      Meta
      7 months ago

      Thank you for the suggestion, Alex. I plan to follow your advice and will keep you updated on how it goes.

  • 1
    Profile picture
    Tech Lead/Manager at Meta, Pinterest, Kosei
    7 months ago

    This is not specific to the Java --> PHP transition, but my recommendation with any new language is to make many small changes. Try to make them independent of your main project, which will likely require larger changes and more thorough review.

    Instead, make throwaway changes which are very small quality-of-life improvements, e.g. variable naming, fixing tests, etc. This has 2 big benefits:

    1. Reviews will be quicker and easier. Getting the LGTM from your peers, even for simple changes, will increase your level of trust.
    2. These small code changes will force you to read PHP code, which will make you a better engineer.

    How to apply the 'one diff, one thesis' to improve code reviews?

  • 0
    Profile picture
    Eng @ Taro
    7 months ago

    I've noticed that my diffs tend to undergo several rounds of revisions, which not only delays their integration but also consumes more engineering time than I'd like.

    Here’s what I’m considering to reduce the review cycles and improve my coding approach:

    1. Reducing the Size of Diffs
    2. Pre-Review Checks: -- Any suggestions here would be great

    Since you just started, your reviews will be under a lot more scrutiny, which is good since it'll prevent you from merging in bad code or causing any incidents.

    Your suggestions about how to improve your PRs make a lot of sense. Opening smaller diffs can actually get your code accepted faster. It can be intimidating for someone to open a PR and see that hundreds or thousands of lines were changed. They might decide to look at the PR later in the day because they don't have the time to give it a thorough review in the middle of the day. But, if they see a smaller change that only takes 3-5 minutes to look at, they will be way more likely to close that loop immediately.

    For pre-review checks, this will be less about the semantics of the code and more about being on the right path. A small explanation or bullet points about what you intend to do in your code change can prevent you from going down the wrong path and wasting a lot of your time as well as your reviewers' time. It will also help grease the wheels and get your review accepted faster because the reviewer knows exactly what to expect in the code review. There's nothing more demoralizing than someone blocking your review because the implementation is completely wrong.