Geeks With Blogs
Mike Kenyon Hoarked

I’m not a Microsoft employee, but I’ve been on the advisory board for P&P’s Composite Architecture for WPF and Silverlight (hereafter just called Prism) project since v1.  It’s a great little piece of software and I’ve been negligent about blogging on it, so I thought I’d take the opportunity of starting up this blog to do so.

History

For those that are unfamiliar, since 2003, P&P has been generating a series of application blocks, software factories and guidance packages that have promoted a concept called composite architectures.  The goals here are several:

  1. Separation of concerns.  There’s a struggle in trying to test UI applications in that the business code becomes entangled with the display and it becomes harder and harder to test.  Anything that can break the display from the behavior enables better testing.
  2. Modularity.  Large applications tend to get generated by large teams and there’s not generally good communication channels between them.  When different teams need to share an executable space, there need to be some protocols in place for how they get initialized, talked to and share information.
  3. Composable UI.  This extends the modularity concept not only to the application as a whole, but to parts of the display.  How do I have menus interact, toolbars unify, etc. when the different parts were made at different times by different teams.
  4. Loose coupling.  Its frequently the case that as applications grow, you want to share data from one end to the other.  As this occurs, you find more and more of your application tied to opposite ends and you end up with the veritable spaghetti bowl, rather than a nice, neat application anymore.  Supporting ways to loosely tie things is like adding a little salt & oil to the pasta water.  No more clumping.
  5. Injection-friendly.  Inversion of control has become a reasonably common pattern for supporting configurability and supportability along with greatly improved testability.  These frameworks embrace the idea.

The combination of these traits results in code that is cleaner, easier to extend and easier to support.

The downside is that traditionally this also came with a lot of weight.

In 2003, P&P supported the release of the Composite Application Block (CAB).  This was a cut at supporting this functionality for WinForms applications and had great success, but it was monolithic.  It was very hard to use the system without being trained in its depths and making changes for the uninitiated was hard.  A severe shortage of secret handshakes and staves meant that it didn’t get the play it probably should have.

In 2004-5, CAB bulked out from large to ghastly with the addition of a number of supporting blocks, GAT/GAX tooling and LOTS of documentation and became the Smart Client Software Factory (SCSF).

In 2005, SCSF was ported to the web and became WCSF.  It was smaller and leaner.  The documentation and GAT/GAX tooling was there and it was slightly easier to comprehend then SCSF.  It also lost some of its purity to the pains of the web.  On the downside, because of a number of issues, there were large chunks of code that were re-used between the two blocks either as pure copy-and-paste reuse or with minor tweaks to work on the web.  This made it hard, but not impossible to write components that worked in both SCSF and WCSF.

In 2006, the CAB community extended SCSF out into the WPF space with plugins that supported both WinForms with embedded WPF content and the reverse.  The problem was that a LOT of the concepts and ways of doing things in SCSF were tied to WinForms concepts that either no longer made sense or could more cleanly be done with mechanisms in WPF.

In 2006-7, Microsoft launched the Acropolis project.  This project was a from-scratch application framework in WPF.  It had a LOT of great tooling around it, but it suffered a number of problems and for reasons I’ve never had completely clearly articulated the project was disbanded.  It wasn’t perfect, but it was better than the SCF-WPF bridges.

In 2007, Microsoft launched Prism.  Prism is the new-generation to grow from both the ideas and the lessons learned from SCSF and WCSF.  It’s cleaner, smaller, lighter-weight and “injectable”.  What I mean about the last one is that its relatively easy to incorporate the framework in an existing application.  In the previous incarnations, it was much harder to do an incremental inclusion of the framework.  Possibly in all of them, yes.  Harder, surely.  Prism also attempts to alleviate the differences between windows and web by supporting the same framework on Silverlight and WPF.  You have to jump through some hoops in order to get there, but that’s caused by differences in the display frameworks themselves, not caused by the application framework that sits on top of them.

