tudo-astroparticlephysics / PROPOSAL

Monte Carlo Simulation propagating charged Leptons through Media as C++ Library
GNU Lesser General Public License v3.0
35 stars 21 forks source link

Create function for EnergyCutSettings #300

Open Jean1995 opened 2 years ago

Jean1995 commented 2 years ago

When creating EnergyCutSettings, one has to explicitly create a shared ptr in C++:

auto cuts = std::make_shared<EnergyCutSettings>(2, 1, false);

There should be a create function this does this, as it is already implemented for other objects as well:

auto cuts = make_energy_cuts(2, 1, false);

maxnoe commented 2 years ago

I dont like this. This reduces the Information available for the Reader for a minimal number of saved character.

Jean1995 commented 2 years ago

I dont like this. This reduces the Information available for the Reader for a minimal number of saved character.

Isn't it common to provide such helper function within an API?

maxnoe commented 2 years ago

Isn't it common to provide such helper function within an API?

What is the benefit of writing or reading:

auto cuts = make_energy_cuts(2, 1, false);

over?

auto cuts = std::make_shared<EnergyCutSettings>(2, 1, false);

It's 10 characters shorter, yes. But you loose the type information completely. The second version is completely clear that it creates a std::shared_ptr<EnergyCutSettings>.

Don't optimize the number of typed characters if it hurts something else.