No Limits on Repetition – The Daily WTF

Date:

Share:

Just because you get fired doesn’t mean that your pull requests are automatically closed. Dallin was in the middle of reviewing a PR by Steve when the email came out announcing that Steve no longer worked at the company.

Let’s take a look at that PR, and maybe we can see why.

                    $originalUndrawn = DecimalHelper::toDecimal($party->limit)->sub(DecimalHelper::toDecimal($party->drawn));

This is the original code, which represents operations on investments. An investment is represented by a note, and belongs to one or more partys. The amount that can be drawn is set by a limit, which can belong to either the party or the note.

What our developer was tasked with doing was allow a note to have no limit. This means changing all the places where the note‘s limit is checked. So this is what they submitted:

                    if ($note->limit == null) {
                        $originalUndrawn = DecimalHelper::toDecimal($party->limit)->sub(DecimalHelper::toDecimal($party->drawn));
                    } else {
                        $originalUndrawn = DecimalHelper::toDecimal($party->limit)->sub(DecimalHelper::toDecimal($party->drawn));
                    }

You’ll note here that the note limit isn’t part of calculating the party limits, so both branches do the same thing. And then there’s the deeper question of “is a null really the best way to represent this?” especially given that elsewhere in the code they have an “unlimited” flag that disables limit checking.

Now, Steve wasn’t let go only for their code- they were just a miserable co-worker who liked to pick fights in pull request comments. So the real highlight of Steve’s dismissal was that Dallin got to have a meaningful discussion about the best way to make this change with the rest of the team, and Steve didn’t have a chance to disrupt it.

[Advertisement]
Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.

Source link

Subscribe to our magazine

━ more like this

The Top of My Todo List

April 2012A palliative care nurse called Bronnie Ware made a list of the biggest regrets of the dying. Her list seems plausible. I could...

Saturday Morning Breakfast Cereal – Sawyer Lee and the Quest to Just Stay Home

Pre-orders for my new book Sawyer Lee and the Quest to Just Stay Home have begun!Sawyer Lee is an illustrated middle grade novel starring an...

NeoClerks-partnership.md · GitHub

Error in user YAML: (): did not find expected alphabetic or numeric character while scanning an alias at line 1 column 1--- **Important clarification based...

Colorado Train Museum in Golden, Colorado

Located in Golden, just west of Denver, Colorado USA, the museum has an operating track offering train rides, a working roundhouse and turntable,...