The Art of Writing Maintainable Code
Debugging is twice as hard as writing code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. - Brian Kernighan
If you’ve been programming for any length of time I’m sure at one time you’ve had the pleasure (or lack thereof) of wading through another persons code. It is definitely not a pleasurable journey when the code is new, written with the newest standards; but when the code is legacy it can be a downright hair-pulling experience.
The problem with a lot of code is that it isn’t written in a maintainable way. Now you may ask, what is “Maintainable Code”? Maintainable code is purely code that can easily be maintained throughout the years and on different platforms. If you asked 100 people that write code for a living you would probably get 100 different answers on how to write your own maintainable code. Below is a list of things that can help you make your code more maintainable.
1. Good Use of Comments:
Commenting your code is extremely useful if you do it in a good way. I’ve already written about commenting in “The Art of Commenting” and the article does provide a bunch of good tips on how to comment your code but it doesn’t really say why it’s important. When a person reads another persons code they really have no idea what the original programmer was thinking. Comments (when done right) provide a great insight into the mindset of the code’s owner, providing an idea of why (s)he wrote the loop structure like they did or why they included that certain function.If the writer of the code did comment properly you’ll be able to update the code to the newest standard without to many troubles. Since commenting code for many programmers is an afterthought or at least not their highest priority, you know that if the comments are good then the rest of the program is probably written in good form as well.
Adam McKerlie is a 20 year old University student currently studying at the University of Guelph. He spends his time writing tutorials and articles on programming, computers and internet related things
Article Source: ArticlesBase.com - The Art of Writing Maintainable Code