Refactoring #1693

Updated by wuttke over 3 years ago

For example, in ParticleLayout.h we currently have three constructors, and four versions of @addParticle@:
<pre>
class BA_CORE_API_ ParticleLayout : public ILayout
{
public:
ParticleLayout();
ParticleLayout(const IAbstractParticle& particle);
ParticleLayout(const IAbstractParticle& particle, double abundance);
...
void addParticle(const IAbstractParticle& particle);
void addParticle(const IAbstractParticle& particle, double abundance);
void addParticle(const IParticle& particle, double abundance, const kvector_t position);
void addParticle(const IParticle& particle, double abundance, const kvector_t position, const IRotation& rotation);
...
}
</pre>
By using default values in the longest initializer list, the shorter forms can be made redudant. This will save duplicate code, ensure consistency, and simplify the API.

Also consider: is there a need at all for @ParticleLayout(const IAbstractParticle& particle)@ if the same can be achieved in by @ParticleLayout()@ followed by @addParticle(const IAbstractParticle& particle)@ ? Only the latter form works if there is more than one layout, so why have special support for the special case of just one layout?

Back