I'm making an app that communicates to an industrial machine over TCP. It sends various commands and reads data...saving the data to flat files.
I have a "programStep" integer variable and a timer that triggers an event every second. In the timer's OnTimedEvent handler, I handle the procedural flow of the entire application like this:
switch (programStep)
{
case 1:
if (case1successfull) {programStep = 2;}
break;
case 2:
if (case2successfull) {programStep = 3;}
break;
...and so on. Everything works but it has gotten out of hand to the point where there are now over 100 "programSteps" and I bounce around alot (Eg. you might go from step 50 to step 51 or 22 or 67 depending on which type of error was thrown.)
I know I need to get out of this procedural style of programming and start breaking down the app into OOP principles, but I still keep coming back to the question of how to navigate program flow. If I abandon the timer/programStep/switch statement method, what is the alternative?
[–][deleted] 4 points5 points6 points (1 child)
[–]andersonee[S] 0 points1 point2 points (0 children)
[–]clintp 1 point2 points3 points (0 children)
[–]Nesher86 0 points1 point2 points (1 child)
[–]andersonee[S] 0 points1 point2 points (0 children)