As a developer who prides myself in the less popular things such as documentation and standardized code I find it frustrating when I read code that has been "shortened" or "abbreviated" in the name of efficiency. A common theme I am struggling with these days is developers who choose to abbreviate their code for reasons such as "its easier to type" or "it fits better on the screen". As an example, I am frequently seeing the use of a variable name of 'q' instead of 'query' or 'u' instead of 'username'. Don't get me wrong, I am all for efficiencies. But when maintaining this code I find it is much more difficult to understand in order to improve or fix when these abbreviations have been used throughout the code. Imagine a method that finds data in several databases and the variables in scope are 'q', 'u', 'p', 'r', 'd'. Thats a headscratcher if any complexity is involved in the method.
Adding to the frustration is the argument that involves simple editors as a valid reason for this approach. I love 'vi' but for development a good IDE is second to none. Using context assist in eclipse can reduce your overall keystrokes when you need to type out 'username' instead of 'u' and can prevent you from typos. Yes, I see tons of typos in code developed by developers using 'vi'(probably an exception to the rule, but I have my doubts). Using a simple editor is not an excuse.
Is it really too much to ask to type out 'query' instead of 'q'? Descriptive naming in classes, methods, and variables/properties can result in less protracted maintenance over the life of a piece of code. I personally found it difficult when I first decided to be more descriptive in my syntax. However, in a short amount of time you will find it becomes much easier to find appropriate and descriptive names and your code will improve. In the end, you owe it to your fellow developers to do everything in your power to make everyone's life easier through more descriptive syntax.
1 comment:
You'll be impressed that I actually read this, understood (basically) what you were saying, and agree with you completely.
Shorter is NOT better. Which, I think we'll all agree, can apply to many aspects of one's life. ;)
Post a Comment