7 Programming Techniques That Every Developer Should Know
Clean codes are necessary when programming or coding a software application. Some programmers (from beginners to experts) sometimes fail to follow the basic principles when writing codes, thereby they find it difficult to read or understand their own hard written codes in the future. The readability of a source code has a direct impact on how well a developer comprehends a software system. Code maintainability refers to how easily that software system can be changed to add new features, modify existing features, fix bugs, or improve performance. Although readability and maintainability are the result of many factors, one particular facet of software development upon which all developers have an influence is coding technique. The easiest method to ensure that a team of developers will yield quality code is to establish a coding standard, which is then enforced at routine code reviews.
Full Article: http://entradasoft.com/blogs/7-programming-techniques-that-every-developer-should-know
KISS: The “keep it simple, stupid” principle applies to pretty much all of life, but it’s especially necessary in medium-to-large programming projects. It starts way in the beginning when you’re defining the scope of what you want to create. It is a good practice, as a developer, to keep your code as simple and readable as possible. By keeping it simple you can get the results you need with a few lines of code, produce higher quality code, solve problems faster, work effectively in developer groups and have a more flexible code base, among other things.
DRY: The “don’t repeat yourself” principle is crucial for clean and easy-to-modify code. This is the use of functions, classes and instances to allow you to avoid retyping code that has already been written once. This fundamental principle allows developers to avoid duplication to produce much cleaner code compared to the programmer who uses unnecessary repetition.
Comments: Although properly commenting source codes serve no purpose at run time, it is important to a developer who must maintain a particularly complex or cumbersome piece of software. Adding comments to your code makes updating, debugging, analyzing and other post-programming activities easier and more efficient.
Naming Convention: Having a proper naming convention is extremely important in a code as the doors for future edits and updating is always wide open. Having irrelevant or contradicting names to your pages, variables, functions or arrays will only create troubles for you in the future. Therefore, name elements on the basis of what they are and make it a habit to maintain a convention throughout your code.
YAGNI: The “you aren’t gonna need it” principle is the idea that you should never code for functionality that you may need in the future. Chances are, you won’t need it and it will be a waste of time — and not only that, but it will needlessly increase your code’s complexity
Law of Demeter: The Law of Demeter helps in maintaining independent classes and makes your code less coupled which is very important in software development to make your application flexible, stable, maintainable and understandable.
Premature Optimization: It is true that optimization helps in speeding up the program or algorithm but according to this principle you don’t need to optimize your algorithm at an early stage of development. If you do premature optimization you won’t be able to know where a program’s bottlenecks will be and maintenance will become harder for you. If you optimize your code in the beginning and in case if the requirement may change than your efforts will be wasted and your code will go to the garbage. So it’s better to optimize the algorithm at the right time to get the right benefit of it.
As programming is a group task, the success of your project heavily depends on your team. Hence it is heavily required that individuals write code which their peers can easily understand and maintain.