Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    If there is no compelling reason (such as polymorphism) to make all the algorithms have the same interface (execute()), then I would actually prefer option 3, except that I'd only pass the state (a copy of it) to algorithm 2. This communicates that this specific algorithm requires additional, just-in-time information in order to run. If that's not feasible, then I'd consider other options. Commented Mar 7 at 12:38
  • 1
    Along the same lines, I don't particularly like that 'inData' is shared/accessible at the algorithm level, especially if not all algorithms use all of inData. I'd be more inclined towards algorithm-specific inputs with less generic type names, extracted from inData by, say, your Manager class. Think of ctor params as configuring the object in general, and of method params as pertaining to a particular call, then decide which inputs to pass to the ctor vs the execute method. But I don't know enough about the project, so maybe there's good justification for the way it's currently designed. Commented Mar 7 at 12:39
  • please don't cross-post: stackoverflow.com/questions/79491997/… "Cross-posting is frowned upon as it leads to fragmented answers splattered all over the network..." Commented Mar 7 at 20:17
  • It's better to draw some diagrams - class diagram, state machine diagram. These can help you to refine your design. One suggestion I can think of is to introduce callbacks. Like if a state is reached, call the callback function which in your case, will trigger something in Algorithm2. Commented May 15 at 8:40