Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Public Demos, Tools and Applications / Red Bull Soapbox Racer built on PureMVC on: October 12, 2009, 09:05:08
It has been online now for a couple of weeks: The Red Bull Soapbox Racer is a 3D Flash game built on PureMVC. Get in your soapbox and race against the Bull, create your own cars and even build new tracks. Challenge your Facebook friends or any other user and win new tools for your virtual garage as your driving skills improve.

The main ingredients:
  • PureMVC (multicore version, Flash only)
  • Papervision 3D
  • Box2D


Thanks again for your work, Cliff! And thumbs up for all the helpful hints and posts in the forum.
Cheers, Oliver

http://www.redbullsoapboxracer.com
2  Announcements and General Discussion / Architecture / Re: Composite data structures: Advice needed for creating the model structure on: March 03, 2009, 03:55:28
Thanks to Cliff and Joel for the advice. After wracking my head during the weekend I decided to go for the one-proxy solution and did some refactoring. So now I'm glad to see that you would do it the same way.
Cheers, Oliver
3  Announcements and General Discussion / Architecture / Composite data structures: Advice needed for creating the model structure on: February 27, 2009, 03:43:09
Hi everyone,
I'm working on a AS3 game using PureMVC and got literally stuck on the middle of the road. Any help or advice is highly appreciated, maybe I'm completely on the wrong track...

On the model side I have a number of drivers and each driver has a list of cars he has created before. Drivers and cars can appear in different views at the same time.

I have separate VOs for cars and drivers and service delegates for server communication. When requesting a driver, I only know its unique ID. The service responds some attributes and a list of assigned car IDs. After parsing the data I request lightweight instances of the referenced cars based on their IDs.

At the moment, every driver VO is assigned to its own DriverProxy instance, car VOs are accessed via CarProxy instances respectively. I access those proxies via the unique driver and car IDs like this:

:
var proxy:CarProxy = facade.retrieveProxy(car.id) as CarProxy;
I'm stuck in the question of how to model the relationship between a driver and its cars:
  • Should the driver VO have a list of car IDs? Or a list of car VOs? Or nothing? Since the driver VOs should be easy to serialize, I tend to the first option, because sending a list of car VOs to the server when serializing a driver makes no sense in my opinion, no? Or maybe the driver VO shouldn't know anything about the cars at all? I have taken a look at the EmployeeAdmin example where the RoleProxy handles the relationship between *all* known users and their roles, while at the same time the UserVO doesn't know about the user's roles. The relationship may only exist in the proxy in this case and be used to provide methods like
    DriverProxy.getCars():Vector.<CarModel>;
  • When parsing the driver data that I received from the server, I come to the point where I find the assigned car IDs. Parsing the data is done in DriverProxy. Based on the car ID I could create a barebone car instance and its CarProxy. Via this proxy I am able to request further car details. But is it okay to create and register a proxy from within another proxy? Feels odd...
  • If I created the CarProxy instance like described above, who is responsible for removing the CarProxy once its no longer needed? The actor who creates and registers a proxy with the facade should also take care of tearing it down once its no longer needed, no? I'm happy with that as long as the car's lifecycle ends when the driver dies too, but what if the car and its proxy are still visible in another context? Say the driver is removed from the stage and therefore its proxy gets removed from the facade, but the driver's car is part of a highscore table thats still visible? If the car's proxy had been torn down, it would no longer be available for the highscore mediator. Do I need an additional proxy that keeps track of the number of references to a car and that handles creating and destroying the proxies?

I hope I explained the problem clearly enough, in my head things are getting quite mixed up.
Thanks for your advice, Cheers, Oliver
4  Announcements and General Discussion / General Discussion / Re: Unit Test advice needed on: November 04, 2008, 07:24:51
Thanks, I'll go that direction!
5  Announcements and General Discussion / General Discussion / Unit Test advice needed on: November 04, 2008, 05:55:46
Hi all,
I'm using FlexUnit to unit test the proxies in my multicore PMVC app. In my test setup I use a TestFacade instead of the original ApplicationFacade since I don't need the whole bunch of Views and Mediators for the moment. Writing tests for simple proxies is no problem, but what is the best approach if I have proxies that know each other and I want to replace the proxy instance that is not under test with a mock object?

Consider this example: I have a UserProxy that knows the user's login state and a GameSetupProxy that I want to ask if a game can be started, which is the case when the user is logged in and other requirements are met. Sample code:
:
public class UserProxy extends Proxy {
public static const NAME : String = "UserProxy";

public function UserProxy() {
super(NAME);
}

public function isLoggedIn():Boolean {
// Perform some check here
return true;
}
}

public class GameSetupProxy extends Proxy {
public static const NAME : String = "GameSetupProxy";

public var requirementsMet : Boolean;

public function GameSetupProxy() {
super(NAME);
}

public function canStartGame() : Boolean {
var userProxy:UserProxy = UserProxy(facade.retrieveProxy(UserProxy.NAME));
return requirementsMet && userProxy.isLoggedIn();
}
}
Testing the UserProxy is easy, but when it comes to testing GameSetupProxy, I want to test the class in isolation and therefore created a UserProxy mock. Now the line
:
UserProxy(facade.retrieveProxy(UserProxy.NAME)); makes no sense anymore since I have registered the UserProxy mock with the facade instead of the original UserProxy.
I can refactor GameSetupProxy to be able to exchange the UserProxy instance, e.g. by letting both, mock and UserProxy implement the same interface, but maybe you can give me additional advice.

Thanks a lot, Olli
6  Announcements and General Discussion / Getting Started / Re: How to inform a new mediator/view about the data to display on: October 09, 2008, 07:08:24
Thanks! That's pretty straight forward. Maybe I thought too much about asking Proxies, handling notifications and all that stuff.
7  Announcements and General Discussion / Getting Started / How to inform a new mediator/view about the data to display on: October 09, 2008, 06:38:30
Hi all,
I'm new to PureMVC, so I guess the answer to my problem may be quite obvious:

I work on a AS3 application, Flex is not envolved. I have a combo box containing an array of car objects, and the user can click a "View Details" button to open a layer with more information about the selected car.

The layer I open is a view component that I create as soon as the notification is received:

:
[ApplicationMediator.as]
override public function handleNotification(notification : INotification) : void {
switch(notification.getName()) {
case ApplicationFacade.VIEW_CAR_DETAILS:
// Get the object of interest from the notification
var car:Car = notification.getBody() as Car;

// Create the view component
var carDetailsLayer : CarDetailsLayer = new CarDetailsLayer();

// Register a new mediator for the component
facade.registerMediator(new CarDetailsLayerMediator(carDetailsLayer));

// Add the component to the display list
mainHost.setLayerContent(carDetailsLayer);
break;
}
}

Now I want to know which is the best way to inform the new Mediator/Component about the object of interest, the car. Since there is no such thing as a CarProxy that knows the current selection, I pass the selected car as the body of the notification. But the mediator itself can't listen to the notification since it doesn't exist yet when the notification is sent. And as Cliff writes in his Best Practice guide, mediators should only react on notifications instead of providing an own API.

I hope you can give me a hint what is the best practice for this case.
Thanks, Oliver
Pages: [1]