Solved

Inheritance

Posted on 2008-06-24
4
434 Views
Last Modified: 2013-11-26
HI Experts

We have a .NET application (VS 2008) that uses the Factory and Command Patterns to generate & invoke commands. Commands are logged, may have or not have timer support and are classified to categories which are also hierarchical (i.e. in category A you have commannd A1 and command A11 that is inherited from command A1 and so on...)

The difficulty with this is debug, since there are about 7 levels in the hierarchy , it takes time to navigate   and find the problem origin.

Questions :

1) When I did OO courses, I remember that they strongly recommended not to pass the 3 object hierarchy depth , is that true?

2) What design alternatives can you recommend in order to make our commands hierarchy shorter ?

Thanks
cmd.JPG
0
Comment
Question by:elimesika
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:mastoo
ID: 21866714
1) One of my favorite books:
  "Heuristic 5.4 In theroy, inheritance hierarchies should be deep - the deeper, the better.
  Heruistic 5.5 In practice, inheritance hierarchies should be no deeper than an average person can keep in his or her short-term memory.  A popular value for this depth is six."  I must be more feeble minded than most as I like 3.

2) I can't read the jpg but it looks like you might be suffering a class explosion.  The command pattern purpose is to encapsulate requests, hiding implementation from the caller.  Possibly a narrower command hierarchy using classes representing individual functionality within a command and then aggregating functionality via Mediator pattern.
0
 
LVL 19

Author Comment

by:elimesika
ID: 21868871
HI

Thanks for your respond.
Given that all commands are isolated and have no commnad-to-command commun ication, it seems that the mediator pattern will not help to simplify this.

Is there a way to use interfaces when applicable instead of classes in the inheritance tree to shorten the depth of the inheritance tree ???

0
 
LVL 21

Accepted Solution

by:
mastoo earned 500 total points
ID: 21869841
I meant that you'd have a smaller number of command classes, and when they are constructed they get different components added.  I was thinking the mediator within the command would orchestrate those pieces, but on second thought that would be overkill.

For instance, during construction the factory feeds the command constructor a CLogger.  CLogger might be a base class reference to a CLogPrinter or CLogFile.  I'm not sure if this example applies to your case but it would be one less dimension for the command hierarchy and it helps with another golden rule: A class should capture one and only one key abstraction (i.e., a command shouldn't have to worry about implementation of logging).
0
 
LVL 19

Author Closing Comment

by:elimesika
ID: 31470387
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question