Re: [Pharo-users] Question about pharo's object model
Hello and welcome :-) When a method is « public » , it means that it is usable by any other object in the system. In Pharo, methods are « public » and instance variables are « protected ». « protected » means that the instance variable is only usable from inside the class defining it or from subclasses of the class defining it. Some languages (as Java) define the concepts of « private » method / instance variable which means that the method / instance variable can only be accessed from the class defining it (and not its subclasses) and « package » which means that the method / instance variable can only be accessed from classes inside the same package. In fact, in java you can choose the visibility you want for each method / instance variable. In Pharo, this is fixed, methods are « public » and instance variables are « protected ». So you do not need to bother. All these concepts are related to encapsulation [1] which is an important concept of OOP. BTW, there are some posts related to your question on StackOverflow [2] which I recommend to you. Cheers, Julien Links: [1]: https://en.wikipedia.org/wiki/Object-oriented_programming#Encapsulation <https://en.wikipedia.org/wiki/Object-oriented_programming#Encapsulation> [2]: https://stackoverflow.com/questions/2647289/what-does-it-mean-for-a-method-t... <https://stackoverflow.com/questions/2647289/what-does-it-mean-for-a-method-t...> --- Julien Delplanque Doctorant à lâUniversité de Lille http://juliendelplanque.be/phd.html Equipe Rmod, Inria Bâtiment B 40, Avenue Halley 59650 Villeneuve d'Ascq Numéro de téléphone: +333 59 35 86 40
Le 15 nov. 2018 à 05:43, iu136 via Pharo-users <pharo-users@lists.pharo.org> a écrit :
De: iu136 <iu136@yahoo.com> Objet: Question about pharo's object model Date: 15 novembre 2018 Ã 05:43:45 UTC+1 Ã: pharo-users@lists.pharo.org
hello guys I'm new to programming, I started programming using pharo, I had a question about pharo's object model. In object model we say, methods are public. What does "public" mean here? thanks
-- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
participants (1)
-
Julien