I would like to touch on two things. Both of these things drive me absolutely insane because I enjoy reading nice code. Well written code should be really easy to understand at a high level. It should be clear and concise. These two things take away from it.
The first is abbreviating variable names. Some people like to give me a load of crap for my naming conventions. It would not be uncommon for you to find this in my code:
bool isIndicatorLightTurnOnDuringExecution = DetermineIndicatorLightStateDuringExecution();
Some people would argue that this is wrong because of having to type so much, but let me tell you what's right. I know exactly what this variable is holding, and what this method is doing. I am extremely diligent and naming my variables and methods for EXACTLY what they do. Why don't I use abbreviations or chop out some words? Because, I want to know what is going on in my code, and there isn't a chance in hell of me writing a comment without somebody making me. And can you tell me what this means:
bool isLightOn = CheckLight();
Sort of. There's a light there. But that's all I can tell you. Yeah, I can go dig through the code, but who the hell wants to do that. This may have taken me a little less time to write, but that time savings is going to be lost when I come back through when my code breaks (WHAT?) and try to figure out what is going on. This is just laziness. Or how about his one:
bool isIndLgtTrnOnDurExe = DetIndLghtSteDurExe();
Now, I have no idea what this means. I would argue that it probably takes less time to write the long form of this code than the abbreviate version of it, because I have to stop and try to figure out which letters to leave out and which to keep in. Also, am I coding in assembly language? Not last time I checked. That name is not taking up more or less space, so who care about shorting it. I wouldn't do it, ever. Take the time to write it out, and you'll be happier when you do.
The second thing that drives me nuts in the creation of the var in .NET 3.5. I hate using it. I hate seeing it. I hope it dies and goes away. Why? I am not gaining anything from it. Is it really hard to type out bool? Nope. Is it hard to type out ObservableCollection<objecct>? Maybe it used to be, but with intellisense, I don't type all of any word anyway, I hit only the first three or four keys and then move on. The thing that I lose with var is the ability to easily see what my variable is. Take this:
var item = DoSomething();
var otherItem = DoSomethingElse();
return item.Equals(otherItem);
What is this doing? I have no idea. I now have to go look at the implementation of DoSomething() and DoSomethingElse() to figure it out. Totally unreadable. I hope the decision is made to eventually get rid of var.
1 comments:
Please post your latest code that uses LINQ to query against a collection. I'm curious the syntax you use.
Sincerely,
Fellow C#'er
Post a Comment