Monday 27 July 2015

Perils of Programming

So if you are reading this you are already a programmer or looking at getting in to programming. Either way this should be a good and helpful read for you. As a working man who programs pretty much every day it is no supprise I make mistakes, quite a few tbh, but they aren't big mistakes that can be overly complex.

They are usually the mundane missing a semi colon or most recently an incorrect spacing. These can drive you mad searching tirelessly for the most simple errors and as such I have learnt a fair few ways of trying to reduce the number of these errors and just improve all round code. You may have heard of a few of these and there may be more but these are my top 5.


Number 1: It seems fairly obvious but some people don't like letting other people look at their work. However, if you ever want a simple bug being found quick and easily, give it to someone who doesn't know what your program does. They will be looking at it with fresh eyes and won't think about, "Oh this could be improved by this", they will be less distracted by the program and more likely to spot the simple errors. So suck up what ever pride you think you have and ask for someone to give your code a quick read through.

Number 2: If no one is around or you are too stubborn to ask for help then fair enough, read it yourself. Just take your time and read it as though it was being ran, don't go off to look at other methods to try and see what they are doing. This is where the debugger comes in really handy, it allows you to run the program step by step seeing what variables are what. You never know you might come across a missing semi colon or a mis typed variable that stops everything from working. It happens I know.

Number 3: Comment your code, dear god comment it. This can not be said enough, comments are so usefull and I am not on about just the one line saying does stuff. If you comment often and clearly not only other people will know what you have written should do but so will you when you come back to it. The number of times I didn't comment something because I knew what it was at the time then came back to it and was like, erm what is quite a lot. It is a vital part to programming, yes the computer might know what the code does but when you come back to improve or use your code you will have no idea and that can make chages really hard to implement.

Number 4: Test. Now this can be manual tests, automated tests or other tests but testing works out the kinks. As well as that it helps you write better code and reduce pointless code. With a good few tests you can see where and why your code is failing and what you can possibly do to remedy it. It can get boring but if you do it as you go along you won't have a LOAD of tests at the end to write. As well it also helps see if any new code you have put in breaks existing code.(see regression tests).

Number 5: Write code, any code and lots of it. Practice makes perfect...but nobody is perfect so why practice..... because you can come damn close to being perfect. The better and quicker you can write code the more money you are likely to earn. So crack those fingers, sit down and give yourself a simple coding challenge. It is a great way to try and learn a new language or just boost knowledge in an existing one, it doesn't have to be anything huge, try conways game of like or noughts and crasses. You can write something that solves a problem you are working on or something that makes your life a little easier. The more you write the better and less buggy your code will be, there will always be those bugs that creep in though, it happens to us all.


I hope these few bits of info help in your programming endevours and if you have any pointers you would like to share please leave a comment below.


Twitter - https://twitter.com/MentalMarriott

Twitch - http://en-gb.twitch.tv/mentalmarriott

Youtube - https://www.youtube.com/user/GamingMarriott

Facebook - https://www.facebook.com/mentalmarriott  

Google+ - https://plus.google.com/u/0/109059474716876336577/posts/p/pub

No comments:

Post a Comment