Stuck -- newbie question : How to add new instance method?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Stuck -- newbie question : How to add new instance method?

Rick Flower
Ok.. I'm toying around with VW and am working on some rudimentary objects
to get my feet wet with Smalltalk and ran into a problem that I can't
figure out..  I managed to create a class just fine in my own test package.
I then managed to setup my "accessing" protocol (protocol seems like a strange
term for this, but I guess if categories is already used, perhaps it's OK)
for all of my classes instance variables.  I then found a nice menu option
that created all of my accessors for me -- Cool!

Now, I want to add another accessor to the list in the far right pane of
the browser but can't seem to find/figure out how to go about it.. I don't
see any menu options under the "Methods" menu for "add" or similar..

I've got a class instance variable that's supposed to be a sort of boolean
if you will (yeah, I know Smalltalk doesn't do types, but I do embedded C++
for my day job and it's stuck in my head!) and want a method called
"MakeAcctLocked" and another called "MakeAcctUnlocked" that will flip-flop
the same instance variable and aid in readability.  Anyway, I'm sure I'm
just missing something on how to do the adding of a new method -- can
someone please point me in the right direction?

Thanks much in advance!

-- Rick

Reply | Threaded
Open this post in threaded view
|

Re: Stuck -- newbie question : How to add new instance method?

Charles Adams
Rick,

You might be stumbling over the mechanics of the editor/browser. No problem.
Been there.

To add a new method, simply start typing.

If you have another method already selected, then highlight the entire
context in the big editing pane and start typing.

If you have no method selected, again, highlight the text that appears in
the big editing pand and start typing.

When you accept your text, it will create a new method entry in the upper,
right pane. Its magic.

Hope that was what you wanted...

Charlie

----- Original Message -----
From: "Rick F." <[hidden email]>
To: <[hidden email]>
Sent: Wednesday, January 25, 2006 2:40 PM
Subject: Stuck -- newbie question : How to add new instance method?


> Ok.. I'm toying around with VW and am working on some rudimentary objects
> to get my feet wet with Smalltalk and ran into a problem that I can't
> figure out..  I managed to create a class just fine in my own test
> package.
> I then managed to setup my "accessing" protocol (protocol seems like a
> strange
> term for this, but I guess if categories is already used, perhaps it's OK)
> for all of my classes instance variables.  I then found a nice menu option
> that created all of my accessors for me -- Cool!
>
> Now, I want to add another accessor to the list in the far right pane of
> the browser but can't seem to find/figure out how to go about it.. I don't
> see any menu options under the "Methods" menu for "add" or similar..
>
> I've got a class instance variable that's supposed to be a sort of boolean
> if you will (yeah, I know Smalltalk doesn't do types, but I do embedded
> C++
> for my day job and it's stuck in my head!) and want a method called
> "MakeAcctLocked" and another called "MakeAcctUnlocked" that will flip-flop
> the same instance variable and aid in readability.  Anyway, I'm sure I'm
> just missing something on how to do the adding of a new method -- can
> someone please point me in the right direction?
>
> Thanks much in advance!
>
> -- Rick
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Stuck -- newbie question : How to add new instance method?

Christopher Petrilli
In reply to this post by Rick Flower
On 1/25/06, Rick F. <[hidden email]> wrote:
> I've got a class instance variable that's supposed to be a sort of boolean
> if you will (yeah, I know Smalltalk doesn't do types, but I do embedded C++
> for my day job and it's stuck in my head!) and want a method called
> "MakeAcctLocked" and another called "MakeAcctUnlocked" that will flip-flop
> the same instance variable and aid in readability.  Anyway, I'm sure I'm
> just missing something on how to do the adding of a new method -- can
> someone please point me in the right direction?

Rick,

While I think maybe a menu option to do that would be cool... a couple things:

1) You can do it by selecting the protocol, and then just replacing
the text and saving it in the bottom pane of the browser.  It's really
that simple. For example:

lock
    self immutable: true.

and then:

unlock
    self immutable: false.

2) Traditionally we use (we = Smalltalkers) shorter names and initial
lower-case.  Also, they tend to be verbish, if that makes sense.

Chris
--
| Christopher Petrilli
| [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Stuck -- newbie question : How to add new instance method?

Dave Stevenson-2
In reply to this post by Rick Flower
-covering message-

+-----------------------------
| Date: Wed, 25 Jan 2006 12:40:58 -0800
| From: "Rick F." <[hidden email]>
| Subject: Stuck -- newbie question : How to add new instance method?

| Ok.. I'm toying around with VW and am working on some rudimentary objects
| to get my feet wet with Smalltalk and ran into a problem that I can't
| figure out..  I managed to create a class just fine in my own test package.
| I then managed to setup my "accessing" protocol (protocol seems like a strange
| term for this, but I guess if categories is already used, perhaps it's OK)
| for all of my classes instance variables.  I then found a nice menu option
| that created all of my accessors for me -- Cool!

| Now, I want to add another accessor to the list in the far right pane of
| the browser but can't seem to find/figure out how to go about it.. I don't
| see any menu options under the "Methods" menu for "add" or similar..

| I've got a class instance variable that's supposed to be a sort of boolean
| if you will (yeah, I know Smalltalk doesn't do types, but I do embedded C++
| for my day job and it's stuck in my head!) and want a method called
| "MakeAcctLocked" and another called "MakeAcctUnlocked" that will flip-flop
| the same instance variable and aid in readability.  Anyway, I'm sure I'm
| just missing something on how to do the adding of a new method -- can
| someone please point me in the right direction?

| Thanks much in advance!

| -- Rick

Select your accessing protocol.  Type the following in the code view and then accept (ctrl-s):

lockAccount
        locked := true



Reply | Threaded
Open this post in threaded view
|

Re: Stuck -- newbie question : How to add new instance method?

Rick Flower
In reply to this post by Christopher Petrilli
* Christopher Petrilli <[hidden email]> [2006-01-25 15:53:57 -0500]:

> 1) You can do it by selecting the protocol, and then just replacing
> the text and saving it in the bottom pane of the browser.  It's really
> that simple. For example:
>
> lock
>     self immutable: true.
>
> and then:
>
> unlock
>     self immutable: false.

Doh!  I didn't even think about that.. Consider me flogged!  I just tried
it and it worked like a charm!  I guess I'll have to go read up on what
the above immutable does (no need to explain here, I'll go poke around
in the online books)

> 2) Traditionally we use (we = Smalltalkers) shorter names and initial
> lower-case.  Also, they tend to be verbish, if that makes sense.

Cool.. I'm still trying to wrap my head around the dramatic changes
this language has from what I'm used to doing!  Thanks to all of you
that replied in record time!

-- Rick