Archive for the ‘Best Practices’ Category

PureMVC notes

Here are notes that I wrote down during Javier Julio's PureMVC talk at FITC Amsterdam a couple of weeks ago.  I intend to use pureMVC and they'll be a useful reference when the time arrives.  If I have glaringly misconstrued anything please let me know :-)

The Proxy and Mediator

  • The Proxy typically sends notifications
  • The Mediator receives notifications and can also send notifications
  • The Proxy is located in the Model and is a natural location for domain logic, something that tends to be wrongfully be placed in Commands
  • The Mediator performs the key task of separating the View and Model (which is the responsibility of the Controller in Cairngorm)
  • The Mediator and Proxy have a similar setup
  • Methods to override in the Mediator include;
    • listNotificationInterest(),
    • handleNotification()

About Commands:

  • Since service interaction occurs in the Proxy (located in the Model), commands in the Controller are limited to things like; startup, shutdown.
  • A Command is used when you want to do multiple things in response to a notification.
  • Mediators can directly call methods on the Proxy instead of sending a notification.  You don't have to create a Command for everything.
  • Method to override in Command
    • execute()

The Facade

  • Facade is where you retrieve, register and remove actors.
  • The Proxies, Mediators and Commands all have access to the Facade.
  • Some of the methods to override in Facade:
    • retrieveProxy(proxy)
    • registerMediator(mediator)
    • registerCommand(command)

Update:

Javier got in touch with me and kindly pointed out a couple of things that I had got wrong and also offered some encouragement.  These are a few points he made (I've made the amendments to my notes above):

"The Proxy contains controller-like code but is actually in the Model part of the architecture"

Javier - I'm not sure where you picked up this one but definitely not the case, or at least not for the Proxy. You'll find that the Mediator already acts like a controller and that can trip people up about the framework. The reason for this is that the Mediator already does the key job of separating the View Component from the Model (e.g. a or many Proxy class) thus you don't really have a huge need for commands, in fact very little. This is expected and because the Mediator essentially acts like a controller.

"...Controller are limited to things like; startup, shutdown, database calls."

Javier - I could be misunderstanding database calls here as you could mean that a Proxy that makes a call to the server to fetch data from a database but was triggered by a command. Or say an AIR app that can interact with SQLite. But things like that you want to avoid having in the Command and move into the Proxy. This is one of the big differences between PureMVC and other frameworks because by moving service interaction into the model we can achieve portability and reusability.

"Mediators can directly call methods on the Proxy instead of sending a notification sometimes.  You don't have to create a Command for everything."

Javier - Cliff Hall, the creator of PureMVC, and others, especially myself couldn't be more proud. :) You learned probably one of the most important things to take away from the presentation. A lot of people get this wrong. I use the word "wrong" as Cliff has stated very good reasons why this is not only acceptable in the framework but pushed for you to do. Don't create a command class for an action that only ever happens in one place, you are just doing more work and adding more bloat.

Posted by admin on March 11th, 2010 1 Comment

Thinking about version control?

I've recently decided to take the bull by the horns and bring a sense of order to my personal projects by using some form of version control.  My personal projects don't normally involve other developers so you might be asking why bother with source control?  Well, for several reasons:

  1. Having a single respository to act as a centralised location for source code retrieval - Although there is only one of me I happen to have several machines (work laptop, personal laptop, PC, etc..) and I move around a lot.  A USB key is very useful for taking the latest files with me but I have to be very disciplined or else this system will break down and I'll end up with multiple versions spread across different machines... and this is what Subversion was designed to help with!
  2. Being able to revisit older snapshots of a codebase - this is effectively a breadcrumb-like navigation that allows me to traverse the life of a project
  3. A web-based repository provides a set up for collaboration with subcontractors when the need arises
  4. I am familiarising myself with a popular method of version control that many companies use.
  5. I am tired of using VSS at work and I am interested in using an alternative.

I did a fair amount of research and finally settled on creating a free account with Unfuddle, who provide a Subversion Hosting service.  Subversion (SVN) is an open source version control system with a client/server architecture.  Using an online service like Unfuddle removes the need for me to set up a subversion server on my web hosting package (I would have had to upgrade my hosting package to accomodate this).  I already use Tortoise SVN as a subversion client for getting source from projects on Google Code and I am going to stick with this.

Here a some links that I found useful:

Version Control for Windows Users Presentation
Subversion hosting packages
http://unfuddle.com/
http://cvsdude.com/
http://beanstalkapp.com/

Set up your own subversion server
http://www.visualsvn.com/server/

Subversion for designers

Subversion project page

SVN Book

Backing up a subversion repository on Unfuddle

Posted by admin on December 26th, 2008 3 Comments