how to extend a class (add methods) and have the source of the methods be in a category other than the one the class is defined in?

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

how to extend a class (add methods) and have the source of the methods be in a category other than the one the class is defined in?

Louis LaBrunda
Hi All,

How does one extend a class (add methods) and have the source of the methods be in a category
other than the one the class is originally defined in?  I expect this is simple and I'm just
missing something easy.

Lou
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|

Re: how to extend a class (add methods) and have the source of the methods be in a category other than the one the class is defined in?

Bob Arning-2

Class categories (the first pane on the left at the top of a system browser) are completely different from method categories (third pane from the left). Assuming you are talking about method categories, you can:

- select the desired method category before you enter and save the method

- if it's already in the wrong category...

-- drag the method name from the fourth pane into the third pane at the desired category

-- copy the method source, select the desired category, paste the method source back in and save

-- choose "reorganize" from the third pane menu


On 1/13/17 11:55 AM, Louis LaBrunda wrote:
Hi All,

How does one extend a class (add methods) and have the source of the methods be in a category
other than the one the class is originally defined in?  I expect this is simple and I'm just
missing something easy.

Lou



Reply | Threaded
Open this post in threaded view
|

how to extend a class (add methods) and have the source of the methods be in a category other than the one the class is defined in?

Louis LaBrunda
Hi Bob,

Thanks for the prompt reply.  I'm still a little confused.  Allow me to describe what we do in
VA Smalltalk and see if we can get the same results in Squeak.

VA Smalltalk has a class called Application.  Applications are similar (I think) to Class
categories (the first pane on the left).  Classes can appear in more than one Application. Each
Application a class appears in holds some methods.  A class starts out being defined in one
application.  It is "extended" by adding methods to other applications.  If one of those
applications is not loaded, then the extended methods are not available.

I have created a Class category to hold my program.  As part of the program I want to add a few
methods to say the String class.  But I'm afraid I will add them to the class category where
String is defined.

Does this make sense and how do I do it in Squeak?


Lou

On Fri, 13 Jan 2017 12:18:37 -0500, Bob Arning <[hidden email]> wrote:

>Class categories (the first pane on the left at the top of a system
>browser) are completely different from method categories (third pane
>from the left). Assuming you are talking about method categories, you can:
>
>- select the desired method category before you enter and save the method
>
>- if it's already in the wrong category...
>
>-- drag the method name from the fourth pane into the third pane at the
>desired category
>
>-- copy the method source, select the desired category, paste the method
>source back in and save
>
>-- choose "reorganize" from the third pane menu
>
>
>On 1/13/17 11:55 AM, Louis LaBrunda wrote:
>> Hi All,
>>
>> How does one extend a class (add methods) and have the source of the methods be in a category
>> other than the one the class is originally defined in?  I expect this is simple and I'm just
>> missing something easy.
>>
>> Lou
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon


Reply | Threaded
Open this post in threaded view
|

Re: how to extend a class (add methods) and have the source of the methods be in a category other than the one the class is defined in?

Nicolas Cellier
Hi Louis,
if the purpose is packaging code for loading/unloading/versioning, then the usage is to create a package via Monticello, say

'LouisApp'

Then any class classified into a category 'LouisApp', 'LouisApp-Base' or 'LouisApp-Whatever' would belong to the 'LouisApp' package.
And any method classified into a category '*LouisApp', '*LouisApp-accessing' or '*LouisApp-WhatYouPrefer' would also belong to the 'LouisApp' package. That's how we would package some extension to another class not in our package.

That's a very low cost but effective convention.

2017-01-13 18:38 GMT+01:00 Louis LaBrunda <[hidden email]>:
Hi Bob,

Thanks for the prompt reply.  I'm still a little confused.  Allow me to describe what we do in
VA Smalltalk and see if we can get the same results in Squeak.

VA Smalltalk has a class called Application.  Applications are similar (I think) to Class
categories (the first pane on the left).  Classes can appear in more than one Application. Each
Application a class appears in holds some methods.  A class starts out being defined in one
application.  It is "extended" by adding methods to other applications.  If one of those
applications is not loaded, then the extended methods are not available.

