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

Word Capitalization

Previous pageReturn to chapter overviewNext page


Often, due to syntax constraints in a language (in this case Smalltalk), it is necessary to take a phrase and represent it as a single word with no embedded spaces. The resultant word should be easy on the eye and easy to scan, such that a reader can mentally parse it back to the original phrase.


Capitalise the first letter of each word in the phrase and remove the embedded spaces. Sometimes further massaging of the resultant word will be necessary, perhaps to lowercase the first letter as in the case of a Method Name or Instance Variable Name.


In class AttributeDescriptor the implied phrase, "Can generate read accessor?" is converted to a method name of canGenerateReadAccessor. Similarly the phrase "Method categorization policy" is word capitalized to form the class name, MethodCategorizationPolicy.


Other name mangling policies are possible, such as replacing spaces with underscore characters. This would have the advantage of maintaining the word capitalisation within the phrase but it is not accepted Smalltalk convention since early implementations of the language did not support underscores in variable names.

Related Patterns

Class Name, Method Name, Instance Variable Name