Books of .Net/Interview Questions Interview Questions and Answers Programs C# Concept OOPS Concept JOBS

Saturday, July 1, 2017

Eight Golden Rules For Better Programming



In this blog,I will cover golden rule for better programming.It can be practiced by any platform programmer at any experience level so as to improve their coding.
  • Learn by doing First rule is to learn any concept by doing it or practice it. You can read thousand of books. A lot of reading will probably help you to understand concepts but with practice or implementing you willunderstand it better.
  • Write self-explanatory code You should have a habit of writing the code which is self-explanatory, thus requiring minimum efforts in understanding it and thus resulting in minimum comments.
  • Don't eat up exceptions exceptions are part of programming and good programmer should know how to handle it. Write code which handles every possible error suiting the business scenario, and if any unexpected exception arises, don't eat it up in my code, but better throw it, so that it is logged/reported somewhere in the Application and someone can take care of it later.It is always better to gracefully handle the exception and tell the user that something bad has happened, rather than hide it behind the curtain.
  • Names Matter – Name your variables, classes, methods, everything with care. Who cares if names get long. If they communicate what’s going on, let it go! This will go a long way in helping your future readers understand your code. It will also cut down or eliminate the need for code comments. 
  • Use Patterns – Like anybody who makes things for a living, patterns and templates are essential to reproducing similar types of products or work. Same goes for software development. There are tons of great “pre-thought-out” patterns for programmers to pick up and use. And, later on, other developers, who are also aware of those patterns, can look at your use of this or that pattern and know EXACTLY what is going on. Or you can ignore the patterns out there and do everything your way, alienating and confusing your future readers, making them hate you. Your choice.
  • 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.
  • 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 eachother 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.
  • Get your code reviewed by a team lead/colleague No matter how experienced a developer you may be, a second look by someone else always helps. You cannot always see your obvious/silly mistakes while someone else quickly can. It has nothing to do with the other person's expertise or experience, it's just human nature.Not only this, you can also review code written by others, and you don't have to be an expert for this. You can always learn something new reviewing others' code, maybe a better use of some design pattern, better performing code, a new OO principle usage, etc.

No comments :

Post a Comment