Tuesday, December 16, 2008

Announcing JumpShip 4.0

JumpShip 4.0 has been released. The new version, although not significantly different from the last, takes a slight philosophical departure from the last. And since it was a significant enough change to possibly break compatibility with older version, I've decided to call it a new major revision.

The most significant change in JumpShip 4.0 is that, now the framework actively discourages the use of Singleton that have become widely popular in other frameworks. Although JumpShip has always touted it's diminished use of Singletons and therefore it's advantage when using it a an application framework or a component framework, the framework itself has never taken an opinion on the use of the Singleton pattern and in face included a few Singletons itself.

There has been a recent backlash against the Singleton pattern in the design pattern world ( See the post on http://www.as3dp.com, Scott Densmore's post, or Miško Hevery's thoughts ). The Singleton has been used as a substitue for global variables ( you know, those things good programmers never use ), and have all of the drawbacks of globals. They can be very convenient but make your code hard to read, hard to test, and hard to debug.

For all these reasons, the latest version of JumpShip has removed ( almost ) all of the Singletons in the Framework. The one exception being the JSRuntimeEnvironment class which is used to make your application behave slightly differently ( logging, throwing errors, etc. ) in a development environment than it does in a production environment ( stability at all costs ).

Eliminating Singletons meant eliminating some classes from the framework, namely the service locator classes, and changing others, JSApplicationState and JSRailsGatewayBase, so that they do not have Singleton implementations.

This has effected the Rails Gateway classes the most and hopefully made the easier to use. You now no longer need to extend JSRailsGatewayBase in order to use it. Instead of having to define a service locator in the implementation, you simply pass in the base path of your Rails app when you create a new JSRailsGatewayBase instance.

The JSApplicationState class is also no longer a Singleton which means you can have as many different state objects as you want.

The other big change in JumpShip 4.0 is that now the JSDataRecord class recognizes when another JSDataRecord instance has been added as an attribute and will automatically listen for data binding events, rebroadcasting them upward if one is received. This allows multi-dimensional data structures that maintain data binding all the way down the tree. Although, JumpShip still encourages flat data structures, there may be occasions when you need data binding for multi-dimensional data.

Finally, JumpShip 4.0 includes improved documentation and a few bug fixes for potential memory leaks.

Saturday, July 19, 2008

Using JumpShip inside Flex. A roadmap.

Using JumpShip inside Flex. A roadmap.

All files can be found at: http://www.youbits.com/jumpship/FlexAndJumpShip.zip for your convenience the entire JumpShip Framework is also included.

        The JSDataModel and JSControllerBase can be used inside of an mxml document as they are. The only trick to using JumpShip in Flex is in using JSViewBase. 

JSViewBase extends Sprite in order to add the ability to add, remove and manipulate DisplayObject's to itself and have those DisplayObjects be part of the Display List. It extends Sprite as opposed to Flex's UIComponent so that it can be used in both Flash and Flex but this decision adds a small amount of complexity for the Flex developer since You can't attach a Sprite directly to most Flex components because all children of a Flex component must extend UIComponent. 

    There are several ways to get past this small annoyance, however. 

    First of all you should realize that you don't need to add JSViewBase to the the Display List in order to use it. JSViewBase is Just a mediator between your Model / Controller and a group of one or more components. It is meant to handle communication between other pieces of the MVC framework. This allows you to build components which don't have any code that is JumpShip Framework specific and wrap them in a JSViewBase instance which takes care of all of the interaction within JumpShip.

    You can create and use JSViewBase just as if it didn't extent Sprite by creating a new instance but not bothering to attach it to the display list. In this case the only thing you loose is the ability to use add components directly to JSViewBase and have them show up on the display list. Instead you would use JSViewBase to store references to it's components which would sit somewhere on the display list. An example of this is provided along with this post.

    Included is a demo Flex project that uses the JSViewBase as a mediator for the Flex compnents contained in the main application.

    Another way to use JSViewBase would be to wrap the class in a proxy component that extends UIComponent. The JSViewBase proxy would just pass all references straight to the JSViewBase instance and the rest of the JumpShip Framework would not know the difference. An example of a JSViewBase proxy class is provided as part of this post.

    A third solution is just to give up the utility function that JSViewBase provides and simply create a new Flex component that implements IView. Although you would loose some of the nicer things that JSViewBase provides, you may decide that those features aren't particularly useful to you anyway. Or you could implement a subset of the JSViewBase functionality in your new component. But as long as your component implements IView, it is capable of fully participating in the JumpShip Framework. Note that IView doesn't require that your implementation be a DisplayObject at all.

    Most MVC frameworks don't even attempt to provide a standard View implementation because as this article illustrates, it can be tricky to implement a View class flexible enough for everyone to use. But JumpShip attempts to go where other frameworks do not, realizing that there is value to establishing conventions even if those conventions get away on rare occasion. But I hope this article illustrates that what may seem like a barrier, really is no big deal when you understand the broader intentions of the JumpShip Framework.

All files can be found at: http://www.youbits.com/jumpship/FlexAndJumpShip.zip for your convenience the entire JumpShip Framework is also included.

Monday, June 16, 2008

JumpShip 3.2 Update Released.

JumpShip 3.2 Update Released.

This minor update of the JumpShip Framework fixes bugs in the JSDataModel and JSViewBase classes.

JumpShip Framework An MVC Based ActionScript with the following features:

  • A Ruby on Rails like Data Mode
  • A Command Pattern Based Controller (similar to ARP and Cairngorm
  • A standardized View with asset loading tools.
  • Model / View Data Binding
  • Controller Before / After filtering
  • Controller Command Cascading (the ability for commands to call other commands).

The following bugs have been fixed:
  • JSDataModel: Fixed a bug in the ‘getItemIndex()’ method that returned an improper value.
  • JSViewBase: Fixed a scope issue that prevented proper data binding.

Wednesday, May 21, 2008

Awesomeness with JSEnumerable and JSArrayEnumerable

JSEnumerable and JSArrayEnumerable are included in the core JumpShip library but are powerful classes in their own right and can even be used outside of the JumpShip Framework.

The enumerable classes provide standard methods for traversing and manipulating collections of data. The methods they define are meant to mirror standard Enumerable modules in other programing languages like Ruby. A lot of the time one of the more tedious tasks of managing data is the need to iterate over the entire data set to find the specific piece of data you need to retrieve or perform a transformation on.

The two enumerable classes in JumpShip each provide the same functionality but in two different ways. JSEnumerable is a class that can be extended by your data model so that it inherits all of the enumerable functionality. JSArrayEnumerable is a static class that manipulates the prototype of the standard Array class so that all Arrays in your app gain the enumerable functionality. Even though prototype manipulation has become a frowned upon practice in AS3, the Array is the most often used class for enumeration. If you want to make extensive use of the enumerable methods, using JSArrayEnumerable can save you a lot of work by simply allowing you to use Array objects throughout your application instead of sub-classes of JSEnumerable. Either way is fine, however, and will allow you to take full advantage of the enumerable methods to do some great tricks with your data. Let's see some examples.

Let's start with some dummy data. We're using JSDataModel as our data collection. It extends JSEnumerable:

var test = new JSDataModel();

var rec1:JSDataRecord = new JSDataRecord();
var rec2:JSDataRecord = new JSDataRecord();
var rec3:JSDataRecord = new JSDataRecord();
var rec4:JSDataRecord = new JSDataRecord();

rec1.create({firstname:"joe", lastname:"smith", purchases:10});
rec2.create({firstname:"jamie", lastname:"doe", purchases:1});
rec3.create({firstname:"jamie", lastname:"scanlon", purchases:50});
rec4.create({firstname:"mickey", lastname:"mouse", purchases:16});

test.addItem(rec1);
test.addItem(rec2);
test.addItem(rec3);
test.addItem(rec4);

Let's also turn on the JSArrayEnumerable class to make all Array objects enumerable:

JSArrayEnumerable.enable = true;

Now the fun part. Let's say we want a way to quickly compile a list of all of the last names in our data set.

var names:Array = test.pluck("lastname"); // smith,doe,scanlon,mouse

The 'pluck' method pulls out a filed from the records in the collection and presents it as an Array. If you were to think of the data in the form of a table, pluck returns a column. In this case we pluck the 'lastname' column. Now lets say we want to only pull out the last names that contain the letter 's'.

var sortedNames:Array = names.grep( /s/, function(item, index) {
return item;
}); // smith,scanlon,mouse

Notice that we have called the 'grep' method on the 'names' variable which is an Array. Since we have enabled JSArrayEnumerable, all Array's now have this method. If we hadn't enabled JSArrayEnumerable, this would throw a compile error. The 'grep' method is one of the most powerful. It lets you use a RegExp ( Regular Expression ) to filter which records to return in the form of an Array. The capability to filter the records in your data set is only limited by your ability to create a good Regular Expression. The 'grep' method calls toString() on each item in the data set so it is also valuable to make sure that you implement a meaningful toString() method if you are working with complex datatypes, ( here we are only dealing with Strings and Numbers so this isn't an issue ). 

Hopefully you can begin to see the power of using the enumerable classes. We just performed two operations that would normally require a loop and at least one 'if' statement. Here's another example. Let's say we want to get a running total of all customer purchases.

var total:Number = 0;
total = test.inject(total, function(memo, item, index) {
return Number(memo) + Number(item.purchases);
}); // 77

The 'inject' method allows you to specify a variable ( in this case a Number ) that will be submitted to a function for each item in the data set. The function also gets the item in the data set and the index. Whatever is returned by the function is submitted to the next item in the data set. This is a great way to apply a recursive function to every item in the data set. In this case, we use it to tally the values of the 'purchases' field.

JumpShip, an AS3 MVC Framework for Flex and Flash, has been updated.

JumpShip, an AS3 MVC Framework for Flex and Flash, has been updated.

This update features the following changes:
  • Addition of a new core class JSArrayEnumerable which adds Enumerable methods to Array objects.
  • Minor bug fixes for JSDataRecord.

Thursday, April 10, 2008

JumpShip mxmlc Compiler Bug

An email from a member of the community pointed out that certain JumpShip Framework's JSEnumerabler Class and it's descending JSDataModel Class might cause errors due to a compiler bug which is documented here:


It is a bug that has been fixed as of Flex 3.

Wednesday, April 9, 2008

I've ditched my site and turned it into a Flash blog.

I've decided to ditch my two year old web desing site in favor of a Flash blog. http://www.jsjstudios.com.

There you will find articles related to Flash / Flex but not Jumpship specific. There is a lot of great content there already, hope you enjoy it.

Jamie

Thursday, March 6, 2008

JumpShip Has Buzz




I've been monitoring traffic for a little while now but ever since I announced the release of JumpShip 3.0, interests seems to have spiked. So thanks to all who are reading, we are now 63 countries strong!

Jamie

Sunday, March 2, 2008

JumpShip 3.0 is Here!!

JumpShip 3.0 has been released.

www.osflash.org/projects/jumpship

Release Notes:

The main goal of this version of JumpShip has been to lower the barrier to entry both in the learning curve, and in the time it takes to get an application up and running.

Former versions of the JumpShip Framework required you to extend base classes to get even the simplest application working. In JumpShip 3.0, the base classes are still there but they are fully implemented. JumpShip 3.0 lets you extend the framework one piece at a time, leaving the rest to perform in a minimal way. In this way you can get an application up and running almost instantly. Using an agile programming style, you can add and change functionality as you need it.

In order to lower the learning curve, JumpShip 3.0 has come more in line with the way other popular MVC frameworks work. Although JumpShip still takes the unique point of view that it is easier to work with a framework that sets reasonable conventions rather than try to be everything to all people, JumpShip 3.0 brings these conventions more in line with other frameworks like Cairngorm, PureMVC and ARP. The goal was to make the concepts familiar to those who have used other frameworks while still providing all of the great tools that JumpShip is known for.

JumpShip 3.0 has also made significant improvements to the Ruby on Rails Gateway. The new JSRailsGateway takes advantage of the RESTful scaffolding that is standard in the latest version of Rails. The Gateway talks directly to you Rails models, eliminating the need for a Gateway on the Rails side to capture, translate, and send data from Flash to Rails.

So to put it simply, JumpShip 3.0 can preform standard Create, Read, Update, and Delete operations on a standard Ruby on Rails back end with no extra sever-side code. The JumpShip Rails Gateway works with the JumpShip Data Model (JSDataModel) so everything sent and received through the Gateway is understood by the rest of your JumpShip application.

Take a look in the examples folder in the rails package and see how to put together a simple database driven address book in minutes.

Enjoy!

Jamie

Monday, January 7, 2008

The next release of JumpShip is going to sport some pretty heavy architectural changes in order to bring it more in line with what seems to be developing as a standard way of implementing MVC. The reason for the changes are two-fold.

First, I think it's important to simplify the framework in order to encourage new developers to use it. And letting developers use the same basic approach with JumpShip as they may have encountered in other frameworks like Cairngorm or PureMVC is something I would put under the category of simplification.

Second, lazyness mainly. It will be easier to maintain the framework if JumpShip barrows as much as it can from all the other work being done in this space. Many other people have much stronger opinions on how best to implement MVC than I do.

My main goal has always been to lower the learning curve by taking lessons from folks outside of Flash or Java. Folks who are less interested in design pattern theory and are more interested in getting things done correctly, fast, and without thinking about too much.

JumpShip is more focused on the more practical side of development. Respectful of standards and best practices but not afraid to lay down some conventions that make development with the framework take less thought.

Ultimately I don't want the way JumpShip implements MVC to be a barrier, and in fact I'd like to get to the point where it's almost invisible to the developer who just wants to get their app up and running.

Jamie Scanlon