CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeremy D. Miller -- The Shade Tree Developer

Under the hood and working with .Net, TDD, Software Design, and Agile Stuff

Quick way to spot a Blob class

I'm in an all day set of meetings today to talk about how we're going to make our legacy web framework testable in the next version of the application.  It's going to be a cool project to do. 

One of the first things you notice about this codebase is the central class.  It's an obvious blob class.  How do I know it's a blob?  First off, I counted 31 "usings" statements at the top of the class file.  Then I see business logic, HTML, javascript, and database manipulation all happily jumbled together in an ASP.NET user control.  My very first recommendation is basic surgery.  "Extract Class" here I come. 

I don't know what I'd say for a hard limit to the number of namespace references, but if you've got a bunch you probably better start thinking about splitting up the class.

Let's all say it together -- "One class, one responsibility."  Someday I'm gonna make this my very first tattoo.


Published Jul 22 2005, 04:58 PM by Jeremy D. Miller
Filed under:

Comments

Raymond Lewallen said:

Won't be my first tattoo, but I'm going to get one that says "Atomic Methods : Atomic Unit Tests"
# July 22, 2005 10:23 AM

Carlton Nettleton said:

Here's a question about namespaces in Dot.Net - everytime you make a new folder, you are essentially creting a new namespace. Just recently, I reorganized some DTO's (data transfer objects) into their own folder and needed to add that namespace to all my code (thank God for the compiler and my tests). Is this the type of thing you were referring to with this post? Or would the better course have been to keep the original namespace AND move into the new folder?
# July 29, 2005 1:48 PM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Jeremy D. Miller

Jeremy began his IT career writing "Shadow IT" applications to automate his engineering documentation, then wandered into software development because it looked like more fun. Jeremy previously worked as a systems architect building mission critical supply chain software for a Fortune 100 company and learned agile development practices as a .Net consultant at ThoughtWorks, one of the pioneers of agile development. Jeremy is the author of the open source StructureMap (http://structuremap.sourceforge.net) tool for Dependency Injection with .Net and the forthcoming StoryTeller (http://storyteller.tigris.org) tool for supercharged FIT testing in .Net. Jeremy's thoughts on just about everything software related can be found on his weblog "The Shade Tree Developer" at http://codebetter.com/blogs/jeremy.miller, part of the popular CodeBetter site. Jeremy is a Microsoft MVP for C#. Check out Devlicio.us!

This Blog

Syndication

News

All opinions expressed here constitute my (Jeremy D. Miller's) personal opinion, and do not necessarily represent the opinion of any other organization or person, including (but not limited to) my fellow employees, my employer, its clients or their agents.

About Me

"Best Of" Compendium

StructureMap (Dependency Injection for .Net)

StoryTeller (Supercharged Fit)

Build your own Cab

TestDriven

MVP