Need refactoring ideas for Arrow Anti-Pattern

后端 未结 7 1513
刺人心
刺人心 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:19

    Sometimes I combine the state pattern with a stack.

    It works well for hierarchical structures; a parent element knows what state to push onto the stack to handle a child element, but a child doesn't have to know anything about its parent. In other words, the child doesn't know what the next state is, it simply signals that it is "complete" and gets popped off the stack. This helps to decouple the states from each other by keeping dependencies uni-directional.

    It works great for processing XML with a SAX parser (the content handler just pushes and pops states to change its behavior as elements are entered and exited). EDI should lend itself to this approach too.

提交回复
热议问题