Tuesday, September 21, 2010

PatternCraft – Visitor Pattern

PatternCraft is a series of video tutorials that use StarCraft references to teach Design Patterns.

This video is the fifth in the series and covers the Visitor Pattern.


Other PatternCraft tutorials:
Mediator Pattern
Memento Pattern
Command Pattern
State Pattern
Strategy Pattern

Source is here: http://github.com/johnlindquist/johnlindquist.com/tree/master/VisitorPatternDemo/src/

14 comments:

  1. Wakka3:01 AM

    while i really liked your other tutorials, i don't really like the example of this one.

    in my opinion the main benefit of using a visitor pattern is to create exchangeable algorithmns that traverse tree-structures. you totally left out that point by just iterating through all objects from outside of the visitor.

    ReplyDelete
  2. johnlindquist7:08 AM

    Thanks for the constructive criticism, I really do appreciate it.

    I'm actually planning on revisiting many of these tutorials after I've finished covering other patterns. For example, now that I've covered Memento, I can teach undo/redo with Commands or, when I cover Flyweight, I can show how to manage Strategies.

    I haven't covered any structural patterns yet (like Composite), so I tried to just focus on the "double dispatch" portion of Visitor. Maybe I failed to show the true value of Visitor, but I think it's a solid intro to the main concept.

    Cheers,
    John

    ReplyDelete
  3. Gjslick2:43 PM

    John, thanks for these videos, they are awesome! It's great to see some step-by-step examples of when these patterns can be used, from original (problem) code, to an elegant design patterns solution. Also, relating them to Starcraft (a game which many people have seen) is brilliant, whereas these patterns can be very hard to visualize from the Design Patterns book itself. Keep up the great work on these, I'm learning a lot!

    ReplyDelete
  4. OK, you'r right.

    Keep on the great work!

    ReplyDelete
  5. This pattern is new to me, but I really like it. For me, it solves the issue of looping through characters and saying if you're an enemy then do x and if you're the player do y. By using the double dispatch the character determines how the visitor reacts to it.

    I'm looking forward to seeing more in this series. Keep up the good work!

    Mark

    ReplyDelete
  6. Fernandodefranca11:10 AM

    Awesome!

    ReplyDelete
  7. I'm really loving all of these Design Pattern videos!!

    Since I'm now on a Mac, a few weeks back I decided I would switch from FlashDevelop to FlashBuilder temporarily to see if it's a worthwhile permanent switch. SourceMate helped it to be a little better, but I'm still not totally happy. I'm considering switching to either FDT4 or IntelliJ. Now that you've been using IntelliJ for a while, what's your honest opinion? Which would you use if you weren't paid to use one over the other? =)

    ReplyDelete
  8. johnlindquist12:47 PM

    I'm giving a presentation at Max to address that exact question. It's a pretty loaded question since everyone's needs are different, but for my needs I would use IntelliJ (but I still wouldn't recommend buying IntelliJ until version 10 releases later this year).

    ReplyDelete
  9. this screencast is really helpful to me, thank you.

    ReplyDelete