Login  Register

Re: Unintuitive behavior of class-side initialize

Posted by kilon.alios on Aug 27, 2014; 6:00pm
URL: https://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775114.html

I assume you mean there will be an inheritance issue if I want the variables to be inherited with a default value by the subclasses, which is a valid concern. Other than that you can have accessors for it as far I know . But yeah in that case of inheritance you need some kind of initialise method. 

I have not played with class instance variables so no clue about that part.


On Wed, Aug 27, 2014 at 8:38 PM, webwarrior <[hidden email]> wrote:
I've also chosen ifNil route.
However, in that case you either:
- break encapsulation by providing accessors
- have to invoke initializing method in every method that uses class
instance variables or class variables

27.08.2014 20:31, kilon.alios [via Smalltalk] написав(ла):

> yeah python does not need initialisation for class variables like it
> does for instance variables, but then same applies for instance
> variables, for example you can add instance variables and even instance
> method after the instance is created , pharo does something similar too.
>
> Well OOP is a deep subject and this is an advanced topic that I would
> not want to put in an introductionary chapter.
>
> I had issues with initialise on class side recently where i was told i
> had to initialise the class myself instead I chose to go down the ifNil
> route and initialise my class variables inside other methods.  This way
> I avoided the creation of an initialise method, and probably i will
> avoid using it in the future too. From what I see most classes
> (metaclasses) dont use an initialise method either.
>
>
> On Wed, Aug 27, 2014 at 7:33 PM, webwarrior <[hidden email]

> </user/SendEmail.jtp?type=node&node=4775110&i=0>> wrote:
>
>     class-side initialize.
>
>     I don't think it can be considered a metaprogramming in Smalltalk.
>
>     In Python, yes, messing with metaclass is metaprogramming. But things
>     are a bit different there and metaclasses are very rarely used
>     [explicitly].
>
>     27.08.2014 19:05, kilon.alios [via Smalltalk] написав(ла):
>
>      > ok officially I am confused are we talking about initialise at the
>      > instance side or class side  (metaclass) side ?
>      >
>      > I am  a python coder myself but I have not done any
>     metaprogramming .
>      >
>      > If it is a metaprogramming thing then yes it wont go inside my intro
>      > chapter since this is advanced topic and metaprogramming is already
>      > covered by PBE on a separate chapter so that can be added there.
>     Since I
>      > am not experienced with metaprogramming it would be better if people
>      > experienced with Pharo and metaprogramming would write the
>     documentation .
>
>     ------------------------------------------------------------------------
>     View this message in context: Re: Unintuitive behavior of class-side
>     initialize
>     <http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775103.html>
>     Sent from the Pharo Smalltalk Users mailing list archive
>     <http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html> at
>     Nabble.com.
>
>
>
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/Unintuitive-behavior-of-class-side-initialize-tp4775042p4775110.html



View this message in context: Re: Unintuitive behavior of class-side initialize
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.