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.

About Jeremy Miller

Jeremy is the Chief Software Architect at Dovetail Software, the coolest ISV in Austin. 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 is the author of the open source StructureMap tool for Dependency Injection with .Net, StoryTeller for supercharged acceptance testing in .Net, and one of the principal developers behind FubuMVC. Jeremy's thoughts on all things software can be found at The Shade Tree Developer at http://codebetter.com/jeremymiller.
This entry was posted in Ranting. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.backlinkschecker.ws/backlinks/buylinks.html Purchase High PR Backlink

    thanks for the my comments

  • Carlton Nettleton

    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?

  • http://www.codebetter.com/blogs/raymond.lewallen Raymond Lewallen

    Won’t be my first tattoo, but I’m going to get one that says “Atomic Methods : Atomic Unit Tests”