Chapter 25. Test-Driven Developers

Logic will get you from A to B.
Imagination will take you everywhere.

Albert Einstein

After years trapped in the software factory and many long hours of bitter experience, software development becomes second nature. Once you are familiar with the syntax of your programming language, understand the concepts of program design, and have learnt to appreciate the difference between good and bad code, you find yourself naturally making reasonable coding decisions without discernible effort. Daily coding activities and “design in the small” become instinctive. Correct syntax flows from your fingers’ muscle memory.

A mindless “shoot from the hip” approach is symptomatic of the cowboy coder, but experienced programmers can work incredibly effectively without much deep thought. This is the benefit that experience brings you.

Have you reached this stage?

According to the Four Stages of Competence model, described in Live to Love to Learn, this idealic state is unconscious competence. It is an act we are able to do without needing to consciously think, a task we can perform effectively without even realising exactly what we’re doing and how difficult it is.

There are many activities in which we achieve a state of unconscious competence. Some are professional. Some are far more mundane: most humans can walk and eat without careful concentration. A common task in which people see their skills progress through the four stages of competency is driving a car.

Driving is an interesting analogue of programming. Learning to drive has many parallels with learning our craft, and there are lessons we can learn from a comparison of the two.

Driving the Point Home

It takes a significant amount of learning to become a competent driver. It requires effort to learn the mechanics of the car, as well as the etiquette and rules of the road. Driving well requires a concert of actions and skills; it’s an intricate process. You must invest a lot of effort and practice to achieve competence.

When new drivers first pass their driving test they are at the conscious competence stage of learning. They know that they can drive, and they have to pay attention to carefully coordinate all the contending forces. The selection of a new gear is a conscious process (for those enlightened drivers with manual transmission). Mastery of the clutch requires thoughtful balance.

But with experience, a lot of these actions become automatic reactions. We gain confidence. The controls and handling of the vehicle become second nature. We become accustomed to how the vehicle responds to our control. We naturally adopt the correct road positioning. We become masters of the operation of the vehicle.

Once a driver reaches this stage, their attention is freed to concentrate on the remaining unknown: the road itself, and the decisions that it constantly presents.

Similarly, once software developers gain a mastery of their tools and languages, they are freed to see the bigger shape of the problem to be solved. They are able to plan a route without having to concentrate on the minutiae of how they will manage it.

Some drivers are better than others. Some are more conscientious. Some have more natural ability.

Similarly, some developers are “naturals.” Others have to invest serious effort to work effectively. Some developers are more thoughtful and careful than others. Others lack diligence and an appreciation of what’s going on around them.

The majority of problems on the road—the accidents, delays, and so on—are due to driver error. Crashes happen to cars but they are caused by the people who learnt to use them.

The majority of coding disasters are due to programmer error. Crashes happen to programs, but they are caused by the people who learnt to write them.

Testing Times

Before you are let loose in a vehicle, you have to prove that you are capable. You have to pass a driving test. It’s illegal to drive on public roads without having first passed this test. The driving test proves that you have the necessary skills, and the responsibility, to drive. It demonstrates that you can not only handle a car, but can make good decisions under the pressured conditions of the road.

The existence of a test ensures that all drivers on the road have reached a certain standard, and have completed a certain amount of training. This training means that:

  • Learner drivers must amass hours of real-world driving experience before they are ready to attempt the test. They don’t just study the theory of driving, and understand the mechanics of a car, but gain practical hands-on experience on the road. Whilst learning, they are effectively “driving apprentices” studying under a master.

  • There is a reduced risk of accidents on the road; drivers are taught the dangers and pitfalls inherent in driving and how to avoid them.

  • Trained, experienced drivers have more confidence in their abilities and can make mature decisions.

  • Drivers understand how the road is shared between all types of users, and are considerate to other road users.

  • Drivers are aware of the limitations of their equipment. They know how to react in emergency situations when things go wrong.

The driving test ensures that a complex human activity does not end in disaster. It doesn’t just encourage people to be good drivers based on good intentions, but mandates it.

Some countries go further, with an additional “advanced” driving test—a higher standard of driving capability. This test is a requirement for certain jobs.

Test-Driven Developers

Now, there isn’t a direct equivalent of a driving test in the programming world; certification is not a legal prerequisite to write code (nor should it be, in the author’s opinion). But to enter gainful employment you do usually have to demonstrate a reasonable level of skill: having passed a reputable training course, or showing tangible prior experience.

So here is the obvious thought experiment: what would the equivalent of a driving test for software developers look like? How can you realistically demonstrate competence? Does it even make sense to try to?

I’m sure there are coders whom you respect and recognise as advanced. But is it possible, or practical, or useful, to certify them as such?

We debate the true value of certification in our industry. Certainly, much of the certification pedalled by training organisations is pure bunk, snake oil that helps you tick boxes on a job application form but that means very little. Are you a certified scrum master? How marvellous. I hope it didn’t cost too much to buy that certificate.

Would a physical coding test be of any use? What would it look like? How tailored would it have to be to specific technology areas? Would the many specialisations make it impractical to create? How would you measure engineers who don’t predominantly work in code?

As we’ve seen, the majority of programmer skills are gained by experience garnered on the job. So recognising progression through the apprentice-journeyman-craftsman model may suit us better. Not every long-serving coder continues to learn and hone his skills; not everyone becomes a master craftsman. Time on the job is not enough.

Indeed, advancing coding skills can be orthogonal to the typical developer promotion path. If you serve faithfully in a job for n years, then your company might give you a pay raise and allow you to climb another step up the corporate ladder. But that doesn’t necessarily mean that you’re any better a programmer than when you started.

It is not at all clear that the benefits of the driving test can be brought to our profession in a meaningful way.

Conclusion

Think for yourself and let others enjoy the privilege of doing so too.

Voltaire

This is a little thought experiment, a rhetorical question. Nothing more. But it’s interesting to think about this kind of thing, to provide a framework that will help us become better programmers.

It’s certainly valuable to consider the stages of coding ability we progress through. Determine when you have moved from conscious competence to unconscious competence. And beware of mindlessness and complacency.

Questions . What do you think? What is the programmer’s equivalent of a driving test? Could there be such a thing? . Are your programming skills at the standard test level or at the advanced level? Do you think you frequently achieve unconscious competence? . Do you want to maintain your current skill level? Do you want to improve it? How will do you this? . How could you test a programmer’s ability to perform an “emergency stop”?! . Is there any extra value to be gained from investing in your skills? If good drivers enjoy lower insurance premiums, how does being a “safer coder” materially benefit you? . If coding is like driving, do we treat code testers like crash test dummies?

See also

  • Live to Love to Learn Describes models of learning and the Four Stages of Competence model in detail.

  • Relish the Challenge Whether or not our knowledge is formally tested, we should strive to continually improve our skills.

Example 25-1.

Consider how to change your habits to become a more mindful and less complacent programmer. Ensure you do not slip from unconscious competence into cowboy coding.

bbpg 25in01