How Not To Be A Development Dick

Having worked with PHP, and within the web development industry for >10 years now, I’ve got a fair idea about what I like to do and what I like to see. However, I can understand and respect different standards and development methods. What I struggle with, however, is others being Development Dicks.

What is a Development Dick?

A development dick is someone who has a tunnel-vision of the project goal. They don’t see the bigger picture. They go in, do their development and they leave. For some, an admirable trait, but you can have this kind of dogged determination and drive without being a dick. This concerns directly how their development affects others, and expands to development standards.

Warning: What you see below is a hugely trivial example, just used to illustrate my meaning.

See the below class method:

protected function getValue($x, $y, $z)
{
    return number_format(($x + $y) * $z, 2);
}

This is being a development dick.

Y’know why? Well, perhaps you’d like to answer a few questions about this method; pretend you’re not the developer and answer them only with the information you have above:

  1. What the fuck is $x?
  2. What the fuck is $y?
  3. What the fuck is $z?
  4. What data type is returned? (without looking at PHP.net)
  5. Why is the calculation structured in that way?
  6. What’s the purpose of the method?
  7. Who wrote it? Who can I ask for help with it?
  8. How do I modify it safely?

By now, you should see my point. If you see this in a code review, you need to stomp on it and stop it from happening. In truth, the method above works and all tests pass; but this isn’t about having bad technical skill. I believe being a good developer doesn’t just stop at your ability to get the job done. It extends beyond this and accounts for all the other stuff around completion of a task.

I’ve emboldened question 8, because this is pertinent one. Without being able to modify it safely, other developers are impaired in their ability to do their job; all because you wanted to shave a few seconds off your development time.

In a previous position, a colleague would say, “Why have you written a method for that, one already exists. Why didn’t you just use that?” Then when I’d ask him to point it out to me, it would look like the above. There is no way I could possibly know that the above is what I’d need.

Let’s list the steps below that I would need to go through in order to answer some of the questions:

  • Questions 1-3: Grep for instances where the method is actually used and inspect the input variables to it.
  • Question 4: Visit PHP.net to find out the return data type of number_format
  • Question 5: No idea …
  • Questions 6: Grep for instances of the method’s use, to learn more
  • Question 7: Visit the repository and look at the ‘blame’ for the method
  • Question 8: Rely on author

Huge amount of work! Keep in mind that this is a tiny, trivial example. Imagine if the method is more complex. Gives me the shivers.

Not being a dick

It’s not hard, nor is it an art-form. Let’s see a near-perfect example of the same method a above:

/**
 * Calculates a Price using the Unit Price, Tax and 
 * Quantity of Product
 *
 * @author Dan Hanly <danhanly@gmail.com>
 *
 * @param float $unitPrice
 * @param float $tax
 * @param int $quantity
 * @return string Formatted Price
 */
protected function calculatePrice($unitPrice, $tax, $quantity)
{
    $productPrice = $unitPrice + $tax;
    $totalPrice = $productPrice * $quantity;

    return number_format($totalPrice, 2);
}

Functionally identical. Dick index: 0.

Maybe this is overkill, however you immediately know the answer to every single question that I posed above.

  1. $unitPrice is a float
  2. $tax is a float
  3. $quantity is an integer
  4. return type is a string
  5. The calculation is structured to determine the overall product price before multiplying against the quantity
  6. The purpose of the method is to calculate a price
  7. I wrote it, you have my email if you need clarification
  8. You are now able to modify it safely because you have all you need to proceed

It’s important that this information is available to other developers. In fact, it’s important that this information is available to yourself as well. Nobody is good enough to remember a tiny method like this 6 months after it’s been developed. Being a development dick harms yourself as well as other developers.

Advertisements
How Not To Be A Development Dick

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s