Where is this all going in the future?  Well, that’s a good question.  Microsoft has started up the managed extension framework and the common service location projects which are part of .NET 4.0 and will have a major impact on the portions of the framework that are “Core .NET” and not.

Project

So I don’t know about you, but my mind always works better when it’s got something physical to wrap around and I find that I can actually motivate myself better to do things when I have something to get accomplished.  To that end, I need to make a confession.  I have a horrible, dirty addition.  I … I … I love the Oscars.  Yes, its pedantic, yes, it’s a bunch of people I don’t care about 364 days out of the year spending MILLIONS slapping each other about the back, but there’s something about the Oscars I really like.  Okay, I’ll admit it.  It’s a good excuse to haul the kilt out.  Apart from that, it’s an excuse to get a bunch of people together, have some adult beverages and observe all that there is wrong with the world in so many, many ways.

In accordance with this addition of mine, I’ve taken to having a party annually.  A black-tie affair, held in my basement.  I have a red carpet, there’s wine and appetizers, the whole deal.  Part of the festivities has annually been the proclaiming of guesses and the scoring of the same.  There are 24 awards categories for the televised show and we assign a point-value to each.  Everyone then makes their guess for all 24 and then we tally points as we go through.   In the past, I’ve taken stabs at making an app to do the whole deal because otherwise we end up with a slightly tipsy Welshman in the back of the room ignoring the show and doing maths.  Funny, but not really the best plan.

The practical goal therefore is to come up with an application that will do this task for me.  This is going to be a running journal of the experience, good, bad and indifferent. 

My actual goals extend beyond that.  I want to provide a sample of Prism development.  I also want to explore Designer/Developer separation.  To do this last bit I’m going to withhold styling the app as best as I can stand it until its up and running and then go and style it.  Of course, in this case I’m playing both roles, but I’m going to try to segregate as much as possible.

For clarity sake throughout the series I’m using Prism v2 drop 9, which is the latest as of the date of this post.

Requirements

Designing a composite application does not mean not designing an application.  Just because the application can be composed and there’s a fair amount of injection going on, how and where that’s allowed is still up for grabs.  It’s also really hard in my opinion to design without having requirements, though less so with composite applications than others.  So, let’s run through a couple of business requirements and from those let’s abstract out a series of design decisions.  So, without further ado …

  1. The application (or at least the first cut) is going to have 3 major functions.  These are:
    1. Allow people to see a little about the current nominees, reviews, etc. (Browse mode)
    2. Allow people to select their choices for who is going to win. (Enter mode)
    3. Score the live Oscars to provide blow-by-blow results and facilitate people bragging, talking trash and doing the Snoopy dance. (Score mode)
  2. It should be possible to switch between these three modes at any given time.
  3. Current state for a mode should be remembered when switching between modes. 
    1. It’s not necessary (but nice) to remember state between runs.
  4. In Browse mode, the user should be able to browse between the following items.
    1. Categories
    2. Movies
    3. People
  5. For each display, at a minimum it should list the other types of data to which its connected (e.g., when looking at movies, you should see the actors in them and the categories they’re up for).
  6. In Enter mode, you should be able to pick in any order, go to and return from the Browse views for the nominees.
  7. You should be able to make exactly one pick a “double-down” for double the normal points.
  8. In Score mode, you should be able to pick the categories in any order. 
    1. You should be able to reprise an answer (if you screwed up).
    2. There should be a display with the current leaderboard sorted descending with point values.
  9. Time permitting, it would be nice to support additional views on the data:
    1. Allow the viewing of reviews
    2. Allow the viewing of other people’s current choices
    3. Hide the above and expose them for a drop in point values
    4. Hide the above and allow a limited number to be exposed (dial-a-friend and poll-the-experts).
    5. List of actors/roles in the movie.

 

That’ll do for now.

Posted on Monday, January 26, 2009 8:52 PM | Back to top


Comments on this post: Creating a WPF Application With Prism v2 – Background & Requirements

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © hoarked | Powered by: GeeksWithBlogs.net