Need refactoring ideas for Arrow Anti-Pattern

后端 未结 7 1494
刺人心
刺人心 2021-01-02 02:13

I have inherited a monster.

It is masquerading as a .NET 1.1 application processes text files that conform to Healthcare Claim Payment (ANSI 835) standards, but it\'

7条回答
  •  甜味超标
    2021-01-02 02:37

    Judging by the description, a state machine might be the best way to deal with it. Have an enum variable to store the current state, and implement the processing as a loop over the records, with a switch or if statements to select the action to take based on the current state and the input data. You can also easily dispatch the work to separate functions based on the state using function pointers, too, if it's getting too bulky.

提交回复
热议问题