Hello Pattern Experts! :)
[short: content:
- description of the problem
- notes
- whats I have to use
- what I tried/thought about
- End (Question)]
I am a novice in Patterns and wnated to ask for statements, help, new
idears for my following Problem:
Actually I am making a Practical course at a facility at the Technical
University Graz, where I am developing a Client for a tool they use
internally.
At that client there should be a mapping from some Objects and too their
Properties to a graphical representation in form of a graph. So for
Instance it could be something like this:
Type A ----> Node with Shape of a Circle
A with Property a1 -> The border is fat
A with Property a2, Value -> the Color varies between Green and
Blue in 10 Steps according to the Value
A with Property a3 -> NodeColor = green
Type B ----> Node with Shape of a Triangle
B with Property b1 -> The border is fat
B with Property b2, value -> The color stroketype vaies according
to the value
Type C -----> Link in form of a Polyline
C with Property c1 -> End of Line is a small circle
C with Property c2 -> End of line is a circle and an arrow
.....
Some things are to note: The Properties are all optional, I get Nodes
and Links reported, however the Propertyies change for every Node/Link.
There might be that new Properties are added to the mapping after some
time...
The mapping pf the Properies might change too (okay, it will ;), since
it is a prototype and we first have to find the right mapping.... )
There should be a initial configuration which Property corespont to wich
kind of mapping, the form of the configuration is not important at that
point since it is a prototype, to this could be hardcodet in the
programm, however it should be flexible.
Since this Prototype is a Windows Applikation we are coding in .NET {not
my stuff normally ;) }, and for time-reasons the facility (the
Know-Center at graz [www.know-center.at]) wants to bye the Nevron
Diagram library (www.nevron.com), so the drawing of the diagramm works
with that, and also the altering of shapes.
I have wrapperclasses for all the drawing done, since it fits easier in
the model and we are shure we change the version of nevron as soon as
the new one comes out, since this one desn't fit our needs.
What is defenite:
I have an Interface with which I get the elements reportet for drawing.
There is a class which draws the nodes and makes the connection one by
one. Since the mapping is always specific to just one element i also
want to trigger the action at that drawing process.
I get the nodes reported in a very descriptive style, I get:
for Nodes:
the name of the node, used for labeling
an id, I use that to identify the node and make the connections
a dictionary with the properties. For those unfamiliar to .NET: a
dictionary is a container with key/value pairs.
The Keys are the types of the Properties (like a1,a2,b1 in the example
above) the values are optionally, but needed by some types.
What I thought about {and where i think it isn't good):
The maybe best idear at first:
IDEAR Nr. 1)
I am creating a function for every type of visual manipulation on the
graph. I am having a hashtable where I store the Property as a key and a
function pointer (a delegate in .NET i think) to the functions. There is
an other function which is configuring that hashtable with the delegates.
Everytime I get a Object do draw I look in the Hashtable for the
properties and call the registered functions.
Problems i see:
- There is no good way of extensibility according to the open-closed
principle, which I want to follow here I think.
- I have to follow a specific set of parameters for every function if I
don't want to have a big if then else if else part. If I get one the
registration at a hashtable seems nonsence to me.
- I think too that it is hard to have different behavior for different
reports which exist at the same time in the program (which might be
true, but maybe not that important if we get a tooo complex solution for
that problem {I am not shure if there is a simple one....})
IDEAR Nr.2
There are Objects for every type of visual manipulation of the graph. I
am having some kind of store (like a hashtable) where I register the
Objects to a property-key. So generally the same as above with objects:
Problems I see:
- The same with the decision code of fixed params as above
- There is the same problem with the different bahvior.
IDEAR Nr.3
Okay, now the things with too much patterns:
I thought of a chain of responibility, where I give the dictionary with
the properties to appy inside as an argument, and every property who
wants to have something to do with it makes it stuff. The Property class
itself ist having an visual-mapping-object which is created over an
abstract factory. There too exists a serier of visual mapping objects
which implement the according behavior. The configuration is done by
registering the right factories to the Properties Objects.
Problem I see:
- I tried do draw an UML diagram for that, and even here I got the
feeling that is too complikated.
IDEAR Nr.4
Hm, I thought of making the visual mapping objects in means of a
decorator pattern, who can be chained dogether. Everytime we have to
draw an node/link the request is going to some desicion code (maybe too
a chain of responibility), who just chains the decorators together so we
get a configured element, on whom then a mapp() method is called
Problem I see:
- Okay, this was really much tooo much complcated and for our app
defenitely an overkill.....
End (Question:)
Okay, none of the above solutions seemed satifacting to me, so I just
wanted to ask for satements of my solution idears, and maybe idears what
else I can do.
{okay, generally I am awaiting some magic pattern which is very easy to
understand, very efficient, very fast, very small, easy to implement and
so on ;) }
Thanks for any replies,
Jörg Simon
_______________________________________________
patterns-discussion mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/patterns-discussion