During my last project I noticed, that it is very convenient, to include design patterns names in class names. For example:
- ContextLazyFactory
- RunOnceMediator
- ThirdPartyMediator
- MyProjectCliFacade
- BinaryGate
It makes the project easy to read. Additional benefit is that you will not use your own names like ‘RunOnceManager’, ‘ContextDelayedConstruction’, ‘ThirdPartyInterface’, etc. which may have sharp meaning only for the author. On the other hand, I would not like to see classes like vector_container in the STL. How do you think?
My current view on this topic is: classes that are important nodes in class hierarchy should have their design pattern in their name, to emphasis the hierarchy structure and make the project much easier to read.
It seems natural to me in many cases:
When the simplest way of explaining a class’s purpose is in design pattern terms, why not use it?
On the other hand, when the design pattern is mostly incidental then exclude it. For example, a class may happen to be a singleton, but that’s not its main purpose in life, so I wouldn’t expect to see ‘Singleton’ in the name. Compare that with a factory whose main purpose is to be a factory for other objects – ‘FooFactory’ makes perfect sense.