▪Ownership is ambiguous
▪It implies the argument can be null
Prefer a reference if the function is only observing the argument
Use a unique_ptr or auto_ptr if you pass ownership to the function
Use a shared_ptr if you want (really want) to share ownership with the function
Use a weak_ptr if the function wants to keep the reference and observe it
Returning pointers from functions
Don’t!
▪Ownership is ambiguous
▪It implies the return can be null
▪Encourages the caller to keep the pointer (almost always)
Prefer a const reference
Use a unique_ptr or auto_ptr if you pass ownership to the caller
Use a shared_ptr if you want (really want) to share ownership with the caller
Use a weak_ptr if the caller wants to keep the reference and observe it
Functional programming (Haskell)
Pure functions
Declare if you have side effects
▪ A member function is const except otherwise needed
Don’t return const types by value – RVO & rvalues.
const std::string GetName() const;
But do return const refs
Includes
Const correctness
Pass by reference
Projects – premake
Function Names
▪see FindOrderedSubstringsInWord
Singleton
Statics in headers
Unit tests
Warnings
Defines for configuring things (static libs!!)
Memory allocation habbits