Swiss Army Knife

I saw an interesting post from Ben Scheirman last Saturday on the separation of concerns with regard to ASP.NET MVC controllers. Apparently, Preview 4 includes a new AccountController that contains some...ahem...less than production quality code. Ben refactors the code and gives it a more professional polish and the story ends happily.

However, what I found most interesting was one of the comments to his post. And I quote:

"I'm beginning to get a distaste for controllers. It seems like too much code in one place."

To me, this is a very interesting comment because it is characteristic of something that I notice quite frequently: people seem reluctant to create new classes even when new classes are required (disclaimer: sometimes "people" means me). They seem to get into a mind set that certain code needs to go in a certain place versus thinking about classes in terms of behavior. I see this from developers across all levels of experience, too.

Unfortunately, this way of thinking leads to an anti-pattern that I like to call Swiss Army Knife. This is the class that does it all and behaves however you need it to behave.

Here's the thing. We all know this is not a good thing. Whether we have a controller, a view, a presenter, a repository, or a whatever, a class is about behavior. It is there to do a specific job. When we notice that our class is starting to exhibit a split personality, we break it into two classes. No need to be afraid. Code is the most malleable substance on the planet. If we don't like the results, we can always refactor and try again. I know this is common wisdom, but it seems that under certain circumstances, we just forget to do it.

ReSharper Build 910

I am going to go for it. It contains fixes for 7 bugs that I reported plus a slew of other fixes. I have to say that I really like the way Jetbrains handles their bug fixes. When you report a bug, you are notified when the bug has been assigned to a developer as well as when it is fixed. When a build is done, it is easy to see if bugs that you reported were fixed. Compare this to the "send and pray something will get done" method employed by many MS programs. Seriously, I wonder where all my bug reports to MS go. No visibility whatsoever.

ALT.NET Houston Geek Dinner #2

I have to say that last nights dinner was a success. Although, I must admit I am easy to please. If I learn a new keyboard shortcut I consider it time well spent. For instance, I had no idea you could jump to type declarations using Resharper by holding the CTRL key and dragging the mouse around. It's really cool. ReSharper underlines all your types and basically turns them into hyperlinks. Conversely, a colleague of mine did not know Shift+Alt+L would allow you to jump to a file in Solution Explorer. See, this is why geek dinners are good.

Anyway, we discussed the Entity Framework Vote of No Confidence,  our favorite tools, and putting together an Open Spaces event sometime at the end of the year (beginning of next year?). To top it off, Jay Sawyer (a very cool Microsoft guy) was there, and picked up the tab. Thanks Jay!

Okay, that's all I've got, so I will leave you with one final bonus keyboard shortcut  (that I learned yesterday from my co-worker Eric Geiger who always seems to have cool tips): Holding down CTRL turns the IntelliSense window transparent so you can see the code underneath it. Ta da! How did I not notice this before now?