Timeline for Using visitor pattern with large object hierarchy
Current License: CC BY-SA 3.0
9 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 25, 2018 at 4:49 | comment | added | Tintenfiisch | @dasblinkenlight Understand, and thanks for the fast answer ! (did not expect that :D) One additional question: I have a quite complex class hierarchy (SequenceItems and LeafItems) each with several inherited child classes. For my Visit(ExplicitClassFromLeaf item) method, do you think it should call the corresponding base class visit method as well ? (e.g. Visit(BaseClassForLeaf item) Or should it only be used as fallback? An inherited sequence item should call the the base class before or after visiting childs ? or both ? Any good practice ? | |
| Jun 25, 2018 at 4:34 | comment | added | Sergey Kalinichenko |
@Tintenfiisch That's a completely different technique, which cannot be done without an overload (which I use almost exclusively in place of a visitor now). I am talking about the technique where each class implementing IVisitable needs to make a call to its own overload, causing a certain amount of confusion among human readers of the code.
|
|
| Jun 25, 2018 at 4:25 | comment | added | Tintenfiisch | @dasblinkenlight C# now offers dynamic to let the runtime decide what overloaded method should be used (not at compile time). Is there still any reason why not to use overloading ? | |
| Jun 8, 2012 at 6:39 | vote | accept | T. Fabre | ||
| Jun 6, 2012 at 15:39 | comment | added | Sergey Kalinichenko | @SnOrfus Please see my answer to T.Fabre above. | |
| Jun 6, 2012 at 15:39 | comment | added | Sergey Kalinichenko | @T.Fabre It does not matter in terms of speed, but it does matter in terms of readability. Method resolution in two of the three languages where I implemented this (Java and C#) require a run-time step to choose among the potential overloads, making the code with massive number of overloads a little harder to read. Refactoring the code also becomes easier, because choosing the method you'd like to modify becomes a trivial task. | |
| Jun 6, 2012 at 14:24 | comment | added | T. Fabre | Can you explain why you don't recommand using overloads ? I read somewhere (on oodesign.com, actually) that it does not really matters whether I use overloads or not. Is there any specific reason why you prefer that design ? | |
| Jun 6, 2012 at 14:21 | comment | added | Steven Evers |
Can you clarify why you say Do not use overloads in the interface of the visitor ?
|
|
| Jun 6, 2012 at 13:45 | history | answered | Sergey Kalinichenko | CC BY-SA 3.0 |