I am trying out the Julia language (coming from a Python background) and am interested in the most natural way to tackle an issue I would have solved using objects in Python.
Basically, I am trying to program a function that will evaluate some simple 1-d mathematical bases and then combine them to approximate a multidimensional function. In Python I would have written something like
basis_1d_values = scheme_1d.evaluate(points)
for each of my scheme_1d objects. I would use a parent Scheme1d class, and then have subclasses for the various types of 1-d schemes (linear, Chebyshev polynomial, etc.) that would know how to run their separate "evaluate" functions.
What is the most natural way to do this in Julia? Obviously a long if statement like
if scheme_1d_type == "linear"
basis_1d_values = evaluate_linear(scheme_1d, points)
elif scheme_1d_type == "chebyshev"
basis_1d_values = evaluate_chebyshev(scheme_1d, points)
elif ...
...
end
will work but it is very clunky since I will need to use these branching if statements and separate functions every time the subclasses behave differently (and will have to keep track of every if statement when I update the code in some way). Any suggestions would be much appreciated.
Thank you!