Sunday, May 24, 2009

The Gospel of J35u5 Chr!5+, Part 1

Jesus' Gospel shows up everywhere in software development.

Today let's talk about the gospel of Love.

Mark 12:31 - "The second is this: 'Love your neighbor as yourself.' There is no commandment greater than these."

Want to know how to write good software? Want a quick way to derive all of the good software practices that have been developed over the years? Just like you can derive all of the physical laws from a small subset of establish facts (f = ma, d = rt, etc.), you can also derive almost all of the good coding practices from this one kernel of truth: Love.

Who are you writing software for? No one write software in a vacuum. We write software to be used by someone. The User.
Who will look at this code next? You won't be around for ever, and you'll probably be moving on from this project in the relatively near future. Someone will have to fix bugs in your code after you're gone and add functionality when users ask for it. The Maintainer.
Would others find the functionality you are creating useful? Maybe they would. Maybe they would want to use it for reasons you had not originally intended. The Reuser.
And who owns the code? Who asked you to write it, kept track of your progress, and is ultimately accountable for the success or failure of the project? The Boss.

Now here's the deal. You need to think about these people when you write your code. You need to love them by looking forward into the future and taking responsibility for how they are going to interact with this thing you're creating.

The User. The most obvious one. Put yourself in his shoes and understand what he wants. He is using your product to get a job done. Help him do it quickly. Make his way obvious. Make the right choices for him so he doesn't have to. Wipe away all unnecessary options and let the functionality of your product be obvious and simple. He will never know your name, and if you do your job right he will never even think about you.

The Maintainer. Again, put yourself in his shoes. He's just gotten assigned to go fix bugs in an app he didn't write. First step - check it out of source control. Make sure the initial check-out from source control includes everything he needs to get to work. Next, he will try to build it. Make a single build file that can build all relevant components of your project. Now he needs to delve into your code and figure out where the bug is and try to fix it. Comment your code - like a fool! Let the comments describe exactly what you're thinking. Do it as you write the code and update them as you go so that they are faithful to your intent. Help him understand areas where you are unsure, or areas where he could expand it later (if you know what those areas are). Design your product well so that extending it is easy and he won't have to shoe-horn in features after the fact. Write a README document to explain any quirks or gotchas.

The Reuser. This is the person who sees something your code can do and says, "Hey, I wonder if I could reuse that." Package your code into modules that make sense for other people to use. Create interfaces. Create API documentation. Write it in a way that makes it reuseable - for example, the resuer should not need to include your whole project just to get one piece of functionality.

The Boss. This is the guy who cuts you a paycheck, the guy in charge, or even just the tech lead for the project. Write the code to do exactly what it needs to do - and nothing more. Don't go trying to solve the worlds' problems in your code. Sometimes elegance must die in the face of efficiency. If you can make a good business case for doing it the "right way" over the "quick way", great - take it to your boss and let him make the decision. But understand the business mind. He needs you to faithfully serve the cause of the project. Any product can be tweaked from here to infinity, but what needs to get done before it goes out the door? Hitting milestones on schedule and producing a great product are his top priorities. Love him by serving him faithfully. Don't insist on your own way. You should make good decisions without requiring his input on everything, but be willing to put it aside when he says to do it differently.

That's all I got. Jesus is a genius. I want to code just like He would.

No comments:

Post a Comment