Over the years I have written quite a lot of code. These are the tips that I wish I had known when I had started out and would have saved me a lot of head scratching and restless nights:
- Create a “to do” list. Always write down your tasks and keep it updated as you work through the problem. Your memory is limited and you can often forget something which may be critical later.
- Always use variables and don’t hardcode. Generally this will make your life easier and it makes the application more flexible.
- Code comments are your friend. Many times I returned to code I have written and never known what a function or piece of code is expected to do. If I had taken some time out to put some comments into the code it would have saved me hours troubleshooting issues.
- Always break a big problem into a series of small problems. Sometimes a big problem can feel daunting and be more difficult than it seems. Break the problem down into smaller blocks and then solve each block one at a time. It’s okay to skip a block and return to a previous block as it may give you clues to fixing the skipped block.
- Errors are not a bad thing they tell you where the problem is. This will help you to solve the error more easily and doesn’t mean you’re a bad programmer. Only be worried when something goes wrong and you don’t get an error message.
- Never reinvent the wheel. It is more than likely someone has faced the same problem as you and it is okay to copy their solution.
- A difficult problem doesn’t mean you’re a failure. There will be times when you face a problem which you find hard to grasp. It is perfectly acceptable to find things difficult.
- Know who to contact in your ogranisation to ask questions. When you have very little information and need more details it is infinitely better when you have a list of go to people for all the applications you will be supporting.
- 99% of your work will never be seen by anyone. Your solution may not necessarily be the most elegant one but try to keep it simple.
- Prototypes do not have to always end up in production. Building things allows us to learn from coding. What you learnt is better than whether it ends up in production. Sometimes it is better to start again than fix problems with some poorly written code.
- Read code of more experienced programmers. When you get passed some code don’t just deploy it. Read it and review it. You might learn something or you might pick up a problem which will save everyone time.
- Don’t stop learning. Programming can change quite rapidly. If you don’t invest in learning new things you might end up encountering it for the first time when you are debugging something in production
Feel free to comment with any additional tips which you may have.