Looking for some advice here, mostly to what some much more experienced programmers would see as the pro and cons of two different approaches. Just and FYI all the code that I have as of now works, I am just looking for advice on approaches, as this is all still pretty new to me.
I am writing a program that will control a automated batch reactor. There will be set points that will be able to be edited from the software.
The user interface is from a keypad that I drew up on a touchscreen display. It works great.
I don't know at the moment how many set points I will have, but it's safe to say it will be greater then 10.
User is on the edit set points menu and selects the option to edit the lower pH set point.
This would call the function editSetpoint("pHL");
Function editSetpoint calls my keypad() function to draw the keypad to the screen. It then further displays information based on the string value that I sent to the function.
Now the user hits the confirm button and it calls errorCheck(keyedInput, "pHL")
keyedInput is the value the user input, the function returns a boolean value.
Now my error checking works, it uses nested if statements. First it has to check for the parameter "pHL" then does the various error checks.
I was thinking of utilizing switch statements. I would define a variable such as
#define pHL = 1
This would allow me to use switch statements in my errorCheck function.
Is there any real advantage to one approach to the other? To me method #2 looks neater, but am curious to learn more about the two approaches.
Thanks in advance for any input!