We require discipline in every facet of our lives. It takes discipline to practice every day to master an instrument. It takes discipline to study in college when everyone wants to just have fun. It takes discipline to eat healthily and to exercise. It takes even more discipline to run a marathon. It takes discipline to handle all the streams of information in our lives. And, of course, it takes discipline to be a professional software developer or to practice software craftsmanship. Any mere programmer can sling together a working solution to a problem, but it takes skill and discipline to write clean code.
"My simplest explanation of discipline is to refer to it as intentional suffering. It is the act of insisting that the body, the mind, and the spirit engage in challenges that build up capacity and stamina." (156-157)
I feel like this is why it is so easy to lack discipline. Discipline takes sacrifice; it's not going to be easy, but it will be for your benefit. Test Driven Development (TDD) is one of the disciplines of software craftsmanship. It's not easy at first. In fact, I'm still struggling to practice TDD consistently. It feels like a chore right now, but I can see how it is building me up to be a better developer that writes better code.
"[Thomas] Merton offers an idea that seems paradoxical: We are most free when we are under discipline." (151)
"The joy, the freedom that comes with the finished product is exhilarating. But the road of disciplinary activity that led to the finished product is fraught with struggle." (151)
The struggle that we face while we try to be disciplined in our craft is worth it; we just need see the fruits of our labor that lie ahead. In software development, it's too easy to only see the next deadline and not the big picture. If I'm not thinking about how this code will be maintained a year from now and I lack the discipline to write clean code, then it will be a burden later on. Without tests, I or someone else will not have the freedom to modify the code without worry of breaking something.
Having seen a piece of code that is fully tested and easy to understand is very freeing. The only reason for my code to lack tests or to be hard to understand is a lack of discipline. In order to have the freedom to write elegant, correct, working, easy to maintain software, we need to be disciplined.
"By doing things regularly and repetitively, one acquires the ability to do something far more effectively and in a way that inspires others." (160)
This ought to be our goal - to be effective and inspire others with our work. I'm not there yet, but I'm trying every day. There may be days where I fail, but hopefully at the end of the week or the month, I will find that I am more disciplined than the week or month before. And I know that there are many areas of my life where I need to practice discipline. In fact, there is a correlation between a lack of discipline in one area of my life and a lack of discipline in another. We need to be disciplined as whole individuals, not just in our profession.
I'll leave you with Paul's instruction to overseers in the church, which is just as applicable to us all today. Discipline is certainly not a new concept.
For an overseer, as God's steward, must be above reproach. He must not be arrogant or quick-tempered or a drunkard or violent or greedy for gain, but hospitable, a lover of good, self-controlled, upright, holy, and disciplined.
The "Code Casts for Software Professionals" by Uncle Bob Martin at http://www.cleancoders.com/ partially inspired this article. Uncle Bob has also written a book on software professionalism -- The Clean Coder: A Code of Conduct for Professional Programmers.