Navigation:  Appendix B: Dolphin Pattern Book > Class Patterns >

Class Name

Previous pageReturn to chapter overviewNext page

Context

When creating a New Class, a good class name will encourage others to re-use the class by illustrating its potential. In use, a well named class will also improve the readability of the code that makes use of it.

Solution

A class name must be a valid Global Name. It should reveal the purpose of the class to potential users. The name should not be too generic as to be meaningless, nor should it be too specific as to limit its reuse. The name does not need to describe implementation details of the class, as these should be private.

One point to bear in mind is that Dolphin Smalltalk does not currently support global namespaces (mainly because, at the time of writing, there is no consenus between the various Smalltalk vendors as to how this should be done). This means that the namespace for class names is limited and it is sometimes necessary to be careful how one names a particular class or group of classes in order to avoid clashes. In some situations it may be advantageous to add a prefix to your class names to avoid potential classes. This is particularly important when classes are being automatically generated by means of a tool such as the ActiveX Component Wizard.

Known Uses

The PackageManager class uses a lookup table for holding package information. The implementor has refrained from calling it PackageLookupTable because this is an implementation detail and could change in the future.

The Dolphin Binary Filing mechanism consists of about twenty classes, and all of the class names begin with the prefix STB. This reduces the risk of name collisions, and also logically groups the classes even though they are located in different parts of the class-hierarchy.

Related Patterns

Global Name, Method Name, Word Capitalization