cossan-working-group / OpenCossan

OpenCossan is an open and free toolbox for uncertainty quantification and management.
https://cossan.co.uk
49 stars 16 forks source link

RandomVariables #31

Open etheban opened 4 years ago

etheban commented 4 years ago

what is the benefit of instantiating an object using a method and not the constructor?

instead of P = LognormalRandomVariable.fromMeanAndStd('mean', 5000, 'std', 400, 'Description', 'Load');

we should have P = LognormalRandomVariable('mean', 5000, 'std', 400, 'Description', 'Load');

FriesischScott commented 4 years ago

The reason we did this was, that checking weather to construct from the rv parameters or mean and Std is quite complex and Matlab does not support multiple constructors.

For example: What happens if you pass both the parameters and mean and std? What if you only pass one of the parameters and the mean? There are plenty of different cases resulting in a complex if, then, else structure.

I would be open for a simple way of doing this but in my opinion matlab does not offer a suitable solution for this. One of the downside of the way we abuse name/value pairs.

etheban commented 4 years ago

I care about the interface and usability that somehow we are loosing because we pretend to use object oriented programming for computer scientists.

I prefer to give the maximum flexibility to the end-users not to the developers.