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
This issue relates to #38 but is not a complete duplicate of it
Despite being titled "Visitor..." and forcing the implementation of two methods accept and visit, the pattern which need to be implemented in this exercise is a fancy variation of the Composite pattern. Not the Visitor.
This, for instance, is illustrated by the fact that Visitor interface comprises only two signatures for the visit method. One is visit(Object), the other is visit(Visitable). In a true visitor pattern, one would expect the definition of a visit method for each and every type that might be encountered by the visitor. Also, all those types should be implementing an acceptmethod, otherwise no double dispatch is possible. Here, it is easy to see that one cannot just modify Object to force it to implement accept. Also, that would not make much sense since in java "everything is an object". Thus, this would mean that the visitor is universal and all other types would no longer need to implement accept; thereby defeating the double dispatch purpose of the pattern.
The text was updated successfully, but these errors were encountered:
This issue relates to #38 but is not a complete duplicate of it
Despite being titled "Visitor..." and forcing the implementation of two methods
accept
andvisit
, the pattern which need to be implemented in this exercise is a fancy variation of the Composite pattern. Not the Visitor.This, for instance, is illustrated by the fact that
Visitor
interface comprises only two signatures for thevisit
method. One isvisit(Object)
, the other isvisit(Visitable)
. In a true visitor pattern, one would expect the definition of avisit
method for each and every type that might be encountered by the visitor. Also, all those types should be implementing anaccept
method, otherwise no double dispatch is possible. Here, it is easy to see that one cannot just modifyObject
to force it to implementaccept
. Also, that would not make much sense since in java "everything is an object". Thus, this would mean that the visitor is universal and all other types would no longer need to implementaccept
; thereby defeating the double dispatch purpose of the pattern.The text was updated successfully, but these errors were encountered: