The Dharma of Programming


Programming like a Buddha

Being a developer/programmer is not an easy task. Any of us could say that. But why is it so difficult?

Well, the main reason is simply that: it is difficult. It is challenging. We have to put our brains to deep thinking to solve real world problems. And the problem can vary from calculating some taxes to detect an anomaly on a electromagnetic field. This is what makes our jobs interesting and give us passion: we like to solve problems.

But, there are other reasons for that. The thing that stress us out and demotivates us: work on somebody else’s code. This includes work on legacy codes, making changes on software with awful design (that doesn’t respect any design principles) and correct their bugs.

I hate that. And what I hate the most is the amount of programmers that makes code only to “solve” a specific problem, without even understand what the problem was on the first place. You know at least one of those. But they are not this rare, they are everywhere. And they make unreadable code. They make repetitive code. They make code that is hard to modify and maintain.

Because of those guys, I created the Dharma of Programming, inspired by Buddhist principles. This will not be the theme of this blog (I will talk about programming in general, focused on Ruby and Rails), but it will be the start.

The Dharma of Programming comprises of four simple principles (The Four Simple Principles. Yes, that’s the name. I inspired myself on the Four Noble Truths). They may seem very simple and intuitive, but remember that I’m making these for people that don’t understand such simple things.

  1. Problems exist. Every piece of software is trying to solve a specific set of problem. When you are trying to solve a bug, you are trying to solve a problem. You are always solving problems. That’s what it means to be a programmer. Yes, even game developers.
  2. The problem always have a cause. Always. The cause of tax calculations are… taxes. The cause of a bug is some mistake.
  3. If you understand the cause of the problem, you can solve it. If you understand how an anomaly on the electromagnetic field happens, you can make a software that detects it (if you have the tools, obviously). If you understand WHY the error is happening, you can stop it from happening.
  4. To solve a problem, you may follow a path (The Simple Fourfold Path, inspired on the Noble Eightfold Path).

The Simple Fourfold Path is what follows:

  1. Right View: understand the problem and the cause of it. Please. This is the most important thing. Don’t try to solve a problem without understanding it.  (Actually, do try. There are a lot of contexts when digging the problem is the best way to understand it. But don’t consider the problem solved while it’s not understood. If it works and you don’t understand how, in some moment it won’t work). Don’t be afraid of asking for help. Read the error message (seriously, READ IT. Most of the times, when I have a problem, I solve it simply by reading what the error is. And it irritates me when somebody else could solve a problem by reading it and googling it).
  2. Right Concentration: concentrate yourself on solving the problem. Think about it. Seriously. Think. Don’t try to solve it before thinking, you won’t understand if you don’t.
  3. Right Action: learn design principles. It may seem useless when you work alone, but it’s not. When you are the “dumb programmer” I’m talking about, you get irritated with yourself. Make code that is easy to maintain. Don’t Repeat Yourself. Keep It Simple. Make it SOLID. It will help you later. Seriously. Software always change (if it’s good enough, at least).
  4. Right Effort: don’t try to solve “the easy way”. There is no easy way. There are simple ways, but this is not the same thing. If you try to solve a problem the “easy way”, see it as a trigger. It will explode, sooner or later. So, do your job and solve it. If it’s too difficult, try to get more people to help you out.

Well, that’s it. Everything is really obvious. So, if it’s obvious, please, do it.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s