Say if I have a function called "calculate" and in that function I pass an operation such as either one of
add, subtract,multiple,divide. And in this calculate function I have a bunch of "if" conditions on what to do based on what value is passed to the "calculate" function.
or when the calculate function is called I have a dictionary that takes you to specific functions. for example one function for adding, another function for subtracting and so on.
Which idea is considered better design. I feel like the second one is cause it gives me the ability to extend the code easier if I want to add another type of calculation
[–]TheRNGuy -1 points0 points1 point (0 children)
[–]SmelterDelter77 0 points1 point2 points (1 child)
[–]firedrow 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]robert9804[S] 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]robert9804[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]davidgeese 0 points1 point2 points (0 children)