July 2nd, 2010A Handy Refactoring with CodeRush (InLine Temp)
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.









July 4th, 2010 at 3:55 am
how about CodeRush vs ReSharper
January 26th, 2012 at 5:15 am
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.
January 26th, 2012 at 8:33 am
Hi Mallorca, can you give an example?
February 6th, 2012 at 1:54 am
listSessionAttendees = SessionAttendeeODS().GetByUsername(Context.User.Identity.Name);
doesn’t this work in C#? I remember I did something like this a few times.
February 6th, 2012 at 10:16 am
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.