MyPicasaPictures Part 3: Abstraction, Encapsulation, Model-View pattern — starting on the design

…I’ve never actually implemented a design pattern before, so this’ll be a learning experience all to itself.

However, I have implemented in previous apps what I’ve understood as the distributed application n-tier logical separation approach.  That is, I’ve tried to implement a basic separation/abstraction between the data access code and the “display” (presentation layer) code.  I’ve also tried to encapsulate some of the more substitutable functionality into utility classes, or wrap the access to a particular application behind a generic function call, so that I (or someone else) could substitute an alternative approach or target later on.

With that in mind, here’s a few ideas would make sense for MyPicasaPictures (without an understanding of what the Model-View pattern recommends):

  • provide a class for accessing the remote web service (Picasa Web Albums at first, but others later on), which would provide methods like GetMetaData() & SetMetaData() [both overloaded for one or many Pictures], UploadPicture(), UploadPictures(), DeleteRemotePicture(), RenameRemotePicture(), and Authenticate().
  • providing a class for the local Pictures and Folders, if needed, to create any custom Properties or Methods that aren’t entirely suited to this web services work.  Perhaps there’s some class in the VMC SDK for managing Pictures that includes the specific Properties & metadata that’s exposed by VMC?
  • providing a class for tying together the boring stuff like Startup, Shutdown, cleaning up connections, releasing resources.

[Later…]

Funny how, once I reviewed the VMC SDK’s Model-View Separation discussion, it turned out to be pretty much what I’ve described above.  I was hoping for something more granular, more sophisticated — something I could really sink my teeth into to get a head-start on this web services stuff.

Maybe the…simplicity is because this is just a subset of the Model-View-Presenter pattern, which itself has evolved into more sophisticated Supervising Controller and Passive View patterns.

Model-View, and the VMC-specific code

I’ve been thinking about this for a few days, and I’ve been hammering pretty hard on the MediaCenterSandbox community (trying to get my head around the MCML development model — NOT an intuitive thing, let me tell you).  The more I’ve been digging into this, the more planning and learning I’ll need to do before diving into UI development.  That was the most obvious areas to start (or at least the area I usually start with, giving me more time to mull over how the underlying classes will be divvied up and various functions will be implemented).  Media Center UI work also seems to be where all the ‘talk’ is.

However, I finally had a revelation today, that’ll make my life easier and let me get down to building something: why not start at the bottom, and build my way up?  I was thinking about the Model-View pattern, and it seemed obvious all of a sudden, to first develop “…the logic of the application (the code and data)…”.  Why not generate the web services client code, the data send and receive code, then create the local proxy stubs that call the web services functions, and then the functions for accessing and manipulating the local Pictures and Folders?

While I stabilize the “model” code, I can continue to investigate the MCML UI option, as well as other ways that I might “surface” the functionality I’m building in the “model” portion of the code.  [What if I just built a normal WinForms app?  Or a command-line batch processor?]  [Or why not just fall back to Picasa and be done with it?]

And since the “model” code would all be native C#, no MCML or VMC-isms, there’d be no lost work — all good ol’ fashioned reusable lessons, plus getting to know the Google Data API while I’m at it.  Can’t really lose with this approach, now can I?

 

Tidbits

  • Apparently, Background Add-ins are *not* persistent processes — i.e. they’re not intended to run the whole time from startup of the Media Center UI until it’s closed, or the box is rebooted.  [God only knows what the hell they’re good for if they’re as ephemeral *and* invisible to the user…]
  • MCE Controller — a SourceForge C# project enables programmatic control of the MCE UI.  Last updated a couple of years ago, so it’s hard to know how much of this is still relevant to VMC, and whether much of it has been replaced by the Media Center class libraries.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s