Click here to Skip to main content
15,913,758 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: The Laziness of LINQ Pin
ImHere2Learn11-Aug-15 18:41
professionalImHere2Learn11-Aug-15 18:41 
GeneralRe: The Laziness of LINQ Pin
Dominic Burford11-Aug-15 21:32
professionalDominic Burford11-Aug-15 21:32 
GeneralRe: The Laziness of LINQ Pin
OriginalGriff11-Aug-15 22:09
mveOriginalGriff11-Aug-15 22:09 
GeneralRe: The Laziness of LINQ Pin
Rowdy Raider13-Aug-15 4:54
Rowdy Raider13-Aug-15 4:54 
GeneralRe: The Laziness of LINQ Pin
codejager13-Aug-15 23:05
codejager13-Aug-15 23:05 
GeneralRe: The Laziness of LINQ Pin
PIEBALDconsult13-Aug-15 6:07
mvePIEBALDconsult13-Aug-15 6:07 
GeneralRe: The Laziness of LINQ Pin
Steve Wellens12-Aug-15 2:57
Steve Wellens12-Aug-15 2:57 
GeneralRe: The Laziness of LINQ Pin
Steven Melendez14-Aug-15 2:46
Steven Melendez14-Aug-15 2:46 
I have to agree to an extent. Consider the following:

C#
var user = new User();


This is fine imho because it explicitly states the type on the right. I don't mind seeing types on the right with a var on the declaration of type because it is still right there.

C#
User user = new User();


This just feels unnecessary to me because you are stating it in two places;

C#
var user = GetUser(userId);


I don't like this one either as the type of user can be assumed, but isn't immediately obvious in more complicated examples. In this example, sure, you can assume user, but what if you were actually returning:

C#
IQueryable<User> user = GetUser(userId);


because for some odd business reason, a user consisted of multiple users. It is still a single base user in this example that logged in, but he has multiple user objects. Returning the IQueryable allows us to further filter afterwards, but it isn't obvious.

So, my own idea of a go to is if it is explicitly stated on the right, var on the left is fine. If not, then no. Even if it appears to be an obvious return value, you don't truly know unless you have intimate knowledge of the code.
Steve

JokeRe: The Laziness of LINQ Pin
Agent__00711-Aug-15 18:46
professionalAgent__00711-Aug-15 18:46 
GeneralRe: The Laziness of LINQ Pin
ZurdoDev12-Aug-15 1:18
professionalZurdoDev12-Aug-15 1:18 
GeneralRe: The Laziness of LINQ Pin
V.11-Aug-15 20:06
professionalV.11-Aug-15 20:06 
QuestionRe: The Laziness of LINQ Pin
CPallini11-Aug-15 20:34
mveCPallini11-Aug-15 20:34 
GeneralRe: The Laziness of LINQ Pin
Kornfeld Eliyahu Peter11-Aug-15 21:14
professionalKornfeld Eliyahu Peter11-Aug-15 21:14 
JokeRe: The Laziness of LINQ Pin
Mycroft Holmes11-Aug-15 21:25
professionalMycroft Holmes11-Aug-15 21:25 
GeneralRe: The Laziness of LINQ Pin
Wastedtalent11-Aug-15 21:31
professionalWastedtalent11-Aug-15 21:31 
GeneralRe: The Laziness of LINQ Pin
Dominic Burford11-Aug-15 21:35
professionalDominic Burford11-Aug-15 21:35 
GeneralRe: The Laziness of LINQ Pin
Kornfeld Eliyahu Peter11-Aug-15 21:54
professionalKornfeld Eliyahu Peter11-Aug-15 21:54 
GeneralRe: The Laziness of LINQ Pin
Vark11112-Aug-15 9:10
Vark11112-Aug-15 9:10 
GeneralRe: The Laziness of LINQ Pin
maze312-Aug-15 22:28
professionalmaze312-Aug-15 22:28 
GeneralRe: The Laziness of LINQ Pin
Rob Philpott11-Aug-15 22:54
Rob Philpott11-Aug-15 22:54 
GeneralRe: The Laziness of LINQ Pin
Herbie Mountjoy13-Aug-15 4:53
professionalHerbie Mountjoy13-Aug-15 4:53 
GeneralRe: The Laziness of LINQ Pin
Power Puff Boy11-Aug-15 23:13
Power Puff Boy11-Aug-15 23:13 
GeneralRe: The Laziness of LINQ Pin
Duncan Edwards Jones11-Aug-15 23:26
professionalDuncan Edwards Jones11-Aug-15 23:26 
GeneralRe: The Laziness of LINQ Pin
Jacquers12-Aug-15 1:06
Jacquers12-Aug-15 1:06 
GeneralRe: The Laziness of LINQ Pin
Matthew Dennis12-Aug-15 2:44
sysadminMatthew Dennis12-Aug-15 2:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.