I’ve recently started using CodeRush with Visual Studio 2010 and am so far very impressed with the convenience it adds to coding. One thing that is very clear is that the creators of CodeRush are real programmers and look very hard for patterns that us developers are constantly doing. As I run into these things that get my attention, I plan on blogging them. Some are just earth shattering, and others, just nice to have. This particular one is a nice to have.
So, say you have code like this:
var sessionAttendeeOds =
new SessionAttendeeODS();
listSessionAttendees =
sessionAttendeeOds.GetByUsername(Context.User.Identity.Name);
When I chose “InlineTemp”, the code changes to the following, make it easier to read.
listSessionAttendees =
new SessionAttendeeODS().GetByUsername(Context.User.Identity.Name);
Again, this is not a huge deal, but small fixes like this will add up over time and make my code cleaner and more readable. CodeRush makes it so easy that I’m sure I’ll do this kind of thing more and more.
HTH’s.






yes mallorca, now I see what you mean. I often create intermediate variables just to keep things simple and then later put them back without having to use intermediate. I don’t think it matters performance wise. I hope the c# compiler takes care of that for us.
listSessionAttendees = SessionAttendeeODS().GetByUsername(Context.User.Identity.Name);
doesn’t this work in C#? I remember I did something like this a few times.
Hi Mallorca, can you give an example?
yes, but you can populate the list yourself right from the beginning, you don’t have to create that var only for creating an instance of the object.
how about CodeRush vs ReSharper