Generically across programming languages...
- a private method can only me invoked by an object of the same class (or
subclass) i.e. it can only be invoked by itself.
- a public method can be invoked from any object.

In Pharo, variables are private and methods are public.

The advantage of private methods is to avoid users calling utility methods
that only do half the work to leave data in a consistent state.
Also its clear which methods are outside you public API so you are free you
change those without impacting users.

Rather than such a forced constrint, Pharo deals with private methods by
convention:
- prepending "private" or "basic" to the front of the method name
- placing methods into a protocol (or method category) named "private".
- having a protocol "api" for the public api and everything else to be
considered private
Note that "protocols" have no impact on program execution - they are just
an organisational tool.

All reflects Pharo philosophy...
Reduced forced constraints making it quicker and easier to program "in the
flow"
i.e. you "can" break convention and call "private" methods if that is
pragmatic and you are willing
to accept the risk that you don't properly comprehend the behavior or the
behaviour changes later without warning.

cheers -ben







On Thu, 15 Nov 2018 at 12:44, iu136 via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> 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
>
>

Reply via email to