I have created a Class category to hold my program.  As part of the program I want to add a few
methods to say the String class.  But I'm afraid I will add them to the class category where
String is defined.

Does this make sense and how do I do it in Squeak?


Lou

On Fri, 13 Jan 2017 12:18:37 -0500, Bob Arning <[hidden email]> wrote:

>Class categories (the first pane on the left at the top of a system
>browser) are completely different from method categories (third pane
>from the left). Assuming you are talking about method categories, you can:
>
>- select the desired method category before you enter and save the method
>
>- if it's already in the wrong category...
>
>-- drag the method name from the fourth pane into the third pane at the
>desired category
>
>-- copy the method source, select the desired category, paste the method
>source back in and save
>
>-- choose "reorganize" from the third pane menu
>
>
>On 1/13/17 11:55 AM, Louis LaBrunda wrote:
>> Hi All,
>>
>> How does one extend a class (add methods) and have the source of the methods be in a category
>> other than the one the class is originally defined in?  I expect this is simple and I'm just
>> missing something easy.
>>
>> Lou
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon





Reply | Threaded
Open this post in threaded view
|

how to extend a class (add methods) and have the source of the methods be in a category other than the one the class is defined in?

Louis LaBrunda
Hi Nicolas,

Thanks for the prompt reply.  I think I get it, so we will see how it goes.

Lou


On Fri, 13 Jan 2017 18:53:23 +0100, Nicolas Cellier <[hidden email]> wrote:

>Hi Louis,
>if the purpose is packaging code for loading/unloading/versioning, then the
>usage is to create a package via Monticello, say
>
>'LouisApp'
>
>Then any class classified into a category 'LouisApp', 'LouisApp-Base' or
>'LouisApp-Whatever' would belong to the 'LouisApp' package.
>And any method classified into a category '*LouisApp',
>'*LouisApp-accessing' or '*LouisApp-WhatYouPrefer' would also belong to the
>'LouisApp' package. That's how we would package some extension to another
>class not in our package.
>
>That's a very low cost but effective convention.
>
>2017-01-13 18:38 GMT+01:00 Louis LaBrunda <[hidden email]>:
>
>> Hi Bob,
>>
>> Thanks for the prompt reply.  I'm still a little confused.  Allow me to
>> describe what we do in
>> VA Smalltalk and see if we can get the same results in Squeak.
>>
>> VA Smalltalk has a class called Application.  Applications are similar (I
>> think) to Class
>> categories (the first pane on the left).  Classes can appear in more than
>> one Application. Each
>> Application a class appears in holds some methods.  A class starts out
>> being defined in one
>> application.  It is "extended" by adding methods to other applications.
>> If one of those
>> applications is not loaded, then the extended methods are not available.
>>
>> I have created a Class category to hold my program.  As part of the
>> program I want to add a few
>> methods to say the String class.  But I'm afraid I will add them to the
>> class category where
>> String is defined.
>>
>> Does this make sense and how do I do it in Squeak?
>>
>>
>> Lou
>>
>> On Fri, 13 Jan 2017 12:18:37 -0500, Bob Arning <[hidden email]>
>> wrote:
>>
>> >Class categories (the first pane on the left at the top of a system
>> >browser) are completely different from method categories (third pane
>> >from the left). Assuming you are talking about method categories, you can:
>> >
>> >- select the desired method category before you enter and save the method
>> >
>> >- if it's already in the wrong category...
>> >
>> >-- drag the method name from the fourth pane into the third pane at the
>> >desired category
>> >
>> >-- copy the method source, select the desired category, paste the method
>> >source back in and save
>> >
>> >-- choose "reorganize" from the third pane menu
>> >
>> >
>> >On 1/13/17 11:55 AM, Louis LaBrunda wrote:
>> >> Hi All,
>> >>
>> >> How does one extend a class (add methods) and have the source of the
>> methods be in a category
>> >> other than the one the class is originally defined in?  I expect this
>> is simple and I'm just
>> >> missing something easy.
>> >>
>> >> Lou
>> --
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>>
>>
>>
--
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon