Re: Help on choosing a valid pattern: composite or not?
- From: CarmineM <carmine@xxxxxxxxxxxx>
- Date: Mon, 28 Nov 2005 22:03:41 +0100
Hi to everyone,
First off, thanks for your efforts in helping me, and sorry for my poor explanation of the ideas.
*** The (short) story ***
A while ago, I wrote a sort of toolkit to play with neural networks (back prop.). As of today I've realized that I wrote it using objects but not quite in an object oriented way, so after reading some documentations, I thought it could be an interesting exercise writing it from scratch, this time with a different point of view.
*** The (rough) idea ***
Implement a toolkit that allows to: - Build "Nodes" with run-time pluggable behaviours that, given some numerical inputs, will produce one numerical output.
- Build "Nets" of such nodes that, given some numerical inputs, will produce one or more numerical outpus. "Nets" are partitioned in "Layers".
- Allow a "Net" to be a "Node" of another "Net" in such a way that the "Parent-Net" doesn't have to be aware of its subnets. It should treat them just as "Nodes".
- Extend the "Net" so that it could be persisted to some sort of storage (just to make things a little more funny, let's say that the storage medium can be chosen via a plugin interface). (O/R Mapping tools to use and/or implement?!?)
- Extend the "Net" and the "Node" so that it could be graphically represented and manipulated.
Why I think it "could be interesting" to write from scratch?
- Practice with MVC (or its variation) to decouple the model (Net, Nodes, Subnets...) from its graphical representation.
- Practice with what I've read in the GoF's Pattern book (Composites, Factories, Iterators, Strategies...)
- Practice with Application layering (UI, Business, Storage...)
- Try to find a spot where to insert some Dependency Injection ( a network needs a Log service and a Persistence service...)
- Use it to learn C# (and .NET framework) and Ruby
- Future plans: Nets (and subnets) can be remotable on LAN/WAN, can be wrapped in Web Services...
*** And now back to what I started writing in the original post ***
I came to the point of designing what the "Node" and the "Net" are ( yes, I've just stared bothering... :) ), and thought "Composite Pattern" could be of some help in unifying the interface from a client's point of view.
At its minimum the interface shared by "Node" and "Net" is:
- Execute . A "Net" can be told to execute itself, and that would mean to call each "Node"'s Execute . A "Node" can be told to execute itself, and that would mean to fetch its input and apply some calculation in order to produce its output. - Add . A "Node" can be added to a "Net", and that would mean to become the destination of some other "Node"'s output, and/or the input of another one (or one of the "Net"'s outputs...) . A "Net" can be added to another "Net", and that would mean to become one or more inputs of a "Node" and/or one of the parent "Net" outputs.
- Remove . A "Node" can be removed from a "Net", breaking all it's forward and backward links to other "Net"'s elements.
This means that "Node" and "Net" will contain other things aside of this shared interface.
E.g.: "Node" have some parameters that can be adjusted so that the
computing strategy can produce "better" outputs (whatever better means...)
That's what made me concerned about the "Composite Pattern". Would the differences between "Node" and "Net" suggest there is a suitable pattern than Composite to apply? (I thought of Flyweight because sharing "Node" could be an interesting variation point...)
I do really hope having been able to express myself clearly this time.
Thanks for your help!
Best regards, Carmine .
- Follow-Ups:
- Re: Help on choosing a valid pattern: composite or not?
- From: H. S. Lahman
- Re: Help on choosing a valid pattern: composite or not?
- From: Dmitry A. Kazakov
- 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: Model-View-Presenter (MVP) question
- 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
|