Navigation: Appendix B: Dolphin Pattern Book > Method Patterns >
When creating a New Method it is apparent that some methods are intended to be used by clients of a class and therefore form part of the class's public protocol. Other methods, however, are for internal use only and are concerned with implementation details. Such private methods should only be called from methods in the same class or from methods in closely related classes where it is permissible for them to have knowledge of such intimate implementation details.
In Smalltalk, unlike C++, there is no way of genuinely hiding particular methods from access by a client. However, developer's of client classes need some way of differentiating between methods they should be able to use and those that they shouldn't.
In Smalltalk, we generally use an informal convention for marking a method as private. This is to begin the method comment with the string 'Private -' . In Dolphin we also use private and public method categories to convey this information.
Methods marked as private are not guaranteed to be compatible, or indeed present, in future releases of the class to which they belong. Hence they should not be used by clients of the class. It is, however, acceptable for private messages to be sent from within closely related families of classes.
"Private - Raise a NotFound exception."
The Color class contains a private method #defaultPalette.
"Private - Answer the default palette."
^GDILibrary default getStockObject: DefaultPalette