What is Code?
Those who write software refer to source code. This is human readable instructions for a computer to execute. Which either gets compiled to machine code in the instruction set the computer can execute, or is interpreted directly by a virtual machine. Java and Python are 2 languages that commonly use virtual machines. Whereas C or C++ are most likely to be compiled to machine code.
In this topic we will be talking about human readable source code.
Who writes Code?
Coders write Code. Sometimes they are also called Programmers, Hackers and Developers. To understand the difference, I like the definition given by Daniel Miessler who also blogs on technology topics.
- Coder = Programmer = anyone who uses writes code
- Hacker = Programmer who makes a specific something
- Developer = Programmer who has been formally trained
So it is possible to be all three which is where we use formal methods and skills to make something specific by writing code to be executed on a computer.
Which brings us to the point of this post; “How to do it well“!
Writing Better Code
Don’t do it on your own
Not many people only ever write code on their own. There are exceptions. But for most of us working on any substantially sized system, the writing of the code is shared. One of our current projects is updating and improving on a code base that was started in 2009. So nine years ago. There have been 8 programmers contributing to it over those years and even though I was responsible for 80% of it originally I’ve contributing very little to the most recent round of new features or feature enhancements.
So principle number one is that great code comes from Collaboration. It needs to have the following qualities:
- readable – first and foremost, write it for those who will follow
- maintainable – lots of little principles like small commits, well abstracted, single responsibility
- easy to modify
- testable – test is a stakeholder so this should be considered in the design
An interesting agile practice is Pair Programming. One types and the other reviews as they type. This allows more experienced programmers to teach others what they know by explaining as they go, and also to reduce the critical need for code reviews because the code is always reviewed. However don;t jump in too quickly if you think your partner is making a mistake. Maybe they are. Maybe you’ll learn something.
So code is made and maintained by a community in the long run. Whether is is an open community or a closed one inside a commercial business, it is more than 1 person’s responsibility.
So that is the first principle. You are writing for more than you. Make it useful to others.
Learn how to code On Purpose
There are many great resources you can draw on to learn how to code rather than by trial and error. I’ve bought many of the Pragmatic Bookshelf titles and found them very useful.
The Head First series from O’Reilly are also a great way to learn from the compiled wisdom of the industry to date. Start with Head First Software Development to get a good idea of generic Software Development best practice.
And there are many great online communities and resources you can leverage such as DZone. This is a very big topic so I’ll leave it at that. What I do recommend is that you don’t drift into this, you do it on purpose. Learn, adapt, and become better at coding.
The future will increasingly depend on two critical things:
- better values based decisions about how we share this world together
- better software – because we will eventually end up with software managing everything
Code well and prosper.
Successful Endeavours specialise in Electronics Design and Embedded Software Development, focusing on products that are intended to be Made In Australia. Ray Keefe has developed market leading electronics products in Australia for more than 30 years. This post is Copyright © 2018 Successful Endeavours Pty Ltd.