knowledge-database (beta)

Current group: comp.object

small base class

small base class  
Guybrush Treepwood
 Re: small base class  
iamfractal at hotmail.com
 Re: small base class  
H. S. Lahman
From:Guybrush Treepwood
Subject:small base class
Date:Tue, 11 Jan 2005 07:12:28 +0100
I'm programming a postnetwork simulation. There are Offices and Links
between them, postmessages get send through to another office whenever
there still is no link between the office and the recipient. So the
recipients are regular people who can receive a message, but from where you
can't send one. The offices and links are checked by a discrete event
simulator to see if they have anything to send.

Is thought something about this would do as inheritance hierarchy:

abstract base class: Receiver

abstract class ControlableObject inherits from Receiver
Person inherits from Receiver

Office inherits from ControlableObject
Link inherits from ControlableObject

My question now is, the abstract base class Receiver has only 1 method,
receive. This makes me wonder, is this a good design?
From:iamfractal at hotmail.com
Subject:Re: small base class
Date:12 Jan 2005 03:38:17 -0800

Guybrush Treepwood wrote:
> I'm programming a postnetwork simulation. There are Offices and Links
> between them, postmessages get send through to another office
whenever
> there still is no link between the office and the recipient. So the
> recipients are regular people who can receive a message, but from
where you
> can't send one. The offices and links are checked by a discrete event
> simulator to see if they have anything to send.
>
> Is thought something about this would do as inheritance hierarchy:
>
> abstract base class: Receiver
>
> abstract class ControlableObject inherits from Receiver
> Person inherits from Receiver
>
> Office inherits from ControlableObject
> Link inherits from ControlableObject
>
> My question now is, the abstract base class Receiver has only 1
method,
> receive. This makes me wonder, is this a good design?

This is not a bad design just because that abstract base class has only
1 method. Classes (even abstract base ones) should have as many classes
as they need to have, and no more.
..ed

www.EdmundKirwan.com - Home of The Fractal Class Composition.
From:H. S. Lahman
Subject:Re: small base class
Date:Thu, 13 Jan 2005 21:16:53 GMT
Responding to Treepwood...

> I'm programming a postnetwork simulation. There are Offices and Links
> between them, postmessages get send through to another office whenever
> there still is no link between the office and the recipient. So the
> recipients are regular people who can receive a message, but from where you
> can't send one. The offices and links are checked by a discrete event
> simulator to see if they have anything to send.
>
> Is thought something about this would do as inheritance hierarchy:
>
> abstract base class: Receiver
>
> abstract class ControlableObject inherits from Receiver
> Person inherits from Receiver
>
> Office inherits from ControlableObject
> Link inherits from ControlableObject
>
> My question now is, the abstract base class Receiver has only 1 method,
> receive. This makes me wonder, is this a good design?

Having only one method in a superclass does not inherently say anything
about the quality of the design.

What I would push back on is why you think you need inheritance in this
situation at all. Or why you feel you have to use composition in
particular to solve the problem.

*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
hsl@pathfindermda.com
Pathfinder Solutions -- Put MDA to Work
http://www.pathfindermda.com
blog (under constr): http://pathfinderpeople.blogs.com/hslahman
(888)-OOA-PATH
   

Copyright © 2006 knowledge-database   -   All rights reserved