When writing code, you learn that there are many ways to perform the same task. Many times, there is no difference in the methods. However, whenever possible, it is important to focus on keeping your code efficient.
One way to keep your code efficient is to avoid repeating code. For example, if you perform a calculation several times, it is a good idea to encapsulate it into a method. This way, if you need to change the code in some way, there's only one place to modify.
Also, thinking through your code can save unnecessary code. An example of this is avoiding unnecessary checking. Avoid covering scenarios that are not logically possible.
Finally, remember that the more efficient your code is, the easier it will be to maintain.
Monday, October 8, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment