Open side-bar Menu
 Embedded Software
Colin Walls
Colin Walls
Colin Walls has over thirty years experience in the electronics industry, largely dedicated to embedded software. A frequent presenter at conferences and seminars and author of numerous technical articles and two books on embedded software, Colin is an embedded software technologist with Mentor … More »

Why write code?

October 15th, 2015 by Colin Walls

I have a very basic question for you: what do you do and why do you do it? It is quite possible that, if you are reading this, you are an embedded software engineer. It is interesting to consider what that job actually entails. First off, how would you reply to the “What do you do?” question from someone you meet in a pub/bar? You would probably say Software Engineer, but they might ask you to expand on that. [Actually, such a reply can be a complete conversation killer. You might be better to reply with Airline Pilot or some such. Just invent a new persona and have some fun.]

It is easy to think of an embedded software engineer’s job as being all about writing code that programs a device to behave in a particular way. But that is a long way from the whole story…

It is interesting that programmers are trained to write code. A lot of time is spent discussing the best design and coding techniques for efficient reliable code. This is not wrong, but it is a curious priority because, if you look at how engineers actually spend their time, coding is only a small proportion. A large part of the development process is debugging and code maintenance.

About 15 years ago, Jack Ganssle wrote an article for Embedded Systems Programming magazine about debugging. In it he said “Learn to love your debugger – you’re going to spend a lot of time with it”. That is as true today as it was then. Maybe more so, as code volumes have increased dramatically. Typically, a developer will indeed spend more time checking the functionality of their code and identifying and rectifying bugs than they do actually coding.

The other time consuming activity is code maintenance. This may be to fix bugs that are detected after deployment or to enhance the functionality of a device later or may be a consequence of reusing code for a new application. In any case, engineers are faced with the prospect of working on code written by someone else a large proportion of the time. [Or code that they had written themselves and long since forgotten about.] What can we do with this knowledge? The answer is to adopt a programming style compatible with the expectation of future maintenance.

It is common practice to think in terms of writing “efficient” code. In other words, program in a style which is intended to result in the best code generation. That is short sighted. Modern compilers tend to do an amazingly good job. It is, therefore, much better to write code with the future human reader in mind:

  • structure the code in a simple way
  • use short expressions/statements
  • comment the code
  • do not assume the reader is an “expert” [for example, use redundant parentheses if that clarifies operator precedence]
  • use meaningful names for identifiers
  • comment some more

This is, by no means, an exhaustive list. The broad philosophy is write code to be read. Think of it as a form of human-to-human communication, the same as you would with an email, an article or a even blog posting.

Related posts:

One Response to “Why write code?”

  1. juergen says:

    You write exactly how programming in Forth is done – and even interactively, where compiling might take a second, so it is part of the programming.

Leave a Reply to juergen Cancel reply

Your email address will not be published. Required fields are marked *


DownStream: Solutions for Post Processing PCB Designs
TrueCircuits: IoTPLL

Internet Business Systems © 2018 Internet Business Systems, Inc.
25 North 14th Steet, Suite 710, San Jose, CA 95112
+1 (408) 882-6554 — Contact Us, or visit our other sites:
TechJobsCafe - Technical Jobs and Resumes EDACafe - Electronic Design Automation GISCafe - Geographical Information Services  MCADCafe - Mechanical Design and Engineering ShareCG - Share Computer Graphic (CG) Animation, 3D Art and 3D Models
  Privacy PolicyAdvertise