10 Golden rules from become a Better Programmer

DON’T REPEAT YOURSELF This is a great principle to follow. I really enjoy going back through my code after I have written it and refactoring parts that are used more than once. I get a buzz from reducing a long method down to several short methods. Ctrl+R+M works great in Visual Studio to help you refactor code into separate methods. This makes the code more reusable and testable. NAME YOUR VARIABLES TO SAY WHAT THEY ARE FOR, NOT WHAT DATA TYPE THEY ARE The only exception to this is if you are picking up someone else’s code and are continuing with that, you should carry on with their naming convention. GIVE YOUR METHODS A CLEAR NAME FOR WHAT THEY ARE GOING TO DO. If you do this well, it reduces the need for comments. You shouldn’t need comments if your code is clear enough to read. DON’T USE MAGIC NUMBERS OR STRING LITERALS There shouldn’t be any numbers or string values in your code that when someone comes to read later wonders what they are. Create constants, enums or private variables to give them a name so it is easier to understand. WRITE YOUR METHODS SO THEY CAN BE TESTED WITHOUT HAVING ANY DEPENDENCIES ON OTHER PARTS OF THE APPLICATION, WHERE POSSIBLE. Write it in a way that it doesn’t matter where it was called from. It makes the code far more testable and reusable. If you are using session values or app setting values, pass them in as variables instead and get the session and config values at the point you call the method. This makes it far more testable. DON’T BE AFRAID TO ASK FOR HELP I’m not saying you should ask for help with everything and not learn for yourself, I mean have a good go yourself, but if you are stuck ask someone for help. They may have already had this problem and know how to solve it. Also the process of telling someone about what you are doing, what you are expecting and what the problem is, can bring you to solving it yourself. FOLLOW THE BOY SCOUT RULE If you see some buggy or messy code, fix it while you are there and move on. Don’t leave it for someone else to do, but don’t rewrite the whole program either. SHARE KNOWLEDGE WITH OTHERS Don’t be selfish by keeping your knowledge to yourself. Try to create a culture of helping others. You’ll find that you will work better as a team and you can help each other to improve. You’re not giving away knowledge and putting your job in danger if your colleagues improve. You are making yourself more valuable as you are someone who not only has the knowledge, but can also help other around them improve. DON’T INTERRUPT YOUR COLLEAGUES WHILST THEY ARE IN THE FLOW Think about it, when you are programming you have all of these pieces that you are putting together in your mind, like a house of cards you are carefully trying to build. If someone interrupts you to ask a question, then you lose concentration and that house of cards could easily fall down. It may take them 5 or 10 minutes to get that concentration and pieces back together in their mind, when you could have googled it or asked someone else. If you give your colleagues this respect and let them know, they will do the same for you, which in turn will make you more productive. USE CRITICISM AS A POSITIVE INSTEAD OF A NEGATIVE. To me, criticism is a chance for me to improve. If there is another way of doing something that I haven’t thought of then I want to know about it as it will help me to improve.

Modal dialog

You won't be able to dismiss this by usual means (escape or click button), but you can close it programatically based on user choices or actions.