Re: [Pharo-users] Class side vs instance side (variables and methods)
Hello patrick Welcome
Subject: Class side vs instance side (variables and methods) Date: 29 July 2020 at 01:34:22 CEST To: Any Question About Pharo Is Welcome <pharo-users@lists.pharo.org>
Being new not only to Smalltalk, but OOP in general, I think I finally am understanding things.
Did you read my learning OOP book? It does not contain the answer but â¦
One area I am still unsure about is the class side versus the instance side. Does one usually use the class side when they want those inherited in every subclass, which frees one from having to declare them in every instance?
No Class side instances are - to share state among all instances (including subinstances) - state for classes. You have classVariables (should be renamed sharedVariables) and this is different from class instance variables (which are just instance variables of classes and since classes are kind of global you can use also to have act as shared variables). The difference being that there is only one classVar(sharedVariable) per hierarchy while you have one class instance variable per class. S.
participants (1)
-
Stéphane Ducasse