A life in code, the lessons learned

in #programming7 years ago (edited)

I have been writing code for more than 80% of my life now. I started when machines had 1K of Ram and games came as code printed in magazines that you had to type in. It was a far easier time to learn coding compared to the complex interwoven sprawl in interconnected system we have today. The learning pains and lessons learned remain the same though.

  • Programming, no matter the language used, is a subtle complex skill that you never fully master. You will always look back at old code and say "That would be so much better had I..."
  • Learn languages from other paradigms even if you do not use in anger, you will learn new ways of thinking about problems.
  • You will make mistakes and box yourself into a corner. Never be afraid to tear down something that is no longer good for the task and replace it. Just make sure you learn from it at the same time.
  • Learn Big O notation and what it means, it will let you pick the correct collection type for the job. All types of collection have at least one performance compromise.
  • Write small modular functions that do one thing, are easy to plug together and above all else easy to debug.
  • Be consistent with your code layout and naming conventions. It does not matter what those conventions are, stick to them.
  • If you are re-writing old code. Stop, step back and look at what it was trying to do, not how it was done. Chances are there will be a better way, and if not the time spent thinking will result in cleaner code.
  • Don't Repeat Yourself. If you see the same code pattern appear many times look for a way to extract the common code out. It is easier to fix a bug in one place than find the 20 places it repeats. Use inheritance, continuations, generics. or whatever other technique is the best fit. Less code is better code.
  • Think what does this function do before you think about how.
  • If there is something subtle about a piece of code, comment it. The next person in there will know what to look out for.
  • Try to use variable names and function names that make code describe what it is doing. This can take a while to learn well.
  • If you move to a new version of a language do not be afraid to start using new language features. The introduction of lambda into many C style languages has changed how you use the languages for the better. If your team resists, try and bring them up to speed.
  • Do unit testing, it is painful at first but does clear out bugs and gets easier as you go. I will also make your code more focused, single minded functions are easier to test.
  • Become good friends with source control, no matter the project or team size. It will save you from yourself :) Does not matter which one unless it is SourceSafe, never use SourceSafe!
  • Above all, do not be afraid to try new techniques, if you use source control it is easy to unwind if you find it does not work.

Woz

Sort:  

I'll come back to your posts on the weekend. In the meantime, add pictures to your posts and a fifth tag. Otherwise they get lost in the feed.


Regards
@qed

Thanks. Updated all posts with images.

Thanks for sharing, Woz! :)

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.030
BTC 59367.33
ETH 3172.01
USDT 1.00
SBD 2.43