|
Everyone prefers a minified version of code, you know...
You have just been Sharapova'd.
|
|
|
|
|
Agent__007 wrote: Everyone prefers a minified version of code Exactly. I removed the space bar from my keyboard because I never use it.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
It was still taught in school 10 years ago. I actually like the single letter counters as it is an indication in itself. Personally I mostly use it in for loops.
as PIEBALDconsult said: it's a throw away.
|
|
|
|
|
Do you find LINQ too much terse and add verbosity on purpose?
On the serious side, I fully agree with our PIEBALD.
|
|
|
|
|
Obviously, you never were a script kiddie...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
|
I have to admit I use single characters for linq but I do at least try to to use the first letter of the object type (Person => p) etc.
I am not a big fan of var. I think it encourages lazy programming, though used well it makes sense.
|
|
|
|
|
Quote: I am not a big fan of var. I think it encourages lazy programming, though used well it makes sense. Rarely is the "var" keyword used as it was intended. I blame this on lazy programmers blindly following ReSharper's suggestion to replace every single variable declaration with "var".
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare
Home | LinkedIn | Google+ | Twitter
|
|
|
|
|
Dominic Burford wrote: blindly following ReSharper's suggestion to replace every single variable declaration with "var" At that suggestion I removed ReSharper for good...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Dominic Burford wrote: blindly following ReSharper's suggestion to replace every single variable declaration with "var".
My Resharper doesn't do that, and I don't think I've changed any of the defaults
Even obvious stuff like:
string message = string.Format("Error in xyz method: {0}", ex.Message);
doesn't get flagged by it.
|
|
|
|
|
thought someone would mention this (but then read the dislike of var )
With
return source.Select(t => new
{
Index = rand.Next(),
Value = t
})
What is 't' short for? Table?
With loops, 'i' and 'x' (I assume) come from iterator and Maths use of variables.
(then subsequently y follows from 'x')
with linq, it is a sort of replacement for the item working on.
In the case above 'source'
so maybe 's' or 'src' if 'source' is too long to type.
|
|
|
|
|
Because LINQ is evil.
Regards,
Rob Philpott.
|
|
|
|
|
Hear hear!
I may not last forever but the mess I leave behind certainly will.
|
|
|
|
|
I could have told you 20 years ago that that's a battle you're certain to lose.
But I guess you know that by now.
Kitty at my foot and I waAAAant to touch it...
|
|
|
|
|
Lambdas are exactly the same - thousands of inline functions all called f()...
(Some people still think that Maths is the only metaphor in IT[^] )
modified 12-Aug-15 5:41am.
|
|
|
|
|
What! You can use more than one letter?
|
|
|
|
|
Oh oh, I think he's complaining about me
|
|
|
|
|
|
If it's a single lambda parameter, and its use is limited to a few lines, I nearly always only use a one char parameter, like:
var bachelors = _people.Where(p => !p.IsMarried);
I'm also a one letter man with basic loops. i and j all the way.
No object is so beautiful that, under certain conditions, it will not look ugly. - Oscar Wilde
|
|
|
|
|
Brady Kelly wrote: var bachelors = _people.Where(p => !p.IsMarried);
Generally, that's how I code, also. I specifically don't code that way when the LINQ code involves joins across a series of sources/tables. The
(a,b)=>
can get really messy, esp. if you need
(a,b)=> new {}
multiple times.
vuolsi così colà dove si puote
ciò che si vuole, e più non dimandare
--The answer to Minos and any question of "Why are we doing it this way?"
|
|
|
|
|
I think everyone is right here. The var keyword was put in specifically for LINQ. Yes - it does introduce a chance to code sloppy. Its a trade off. I like to use LINQ to slice over CSV Files, and other such collection queries.
I don't like var though, outside on its own, without a leash.
Where there's smoke, there's a Blue Screen of death.
|
|
|
|
|
Well, I wouldn't say you're TOO grumpy though I always considered those three (i,j,k) to be reserved as loop variants (Ever since FORTRAN IV) and still only use 'em for that even in my C# code!
Yeah, variable names ought to be a bit more descriptive!
|
|
|
|
|
This isn't isolated to LINQ. You see the same behavior in for/foreach loops as well. The only time I use single letters is when the variable is for an index.
Scott E. Corbett
|
|
|
|
|
I agree with you on the first Select because there's a little complexity in that lambda, but for the OrderBy and second Select, its one line of code, and if it isn't obvious what the parameter represents and how its being used, then a longer variable name isn't going to help the reader much.
Personally, for those one-liners, I prefer the simple 'p' argument -- less for my eye to read and my brain to parse (and ignore), which means I reach understanding of the code a lot faster.
We can program with only 1's, but if all you've got are zeros, you've got nothing.
|
|
|
|
|
I have always attributed this to the "it's a sample" mentatility. In samples you variables named myObj and newVar and stuff. You should not name things like that in production code, and neither should you use single letter small scope variables.
While I have seen both in production code (really, you named the search parameters myString?), I discourage their use (even in linq) in favor of more descriptive names. Perhaps we should insist on better quality examples for teaching these technologies to help instill better habits in new and learning programmers.
|
|
|
|