<< Philly ALT.NET - Thursday July 17 - Building Maintainable Apps with WPF | Home | "Getting Started With TDD" Workshop Recap >>

Philly.NET Workshop - Slides, Code, and Lessons Learned

posted @ Tuesday, July 29, 2008 10:20 PM

Tonight, Erik Peterson and I did a hands-on workshop as part of Philly.NET's workshop series.  Our topic was "Building Maintainable, Testable WebForms Applications with the Model-View Presenter Pattern."  Without further ado, here are the slides and code from the workshop.  This is the "final" version of our basic app, which is farther than we got in the workshop, so hopefully this will answer some questions that we didn't get to. 

Slides

Code

Model-View-Presenter
Model, View, Presenter!

I'd like to thank everyone that came out and Philly.NET for hosting us.  This was the first workshop for both of us and your feedback was incredibly valuable.  We definitely got some feedback that we'll incorporate in the future.  One of the challenges of teaching TDD is finding the balance between examples and/or approaches that are too simplified to be useful, vs. throwing way too many concepts and/or tools at the audience for them to be able to follow along.  Things like rolling your own mocks and stubs vs. using a framework like Rhino Mocks - the former may be easier to understand initially, but adds a lot more busy work and complexity to the test library, and can end up being almost as hard to explain.  I tend to show all the tools and tricks, and hope that the concepts are made clear, and detailed usage can be researched further after the fact.  But, I do think I need to be very careful about this approach and do as much as possible to help people follow along.  I'm definitely interested in any tips or advice from those more experienced in teaching these things than I.

Also, some more technical details - I should have definitely used the default color scheme of Visual Studio, and not my crazy black background.  People made the valid point that it's easier to follow the code in the scheme they are used to.  Finally, starting out with a blank slate application was probably too ambitious for a 2.5 hour workshop.  We should have started with a little demo functionality to introduce concepts, and then added on top of it. 

In the last slide of the PPT deck there are some links to further references on MVP and TDD.

A couple shout outs:
  • JetBrains provided us with a couple Resharper licenses to give away. 
  • And don't forget our own Philly ALT.NET user group!  It's a great place to learn more about the concepts we introduced tonight, as well as meet and learn from other developers in our area, and get answers to questions on our discussion group.

UPDATE:  I'm wondering if anyone would be interested in a follow-up presentation at a Philly ALT.NET meeting where we could review the "final" version of the app in more detail, answer lingering questions, etc.  If you are interested in this, please leave a comment, or post a note to our  discussion group.

Comments

  1. Scott L Holmes

    Posted on: 7/30/2008 9:04 AM

    # re: Philly.NET Workshop - Slides, Code, and Lessons Learned

    Was in attendance last night. Overall, I got a real feel of the power of the ADD process and Resharper. MVP makes much more sense with a powerful tool like Resharper. My other experience with BDD was in Ruby and the test, code, refactor cycle seemed tedious because I had do write all the code myself.

    I look forward to reviewing your finished app in detail. I would suggest as a refinement to this workshop, that you review the principle MVP entities (services, interfaces, mappers, etc) to show off the architecture a bit.

    My greatest challenge in understanding MVP/C is in reconciling my desire to create a spec versus the overall architecture of the system. In other words, how do you reconcile YAGNI versus MVP when aren't quite sure what MVP is?

    Cheers!

    Scott

  2. Brian Donahue

    Posted on: 7/30/2008 11:01 AM

    # re: Philly.NET Workshop - Slides, Code, and Lessons Learned

    Scott,

    Thanks for the suggestions. I got a lot of feedback that having a partially, or almost fully completed demo app at the beginning, and using that to illustrate concepts *before* making any new changes would have been useful. I'm definitely going to give that a shot next time. In a couple months, I hope to do a similar presentation using the ASP.NET MVC framework, so I am going incorporate a lot of feedback from this meeting.

  3. Jason

    Posted on: 7/30/2008 11:44 AM

    # re: Philly.NET Workshop - Slides, Code, and Lessons Learned

    MVP and MVC get interchanged by some developers. I believe the difference in defination (and implementaqtion) is who is responsible for initiating process.

    with MVP the view knows about the presenter. usually there is an instance with the object. and the view initiates calls to the presenter.

    with MVC the view doesn't know anything about the controller (presenter in MVP) the controller is determined by a routing table. the request is sent to the correct controller. the controller fulfills the request and sends the data to a view. this is very popular in the web world with REST-ful urls. it makes a even cleaner SoC for presentation. It also plays well with IoC containers better than MVP.

    Brain, I wasn't there for the presentation, but did review the slides and code. your wiring events from the view to the presenter, but your using accessors in the view to get the values. why not custom Eve ntArgs instead? were view properties choosen for simplicity?

    I ask because when I implement MVP in webforms I create a presenter field. I instiant the presenter in the Inti event and call presenter members from the Page/Control events (Load, Click, SelectedIndexChanged, etc). I also found passing a DTO from the view to the presenter can simplify the view interfaces.

    all in all I'm really impressed with code/slides. wish I could be there. I'm in HBG, PA. Philly trips aren't exactly around the corner:)

  4. Brian Donahue

    Posted on: 8/1/2008 4:06 PM

    # re: Philly.NET Workshop - Slides, Code, and Lessons Learned

    Hi Jason,

    I appreciate the feedback. The event wiring I was doing is my least favorite part of the solution as it's not very testable (you can test that an event was bound, but not what it was bound to, etc). My co-presenter and I went back and forth and ended up with that solution, which was more of my leaning than his.

    I'm not a fan of the view delegating to the presenter, but it can be clearer I suppose. I'd be interested in seeing your version, if you are up for modifying the code and emailing me (I think you have my email from JP's course?)

    Custom event args might be a good compromise. I may play with that and see if I like that better.

Your comment:



 (will not be displayed)


  Please add 6 and 4 and type the answer here: