i am working on a program with a framework, and modules that will plug into it, and i need to know how to send a class name around. for example: i have a method in one class, that servers as a module, that will "Procces Commands" sent to the framework. I have another class that is suposed to manage the commands and getting them to the right place.
ManCommands-the command managing class Framework-the framework that manages input/output BasicModule1-a module that will eventually be used to run other "modules" how do i get the framework to tell ManCommands to send the command sent to the framework to the ProccessCommand method it BasicModule1> |
Hi David.
I’m not sure I understand your
question. However, if your commands are Smalltalk selectors (method names),
then you can send the message perform: using the command you want to execute as
the argument. For instance,
/Leandro
From:
[hidden email]
[mailto:[hidden email]] On Behalf Of David Zmick
i am working on a program with a framework, and modules that will plug into it, and i need to know how to send a class name around. for example: i have a method in one class, that servers as a module, that will "Procces Commands" sent to the framework. I have another class that is suposed to manage the commands and getting them to the right place. ManCommands-the command managing class Framework-the framework that manages input/output BasicModule1-a module that will eventually be used to run other "modules" how do i get the framework to tell ManCommands to send the command sent to the framework to the ProccessCommand method it BasicModule1> |
they aren't smalltalk related. I'm trying to develop a framework to develop cryptology programs on, and the framework needs to have and input and an output. I can't figure out how to pass a class name to different selectors. i need the framework to be able to load different modules, so i need to have some sort of variable called activeModule that will store the class name to pass things to. I need to be able to say something like
activeModule ManCommand: command.
thanks,
dzmick
On 1/2/08, Leandro Caniglia <[hidden email]> wrote:
|
each module will have a method called ManCommand: aString to tell the framework how to manage commands when that module is loaded
On 1/2/08, David Zmick <[hidden email]> wrote:
|
In reply to this post by David Zmick
On Jan 2, 2008 1:39 PM, David Zmick <[hidden email]> wrote:
> i am working on a program with a framework, and modules that will plug into > it, and i need to know how to send a class name around. for example: i have > a method in one class, that servers as a module, that will "Procces > Commands" sent to the framework. I have another class that is suposed to > manage the commands and getting them to the right place. > > ManCommands-the command managing class > > Framework-the framework that manages input/output > > BasicModule1-a module that will eventually be used to run other "modules" > > how do i get the framework to tell ManCommands to send the command sent to > the framework to the ProccessCommand method it BasicModule1> I've taught Smalltalk to a lot of people. Based on that experience, I think you are heading in the wrong direction. You probably shouldn't be talking about modules, but about classes. You shouldn't think about a module that runs other modules. Further, classes are objects, so you usually don't pass names of classes around, but the classes themselves. Is this your first Smalltalk system? -Ralph Johnson |
yes, it is my first, but i understand all of the classes, etc. I want to make an expandable cryptology system that will have other classes with certain methods to control the framework, or base class, its just fancy words
On 1/2/08, Ralph Johnson <[hidden email]> wrote:
On Jan 2, 2008 1:39 PM, David Zmick <[hidden email]> wrote: |
OK. Then just show us some of your source code so we can figure out what you are trying to do.
/Leandro
From: [hidden email]
[mailto:[hidden email]] On Behalf Of David Zmick
yes, it is my first, but i understand all of the classes, etc. I want to make an expandable cryptology system that will have other classes with certain methods to control the framework, or base class, its just fancy words On 1/2/08, Ralph Johnson <[hidden email]> wrote: On Jan 2, 2008 1:39 PM,
David Zmick <[hidden email]>
wrote:
|
ok,
this is the Framework class:
Framework>>getInput
^input
Framewor>>prompt: aString
"Not yet finished, will be sent to a UI eventually"
On 1/3/08, Leandro Caniglia <[hidden email]> wrote:
|
On 1/3/08, David Zmick <[hidden email]> wrote:
Object subclass: #Framework
instanceVariableNames: 'input activeModule' classVariableNames: '' poolDictionaries: '' category: 'dz-CrypticSqueak'
Framework input: aString
input := aString.
A Basic "module"
BasicModule>>ManCommand:
"Tells the framework what to do when it gets a method"
BasicModule>>initialize
framework := Framework new.
The class that manages where the commands go, all of the commands, in a way it is part of the framework.
ManCommands>>sendCommand: aCommandString
mod = BasicModule new. "THIS IS NOT WHAT I WANT!! BAD!!!"
mod ManCommand: aCommandString.
then there are always some accessors thats just basically how it works.
One more question...How do I know when i need to use a class method instead of an instance method?
|
sorry i sent it like that, i messed up.
On 1/3/08, David Zmick <[hidden email]> wrote:
|
In reply to this post by David Zmick
Hello David,
DZ> One more question...How do I know when i need to use a class DZ> method instead of an instance method? the obvious reply is: If you want to talk to the class you need a message implemented as a class side method. Examples: a := Float pi asks the class Float to return an instance of Float with the value of pi. So you'll find the method pi implemented on the class side of float. then a:= a + 3.0 talks to an instance of Float so you'll find + implemented on the instance side of Float (or on of its superclasses). Cheers, Herbert mailto:[hidden email] |
ok, Thanks! that clears it up a lot!!
happy coding!
On 1/3/08, Herbert König <[hidden email]> wrote:
Hello David, |
In reply to this post by David Zmick
In general, before you try to build a framework for something, you
should build some applications for that problem. The right way to build a framework is to generalize from applications. See http://st-www.cs.uiuc.edu/~droberts/evolve.html So, what are your applications? -Ralph Johnson |
i dont have any. i wasnted to build a base for everything and then develop stuff over it, but i see what you are saying, i shouldn't have to do that in an object-oriented language. especialy smalltalk
On 1/3/08, Ralph Johnson <[hidden email]> wrote:
In general, before you try to build a framework for something, you |
In reply to this post by David Zmick
Hi David
Since this is your first Smalltalk project, understanding the roles of messages, objects and classes from the POV of ST will help you. There are pretty good introductions to ST and/or OO concepts, like this one: http://www.chronos-st.org/Smalltalk-Getting-the-Message.html Cheers Carlos On Jan 3, 2008 1:22 PM, David Zmick <[hidden email]> wrote: > ok, Thanks! that clears it up a lot!! > happy coding! > > > > > On 1/3/08, Herbert König <[hidden email]> wrote: > > Hello David, > > > > DZ> One more question...How do I know when i need to use a class > > DZ> method instead of an instance method? > > > > the obvious reply is: If you want to talk to the class you need a > > message implemented as a class side method. Examples: > > > > a := Float pi > > asks the class Float to return an instance of Float with the value of > > pi. So you'll find the method pi implemented on the class side of > > float. > > > > then a:= a + 3.0 talks to an instance of Float so you'll find + > > implemented on the instance side of Float (or on of its superclasses). > > > > > > Cheers, > > Herbert mailto:[hidden email] > > > > > > > > > > > |
In reply to this post by Ralph Johnson
>>>>> "Ralph" == Ralph Johnson <[hidden email]> writes:
Ralph> In general, before you try to build a framework for something, you Ralph> should build some applications for that problem. The right way to Ralph> build a framework is to generalize from applications. Ralph> See http://st-www.cs.uiuc.edu/~droberts/evolve.html heh... I was about to type "and I've never been able to develop a framework without implementing things at least *three* times" when I started reading that URL. Very nice. You have to implement something *three* times before you start a framework because otherwise you won't know what dials and levers are connected, and what dials and levers are independent. With three data points, you can at least start to make a guess. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[hidden email]> <URL:http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! |
In reply to this post by Carlos Lenz-2
i have the book "Squeak by Example" and i'm reading about that right now!
On 1/3/08, Carlos Lenz <[hidden email]> wrote:
Hi David |
Free forum by Nabble | Edit this page |