ClassName_ClassName // (private) supporting implementation for a (public) classmethodName(...)_methodName(...) // (private) supporting implementation for a (public) methodStaticMethod(...)accept(...) // the accept method of a visitor's contextwhenCase(...) // a visitor's visit
methodoperator() or execute(...) // use to invoke a command as part of the command patterncreateSpecifier(...) // A method which factories an object the caller is responsable for deleteing. The specifier may be ommited and is used to quilify the kind of thing being created or the form of creation.destroy() // Request an object delete itself. Assume the object has been deleted after invocation.Instance() // a singleton's static accessor methodpropertyNameCONSTANT_PROPERTY // prefer const
over #definestaticPropertyinstance // the singleton's static variblemodule_name // multi-word module names should be avoidedτ // Tau: general type variableδ // Delta: as tau when typing data, esp. general collection typeρ // Rho: return typeα // Alpha: argument typeε // Epsilon: exception type// nested directories are used to reflect nested modules// to include an entire module// to include part of a module// for system level headers (e.g. garbage collection is gc
)// classes for doing unit tests go hereDo not use 'A' or 'I' as a prefix to an abstract class or interface
. Proper names can imply when something is abstract. Also, interface does not always have meaning in a language. When using a pattern consider using the pattern name in the class in addition to a meaningful root name. A class' role in a pattern may also make a useful name part.
Header files will always have .h extensions and be in a directory reflecting their nesting in modules. System headers are for things considered so important that you directly use their name. In this case a header is generated without a .h
and it includes the one with the .h
. If multiple system headers would have the same name (i.e. vector) then including the name includes all classes with that name. Since they are in different modules no conflicts occur and using directives should be used to select the desired implementation.
#ifndef headerFileName_h_
#define headerFileName_h_
// include directives
// header file contents
#endif // headerFileName_h_
// BUGBUG JTW message marks code you believe may have an error or need fixed in the future. Includes author's initials in multi-author environment::) and member selection (. or ->) operators should not have spaces on either side* and & should be associated with the variable name. If they are return types the modifiers should be associated with the type)' is when declaring a const method or to separate it from an inline body{ } not {})class ClassName: public SuperName
{
private:
static ClassName *instance;
public:
ClassName()
ClassName(int x): property(x) { }
virtual void method1(Type ¶m, Type2 param2) = 0;
virtual void method2(Type ¶m, Type2 param2);
};
ClassName::ClassName():
property(8),
foo(7)
{
}
void ClassName::method2(Type ¶m, Type2 param2)
{if()
{
}
}
argumentsto return
private, protected, publicprivate: should always be used (don't go with the implicit private that starts a class)friend declarations before any access modifiersfor(;;) to mean forever rather than while(true)destroy() is used to delete)Null())Type* Type::instance = 0;
Type& Type::Instance()
{
return *(instance ? instance : instance = new Type());
}
<type variable>specialization (e.g. τVisitor).
![]() |
jwalker@cs.oberlin.edu |