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
Hi I'm not sure how to even start on this question. So from the code given, the question said that there is cyclic dependency between Console and Logic class, and the aim is to remove this.
The text was updated successfully, but these errors were encountered:
What i did was to remove the cyclic dependency by returning a String from the invoke method in Logic which should not take in a Console anymore and then invoking the feedback method in the start method.
Hi @Lzhenghong, you could break up the cyclic dependency by introducing an interface called Consoleable. Console will implement Consoleable and Logic will take in a Consoleable (ie depends on Consoleable instead of Console). This way, Logic can still hold the Console but it sees Console as a Consoleable and the methods it can invoke are limited to what is stated in the contract of a Consoleable (recall ISP and DIP). Maybe you could decide what methods should go in there.
As for @seanangwj comments, you would face issues when Logic will have to call console.feedback() for both primary and secondary consoles in the later portion. Furthermore, this does not work as you are not sure what "// do something based on the command" will do. There are hidden codes there that may change the state of the consoles. logic.invoke() is not simply a print statement.
Hi I'm not sure how to even start on this question. So from the code given, the question said that there is cyclic dependency between Console and Logic class, and the aim is to remove this.
The text was updated successfully, but these errors were encountered: