I’ve been writing software since the 1990’s, using about 8-9 languages over that time. Each language has it’s own idiosyncrasies (you have to know each ones strengths and weaknesses) … but there are a few principles/techniques that are universal … here are my top three:
1. Self Describing Code:
Go for verbose self describing code that is simple to read and understand, rather than terse code that no one can understand. For example, this is good:
# .. code goes here
And this is bad:
# .. code goes here
In the old days, when computer memory was expensive and we didn’t have much to spare, very efficient code was needed. These days though, memory is dirt cheap and getting cheaper and so it makes no sense to have compact code that is hard to read. Programming hours are always more expensive than adding a bit of ram or hard-drive space to a server.
2. Reuse, reuse, reuse – don’t reinvent the wheel.
When starting a new project, see if someone has already done the work and built a similar product. Look around for perhaps an open source project and even commercial option – sourceforge.net is a good place to start.
Besides saving time, a great advantage of using an established piece of software, is that often enough, they will have thought of smart ways to do things that you may have never considered.
â€¦ In fact, they may even have features you hand’t considered and in the case of open source projects, you will often have clean code that has fewer bugs than any brand new piece of software – yes, few of us can write bug free software with the first release!
3. Use fine-grained objects and functions.
Fine grained (opposite of course grained!) … these are objects that are very task specific, the opposite of monster classes or functions that try to do every thing and are a big mess.
For example, if you have an object that creates new user accounts (call it: user-accounts), keep the validation functions outside of that object. You should have a dedicated validation object instead, that can be used in your user-accounts object (nerds call that composition) â€¦ and can also be used in every other object in the system.
There are many other tips you could list (and I might tackle that later on,) but by following the above three rules, you will make your programming far more productive.
If you are just starting out as a programmer, you may want to try my very popular Complete Web Programmer video training package.