ReSharper & How I write code…

Gregory Beamer is writing an interesting series on Linear thinking.  I think the PoEAA name for what he’s talking about is Transaction Script and boy have I seen a lot of it. 

One of the problems that Gregory brings up is large classes.  Now I haven’t seen the classes in question but to me it seems smelly that the class is complex enough that Gregory would need to use screen splitting to see the variables that exist for the class and the rest of the code.

In following with some fairly common advice I’ve switched to the small method style.  I try to refactor all my methods so that they are around 10 lines or less and then name things appropriately.  I’ve talked with co-workers and they do agree that it helps make the code more understandable. 

One of the other things that I do though is to try and keep my classes small.  I obviously don’t always succeed at this but if I see a chance to take a piece of functionality in a class that can happily live on it’s own I will let it by creating a new class.  I then move all the variables and methods into that class.  I was going to mention this on Gregory’s post but while writing my comment something struck me.  The one problem with this method of working is that it does create a lot of classes.  Now to some people I’ve ran into this is a big deal.  To me it’s not a big deal at all and when I really think about it a large reason that it’s not a big deal for me is that I can use ReSharper as easily as I can use notepad.  After years of usage ReSharper has just become a natural extension of the IDE for me that allows me to quickly my code. 

So the question then is is this valid?  I find that the classes make a lot more sense, have a higher cohesion and lower coupling then otherwise.  These things obviously are good things.  But is the increased cost of navigation and potentially understanding worth it? 

posted @ Saturday, March 28, 2009 9:00 AM

Comments have been closed on this topic.