New Posts New Posts RSS Feed: TechTip: Managing Class Hierarchies with Class View
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

TechTip: Managing Class Hierarchies with Class View

 Post Reply Post Reply
Author
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Topic: TechTip: Managing Class Hierarchies with Class View
    Posted: 09-Jul-2007 at 12:22pm
Level 100
DevForce Express
Managing Class Hierarchies with Class View
Deep class hierarchies are mind benders for all of us.

We're starting to see a lot more of them now, thanks to the "refactoring" mantra chanted by the "Design Patterns" and "Agile" gurus.

We happen to agree with those gurus. It really is worth refactoring code, most especially to purge it of the code duplication that undermines maintenance and testability.

"Extract Subclass" is the refactoring practice that often leads to multi-level class hierarchies. Do it often enough and you'll get an unpleasant profusion of classes, each in their own code files and often in separate assemblies that may not even be in your solution.

Here, for example, is an inheritance hierarchy for the application startup class called "ShellApplication":

These five classes are distributed among four separate projects only one of which is in your solution.

 

Class

Project

In Solution

ShellApplication

Shell

Yes

XtraFormApplicationBase

DevExpress.CompositeUI

No

WindowsFormsApplication

Microsoft.Practices.CompositeUI.WinForms

No

CabShellApplication

Microsoft.Practices.CompositeUI

No

CabApplication

Microsoft.Practices.CompositeUI

No

 

You look at "ShellApplication" and wonder "what are the members available to me?" and "why does this have to be so hard?"

When you see this happening to your code base, it's a good time to stop and ask if the trend is really paying off. Your code's intelligibility declines dramatically with every new level. Are there compensating benefits in maintenance, extensibility, and reuse? Are the benefits greater than the cost?

For many developers the easy answer is "NO WAY".

We feel your pain. Almost all of the good refactorings and design patterns (not just "Extract Subclass") result in more code files and more assemblies. It's a serious manageability problem.

On the other hand, we see the benefits and we are not ready to surrender. Perhaps there is a way to tame the complexity.

There is: a helpful Integrated Development Environment (IDE) makes all the difference. In fact, the "refactoring" movement would have gone nowhere without the new breed of IDEs to help us manage complexity.

Visual Studio 2005 is a leader among this new breed. All we have to do is learn how to use it. That takes some patience. There are a lot of great features. Some are hard to find. Some don't seem immediately useful, until a good friend shows you how to use it and you get that "aha!" moment.

Get ready for an "aha" moment: the Class View. You'll find it on the "View menu" (ctrl+shift+C).

 
 

It doesn't look like much at first but its become a fast friend of ours. We feel it is "the answer" for coping with class hierarchies and it just might change your mind about refactoring.

We could go on about it in print. But you might get more from watching a short movie (7 minutes). Just follow this link: http://www.ideablade.com/webinars/vsclassview/vsclassview.html

Give it a try and let us know what you think.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down