Re: Help on choosing a valid pattern: composite or not?
- From: "Mark Nicholls" <Nicholls.Mark@xxxxxxxxx>
- Date: 28 Nov 2005 08:37:57 -0800
Carmine Moleti wrote:
> Hi to everyone,
>
> I'm just writing a toy application using C# to make some
> practice with Patterns and layers.
>
> Now I'm faced with the "huge" dilemma of which pattern best
> suits the object oriented world I'm building.
>
> I have one object which represents a net, whose node
> can either be:
> 1. A net
> 2. A proper node (of various kinds; Factories?!)
Can it be both?
tell me when I go wrong.
A network consists of a set nodes and connections.
OK a node could itself contain a network of other nodes, but they would
not exist in the same network....that would seem a little odd.
>
> Both the "node" and the "net" have similarities in their
> interfaces.
OK
>
> For example:
> Net:
> - Add a node
> - Delete a node
> - Execute a node
>
>
> Node:
> - Link to node (Could be translated as: Add a link to a node)
> - Unlink to node (Could be translated as: Delete a link to a node)
> - Execute
>
> Node have some properties that Net doesn't have, and the
> clients are expected to deal with them.
>
> If it's possible, I would like to implement clients so that
> they shouldn't have to care about the difference between "nodes" and "nets".
>
> Without taking into account the "properties" aforementioned, from the
> GoF book I understand that the "Composite" pattern would be the
> route to take.
>
> The question is, is still "Composite" a good pattern to use
> if those "properties" are to be considered from a client
> stand point?
>
> Thanks in advance for your help.
> Regards,
> Carmine
I'm not convinced I completely understand how a node can be a node or a
net.
I would prefer to say all nodes are nodes, and some nodes contain a set
of nodes that form another 'net'.
thus you sort of have a tree of networks.
.
- Follow-Ups:
- Re: Help on choosing a valid pattern: composite or not?
- From: CarmineM
- Re: Help on choosing a valid pattern: composite or not?
- References:
- Help on choosing a valid pattern: composite or not?
- From: Carmine Moleti
- Help on choosing a valid pattern: composite or not?
- Prev by Date: Re: Help on choosing a valid pattern: composite or not?
- Next by Date: Re: OOAD Study Guide
- Previous by thread: Re: Help on choosing a valid pattern: composite or not?
- Next by thread: Re: Help on choosing a valid pattern: composite or not?
- Index(es):
Relevant Pages
|