Best Practice To Programmatically add an instance variable to an existing class?

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

Best Practice To Programmatically add an instance variable to an existing class?

GLASS mailing list
HI,

What is the best practice for dynamically adding an instance variable to an existing class?

There are two classes in Behaviour -
        #addInstVarName:
        #addInstVar:

Thanks,

Reg
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Best Practice To Programmatically add an instance variable to an existing class?

GLASS mailing list
On 08/16/2017 06:34 PM, Reg Krock via Glass wrote:
> HI,
>
> What is the best practice for dynamically adding an instance variable to an existing class?
>
> There are two classes in Behaviour -
> #addInstVarName:
> #addInstVar:
>

Generally, classes in GemStone are immutable, so you have to create a
new class version in order to add an instance variable. You can do that
with messages in the class creation protocol.

If the class has instances, it's definitely immutable, and you'll most
likely want to migrate the instances to the new class version. The
Programming Guide has information about that.

Regards,
-Martin
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Best Practice To Programmatically add an instance variable to an existing class?

GLASS mailing list
In reply to this post by GLASS mailing list
Reg,

If you are using tODE, then you can edit the class definition and then
save it ... the new class will be created and all instances of the old
class will be migrated to the new class ...

Dale

On 08/16/2017 06:34 PM, Reg Krock wrote:

> HI,
>
> What is the best practice for dynamically adding an instance variable to an existing class?
>
> There are two classes in Behaviour -
> #addInstVarName:
> #addInstVar:
>
> Thanks,
>
> Reg

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Best Practice To Programmatically add an instance variable to an existing class?

GLASS mailing list
... dynamically? .... there are ways to use other facilities within
tODE/GsDevKit to simplify the process a bit (sing McClassDefinition and
GsDeployer), but if you want to do it using the base GemStone
facilities, then what Martin said ...


On 08/17/2017 02:58 PM, Dale Henrichs wrote:

> Reg,
>
> If you are using tODE, then you can edit the class definition and then
> save it ... the new class will be created and all instances of the old
> class will be migrated to the new class ...
>
> Dale
>
> On 08/16/2017 06:34 PM, Reg Krock wrote:
>> HI,
>>
>> What is the best practice for dynamically adding an instance variable
>> to an existing class?
>>
>> There are two classes in Behaviour -
>>     #addInstVarName:
>>     #addInstVar:
>>
>> Thanks,
>>
>> Reg
>

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Best Practice To Programmatically add an instance variable to an existing class?

GLASS mailing list
if you want to completely avoid migration issues, then take a look at
dynamic instance variables;

   dynamicInstanceVariables

   dynamicInstVarAt:

   dynamicInstVarAt:put:

Dale

On 08/17/2017 03:27 PM, Dale Henrichs wrote:

> ... dynamically? .... there are ways to use other facilities within
> tODE/GsDevKit to simplify the process a bit (sing McClassDefinition
> and GsDeployer), but if you want to do it using the base GemStone
> facilities, then what Martin said ...
>
>
> On 08/17/2017 02:58 PM, Dale Henrichs wrote:
>> Reg,
>>
>> If you are using tODE, then you can edit the class definition and
>> then save it ... the new class will be created and all instances of
>> the old class will be migrated to the new class ...
>>
>> Dale
>>
>> On 08/16/2017 06:34 PM, Reg Krock wrote:
>>> HI,
>>>
>>> What is the best practice for dynamically adding an instance
>>> variable to an existing class?
>>>
>>> There are two classes in Behaviour -
>>>     #addInstVarName:
>>>     #addInstVar:
>>>
>>> Thanks,
>>>
>>> Reg
>>
>

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: Best Practice To Programmatically add an instance variable to an existing class?

GLASS mailing list
In reply to this post by GLASS mailing list
Reg,

I think you should look at an old thread from this list "Class renamed
and migrations practices"[1] and in particular you will want to look at
the post from Otto Behrens[2] where he shares the code that he uses for
managing migrations.

Dale

[1]
http://forum.world.st/Class-renames-and-migrations-practices-td4892354.html

[2]
http://forum.world.st/Class-renames-and-migrations-practices-tp4892354p4892390.html


On 8/17/17 3:27 PM, Dale Henrichs wrote:

> ... dynamically? .... there are ways to use other facilities within
> tODE/GsDevKit to simplify the process a bit (sing McClassDefinition
> and GsDeployer), but if you want to do it using the base GemStone
> facilities, then what Martin said ...
>
>
> On 08/17/2017 02:58 PM, Dale Henrichs wrote:
>> Reg,
>>
>> If you are using tODE, then you can edit the class definition and
>> then save it ... the new class will be created and all instances of
>> the old class will be migrated to the new class ...
>>
>> Dale
>>
>> On 08/16/2017 06:34 PM, Reg Krock wrote:
>>> HI,
>>>
>>> What is the best practice for dynamically adding an instance
>>> variable to an existing class?
>>>
>>> There are two classes in Behaviour -
>>>     #addInstVarName:
>>>     #addInstVar:
>>>
>>> Thanks,
>>>
>>> Reg
>>
>

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass