If I understand you correctly, you're asking about avoiding Premature Pessimization, a good complement to avoiding Premature Optimization. The #1 thing to avoid, based on my experience, is to not copy large objects whenever possible. This includes:
- pass objects by (const) reference to functions
- return objects by (const) reference whenever practical
- make sure you declare a reference variable when you need it
This last bullet requires some explanation. I can't tell you how many times I've seen this:
class Foo
{
const BigObject & bar();
};
// ... somewhere in code ...
BigObject obj = foo.bar(); // OOPS! This creates a copy!
The right way is:
const BigOject &obj = foo.bar(); // does not create a copy
These guidelines apply to anything larger than a smart pointer or a built-in type. Also, I highly recommend investing time learning to profile your code. A good profiling tool will help catch wasteful operations.