tags:

views:

106

answers:

2

Hi all, I have a design Problem. i have a Drawer class wich invokes a serie of methods of a kind-of-brush class and i have a predefined shapes which i want to draw. Each shape uses a list of instance methods from the drawer. I can have more than 1 brush object.
I want to add custom shapes on runtime in the drawer instance, especifying the list of methods of the new shape.
i've created a class method for every predefined shape that returns a BlockClosure with the instruccions. Obviously i have to give to each BlockClosure the brush object as parameter. I imagine a collection with all the BlockClosures in each instance of the Drawer Class. Maybe i can inherit a SequenceableCollection and make a instruccion collection. Each element of the collection it's a instruction and i give the brush object when i instance this new collection. I really don't know the best way to store these steps.
(Maybe a shared variable?)

+1  A: 

Maybe you can use anActionSequence with some MessageSend instances and put them in aDictionary in your Drawer (I'd prefer "Painter" as a Classname for that CLass, since "Drawer" sounds much like the furniture part in my ears :)

I'm not realy sure what you want to achieve exactly.

Richard Durr
i was wondering if i can use a BlockClosure insted of ActionSequence. But it has to be a BlockClosure without parameteres. I saw that i can do aMethod: aParameter ^[ aParameter doSomething ]. but i don't like it so much. I use a class method for every predefined shape that return an Object that i can exceute with the message value. i've to decided if i returns a Closure or ActionSequence jeje. Yes the name it's gonna be Painter – –
Luciano Lorenti
But to your Programm, there seems to be no difference between aBlock or anActionSequence… Maybe you can post some source code ^^
Richard Durr
A: 

Bongiorno, Luciano! La domanda di Lei non è troppo chiara. Eh... I'd rather use English, my Italian is somewhat poor.

Your question is not very clear. It could help if I knew more of the context of your problem. What kind of software are you developing? Why do you need many instances of the 'Drawer' (or Painter) class?

Based on what I was able to guess now, I'd suppose you need some variant of Interpreter pattern. The "Gang of Four" book (Design Patterns: Elements of Reusable Object-Oriented Software) is a must-read for each and every programmer. For Smalltalkers I highly recommend "The Design Patterns Smalltalk Companion" by Sherman Alpert, Kyle Brown and Bobby Woolf as an everyday reference.

Sorry, this is all advice I can give regarding your problem as it is currently formulated.

Yuri Baranov