You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue
Currently the functionality of converting an expression to a string using prefix, postfix or infix notation is hardcoded as part of the Expression class hierarchy. More specifically, it is defined in the toString(Notation) method of the Operation class. This does not make much sense, since the way of outputing an expression in string format should be independent of how the expression is structured and represented internally.
Proposed solution
Use the Visitor design patterns, that is already present for evaluating expressions, to implement a new visitor for outputting arithmetic expressions as strings using different possible notations (prefix, postfix, infix traversal).
Move the "counting methods" that are part of the Expression class hierarchy to count the numbers and operations and depth of an expression, into another visitor.
Adapt all unit tests to accommodate the refactoring, since it will change the current way in which the code is structured.
Classification
suggested code refactoring
Related issues
This proposed refactoring is related to bug issue #2 that will, in principle, be resolved if the proposed refactoring is carried out correctly.
The text was updated successfully, but these errors were encountered:
Issue
Currently the functionality of converting an expression to a string using prefix, postfix or infix notation is hardcoded as part of the Expression class hierarchy. More specifically, it is defined in the toString(Notation) method of the Operation class. This does not make much sense, since the way of outputing an expression in string format should be independent of how the expression is structured and represented internally.
Proposed solution
Classification
suggested code refactoring
Related issues
This proposed refactoring is related to bug issue #2 that will, in principle, be resolved if the proposed refactoring is carried out correctly.
The text was updated successfully, but these errors were encountered: