Showing posts with label AIR. Show all posts
Showing posts with label AIR. Show all posts

Tuesday, 20 October 2009

robotLegs meets as3-signals?

The flash event model is a bit... sucky.

Robert Penner wrote these 3 blog posts which summarise the limitations:

He's been working on an alternative known as as3-signals, which you'll find on git-hub.

Essentially signals seem to provide the following enhancements: (correct me if I'm wrong here)
  1. A type based rather than string based registration for an event.
  2. Compile time checking that you only register for relevant signals. If SomeClass doesn't have a .clicked signal then you won't be able to listen for it.
  3. Centralised and handy functions for removing all listeners from an event.
  4. The ability to add a listener for one time only (and have it automatically removed).
  5. Useful runtime errors (if you use 'addOnce' after you've already used 'add' or the reverse you get a sensible error).
  6. The option to prioritise listeners - enforcing a calling order.
I'm currently working on this modularised rebuild of an existing piece of complex software. Inter-module communication is the thing I'm thinking about most.

I've also been checking out the interesting stuff over at robotlegs - a DI driven framework which looks light and really focussed... except that Flash CS4 won't let you use the metadata required, so it seems to be Flex only for now.

However, it has a nice command and event mapping model - allowing for type checking, 'one shot only' and so on.

So... I'm considering the benefits of a hybrid. Of creating a command mapped version of as3-signals.

Questions:
1) How to replicate the nice compile time checking that Signals provides while also supporting the decoupling of the modules via the centralised command map - so you can't register for an event that will never exist.

2) Where to put the events? Which package? Do they need to reside in a centralised area?

3) Is this a complete waste of time? Does the command map already provide sufficient decoupling? Should I simply use signals within a module and the command map between modules?

4) Could a module create a new signal 'channel' dynamically, or does that make no sense at all?

Questions... questions...

Wednesday, 16 September 2009

A framework for Modular AIR Applications

I've finished building a framework for securely loading signed, packaged swfs into the application sandbox at runtime, while leaving others in the non-application sandbox and rejecting modules without matched signatures.


The framework fairly neatly packages the whole process.

The origin of the signature testing process is the Adobe article here, where you can also download a compiled code swc of the necessary flex-only classes if you're working in Flash.

The air application I've built as proof-of-principle achieves the following:
  • Modules with matching signatures are loaded to the app sandbox (if requested).
  • Modules without matching signatures requesting app sandbox loading are rejected.
  • Modules can also be loaded to the non-application sandbox.

It demonstrates:
  • That app sandbox loaded modules can write to the file system (they put a directory on your desktop).
  • That non-app sandbox loaded modules are prevented from writing to the file system.
  • That both app and non-app sandbox loaded modules can pass library assets to the main application to be added to the display list.

It has a lot of user feedback / developer feedback built in. In the absence of the ability to trace in the air application itself I'm listening for this feedback and displaying it in a textarea in the main application.

Currently the information about what to load and how to load it, and where to find the .zip assets on a server to install modules, is all contained in moduleData.xml inside the applicationFlasAndCode folder. When you start the application you must browse to this file.

To use the framework:
  1. Use ModuleXMLLoader to load an xml document containing your module information.
  2. This creates a strongly typed iterator: ModuleDescriptionIterator.
  3. Instantiate ModuleChainLoader, passing it that iterator.
  4. Listen for the ModuleEvent.MODULE_LOADING_COMPLETE event.
  5. Ask the moduleChainLoader to startLoadingModules().
  6. When you handle the loading complete event, run getModuleDictionary().
  7. Access your modules from the ModuleDictionary using getModule() and getSandboxedModule(). You pass the module's unique name to those functions. They pass back the required module.

Any questions at all, post them here or email me.


How secure is secure?

I'm building an enterprise training application. It already exists in AIR, but we're moving to a modular system because our users don't have the permissions required to run the automatic updates.

Secure, for me, is secure enough not to be the preferred target for a malicious attack. Nothing is impossible, but I want to make it sufficiently difficult / tedious that anyone intending to cause trouble looks elsewhere to do it.


Notes:

In my own final application the xml will be a secure data stream coming from a server.

If you want to keep my xml structure you can use the ModuleXMLLoader class as is, but I've kept it as a separate stage in the process so that you can make changes to this.


Some possible gotchas to avoid:
  • The example module flas have classes which extend ITestableModule. You'll need to point flash to the com folder in order for this interface to be found.
  • Remember that flash keeps signing with the last certificate you used. So when creating good and bad modules, and compiling the app itself, keep an eye on which certificate you're using.
  • Module .air packages need to be renamed .zip
  • You cannot test secure loading in the flash test player. You have to create the application .air file, install it and run it to test it.
  • Don't forget to grab that SignatureUtils.swc from the Adobe link.

Tuesday, 1 September 2009

Creating modular applications in Adobe AIR

Identity is on hold at the moment, work still being too hectic. I'm hoping to really get down to it next year - I've got 3 O'Reilly books on the way out by March next year, and they're eating all my time.

In the meantime, the main work project I've got going on is a nice fit with what Identity needs to achieve in terms of modularity. It's an e-learning app, already running successfully as an Air application, but we're rebuilding it to achieve the following:

1) Dynamically built modular environment. Other than the AIR shell itself, all the functionality will be loaded by the app at runtime. This allows for non-admin updates, and for user A and user B to have different logging systems / quiz engine etc.

2) Reskinned at runtime. Different departments and sub companies of the corporate client can have a different look and feel, maybe even a different screen size requirement.

I've already grappled with the Air security sandbox stuff within this app. The lessons themselves are dynamically loaded and using sandbox bridge for communication. The current quiz apps are also decoupled, and only simple data is passing around - mostly I'm using strings of xml for more structured data requirements.

I've been playing with the two variations of loading content into flash:

A) The light side: use a normal loader, put your downloaded content into a sandbox where it can only access other content via the safe and secure bridge.

B) The dark side: read the file into a ByteArray and use loadBytes() with allowLoadBytesCodeExecution = true on the loader context, to give your loaded content the run of the place... including the fileSystem.

The pros and cons of breaking the Air security model

The light side:

Events
Events must be passed using loaderInfo.sharedEvents. Only built-in events keep their type, but that's ok. The actual Event.type property is just a plain string anyway, so you can still make use of a custom event for compile time checking to avoid typos, as the Air shell doesn't care that it didn't know what MyCustomEvent.DOG_BARKED was - it just sees "dogBarked". On the down side you can't pass useful extra data with your custom events.

Security
You can use sensible functions like storeAsset(assetPath:String) to pull in things and read / write to the file system, rather than opening up your user's computer for an attack by rogue dynamically loaded modules.

Loading grandchildren
Loading a grandchild asset such as a png or jpg seems to be possible using loadBytes() with code execution set to false. You have to pass the byteArray as a normal array, reconstruct it to be a byteArray, and then load the content in the child module. I've only part tested this. More to follow. And it's pretty gross as a process.

Decoupling logic and events is ok
Modularising the logic of the application doesn't actually seem to be too hard. The code was pretty nicely decoupled already, and we think we can reduce inter-module communication to a combination of vanilla events and xml (passed as string). We'd use the Air shell as a postman to deliver messages from one module to another. There would be an unnerving amount of dynamic stuff which isn't checkable at compile time, but it's doable.

Major hurdle: providing skin assets at runtime
I simply can't find any way to load the actual graphics for the modules at runtime. All I want is to load a specific (dynamically selected) swf with a bunch of MCs in the library, and to be able to do stuff like "new LoginButtonUpSkin()" and whack the requested graphic into the right place. I guess we could export all of our graphics as pngs and use the loadBytes() trick to feed them to the individual modules, but how grim is that?

The other option would be to compile variations on the modules themselves, with different look and feel. "MainMenuGreen.swf" "MainMenuBlue.swf". That feels like a huge pain in the ass when it comes to creating new skins. The designers would need access to the code library, they always ring me up wondering how to link their files to the com folder... you can see the potential headaches I'm sure...

The dark side:

Events: Module to module event traffic is possible. Events don't lose their typing when passing from module to module.

Security: This is dangerous stuff. But all my modules are coming from a trusted server and there's a technique for verifying signatures. Basically any module that wants to be loaded into the application sandbox using the loadBytes() method would have to be an Air app in itself. Then that air package gets loaded and ripped open, the signature verified and the module loaded or rejected. I've no doubt that it's not failsafe.

Will adobe continue to provide this work-around?
The adobe official documentation on working securely with untrusted content end with the following fear-inducing statement:

Note: In a future release of Adobe AIR, this API may change. When that occurs, you may need to recompile content that uses theallowLoadBytesCodeExecution property of the LoaderContext class.

A future release WHEN? What? And will I need to recompile content even if it's happily running. Will Air 2.0 break my 1.5 application if I've used this? Presumably Adobe would provide a better work around for achieving this, but my client doesn't want to do a thousand admin-requiring reinstalls... which is why we're going to use a module based system in the first place...

At the moment I'm still testing, still lurching from favouring one side to the other. More to follow as it unfolds. Hopefully I can save someone the three days of googling and testing I've just been through.

Thursday, 29 May 2008

Snapshots


Last week I was doing UML diagrams for a colleague to use in building his part of a large application. It occurred to me that the information he actually needed was quite a lot less than what was on the diagram, but as we were doing some test led development, and the model was continuously evolving to reflect the results of our tests, it was too annoying (and unreliable) to have two separate versions of the model to update.

I think the answer to this problem would be for each Identity Project to be able to have multiple 'Snapshots' - as roughly visualised in the pic above. In different Snapshots the state (CRC / Full class element / Collapsed class element) of each element could be different, but making a change to the model would update it overall, and the changes would be reflected in each snapshot. 

I've also been thinking about 'visibility filters' for the snapshots. Being able to toggle on and off all public / private / protected / package attributes and operations in the whole diagram would be useful too - I often find myself running 2 copies of a model, one with the entire structure and one to give to a collaborator which only includes the public stuff.

Apologies if this stuff is already present in existing UML tools - at the moment I've decided to not do any research into what's already out there until the first draft of the Identity spec is written up. At that point I think it'd be useful to compare what we've come up with to what's already available, but I'm trying to keep my thinking coming from 'what do we want this to do?' at the moment rather than 'what do other tools do?', knowing that we can pick the status quo up later.

Friday, 23 May 2008

Google code sign-up info

Join the Identity Modeller project at Google Code here.

I've also resolved the single-core / multi-core puzzle I think.  A multi-core version of PureMVC is going to be appropriate for a modules based application whether the app has one or many project windows.

Each module can run its own mini-version of the PureMVC framework.

The recommended strategy for modular PureMVC - presenting an interface to the module - is the only option available within the AIR security model anyway, so the multiCore AS3 port of PureMVC looks like a perfect fit.

I'm hoping that we can develop some of our functionality as PureMVC plug-ins.  For example - stuff around history / undo / redo across different modules is going to be a fairly generic solution. The saving of application state (something I love love love about Coda) so that when you start up next time it's just as you left it is also a framework solution that might be of use to other PureMVC users.

I've been thinking about the roadmap and time frame. A couple of people who have expressed interest in being involved are just hitting an intense period of exams and thesis submissions for the next month or so. I think that's potentially a good thing - I believe it takes a while for an idea as complex as this to settle and emerge. My objective then is to remain in planning until the end of June, and work towards a more and more precise definition of the project in that time.

Work begins in earnest at the beginning of July. I'd very much like to get to Alpha in October / November and release the first Beta in time for christmas. Wouldn't that be nice?

Wednesday, 21 May 2008

PureMVC, and the MDI / TDI quandry.

CarnageBlood recommended I check out PureMVC as a framework, and I'm really grateful for the suggestion because it looks excellent.

I have no doubt that using PureMVC is a good move - it's opensource and we can develop any generically useful extensions as plug ins that will be useful to other PureMVC users.  

The big question I have is single-core or multi-core?  How do these relate to interface possibilities?

My favourite applications appear to be a hybrid of TDI and MDI.  Coda is an amazing one-window-web-development tool that has tabbed browsing of files open in each window - one window referring to a 'site'.  Having multiple windows open means I can entirely separate my work by project / client / server.  I love it.  Each window has its own interface - file browser, search tool, activity etc.  A couple of windows - such as 'clips' - a code snippets tool - are shared across the app as floating panels.

Omnigraffle 5 works in a very similar way. Lots of the interface is wrapped directly around the document, but formatting panels etc are floating shared windows.

I've done plenty of standard MVC development but never a multi-core app.  I'm not even sure that what I'm describing is truely multicore?  Whilst there would be many models, views and controllers, the actual basis of the application is perhaps still a single core?

More reading to be done - and possibly the best way forward is to plan version 1 as single window (apart from interface floaters) tabbed documents style, with the multiple project windows version as a major update.

Tuesday, 20 May 2008

Identity modeller roadmap

If you build it, they will come ... 

That's my mantra at the moment anyway. At times I wonder whether I'll get enough active contribution to this project to make it worth doing open source ... and then I tell myself to shut up, because open source is something I believe in.  Wikinomics, etc.

I have a genuine passion about this project. I guess it's my old production engineer background coming out - I want to fix the process, regardless of the product. In the last year or so I've begun to feel incredibly frustrated by a lot of the work I do, by the sheer pointlessness of it to be honest.  But I still have friends who do OO coding who don't feel able to use UML, or CRC, and I still find I'm having to talk myself into doing it sometimes, and I know that if I had the tool that Identity aims to become I would be a much better coder and technical manager. I know that sharing good code would be easier for starters.

I'm fortunate to be involved in a couple of really, genuinely worthwhile projects - the biggest of which is a training application that runs in AIR. Apart from a really good usable GUI, the AIR-ness means that this app can manage its own updates in a wonderfully smooth way, something which has allowed us to get it out to users much earlier in the process than with a conventional app, where releasing updates might be problematic.  We can get a bug report from the client, engineer a fix and release the new update to all users within hours.

Based on that experience, the Identity modeller roadmap aims to release as early as possible. I'm also a fan of getting the risky bits out of the way as early as you can, so we start up with the data side, and work towards graphics at the end. To begin with it won't be pretty, but it will be working.


I've no idea what the timeframe is, which will depend partly on how many people get involved and how their schedules are playing out. If you want to have input into the big picture, in particular the scope of the model and the way data is saved, speak up now.  Thanks to all those already chipping in on email and chat!

If you're not able to contribute in terms of coding or design but would like to do unit testing or alpha / beta testing I'm already taking names for those ... don't be shy.

Saturday, 17 May 2008

Identity modeller overview documents


I've gathered together some of the thinking and ideas I've been bouncing around with Jeroen and Weyert, and chucked everything into a 7 page friendly pdf : download it here (1.6MB).

As always, feedback, input, thoughts etc are all very much welcome.

I've also been looking at alternatives to osFlash as they're closed to new submissions it seems.  I think probably Google Code is the right choice - if anyone has direct experience of using it please let me know what you'd advise.

I think the next step is a road map of proof-of-principle steps.  And later, identifying the bridge API requirements for the various plug-ins and components will be a big exercise - so the more brains the merrier!

Wednesday, 7 May 2008

Interested in testing or influencing development?

There are a few different ways in which you could get involved in this project if you're interested.

The easiest is just by reading this blog and chipping in with a few comments here and there.

I'm also going to build some mailing lists, so please drop me an email if you'd like to get involved in any of the following ways:

  • Top level design team - reading through the specification for the app, contributing brain power to solving the big problems and specifying unit tests.
  • Coding team - writing classes to unit test for the main app.
  • Plug-in team - creating swfs to add functionality using the plug-in APIs.
  • Graphic design team - determining how this thing should look.
  • Language team - drawing up xml files for AS3 / AS2 etc.
  • Unit-testing team - testing parts of the app (obviously we'll do as much as possible with automated unit tests, but sometimes you really do need a human to bash things!)
  • Alpha-testing team - testing the first usable release of the app.
  • Beta-testing team - does what it says on the tin.

I know this kind of project is potentially a bit daunting, but if you feel like there is a particular task that you'd be interested in, let me know.  Maybe you've already got some experience that might be useful - perhaps you're a regex junkie who'd relish the prospect of churning through AS3 files to strip out the data required for reverse generation of models?  Or perhaps you're just really good at breaking stuff, and would be an ideal candidate for the unit-testing team :)

Maybe you're up to your neck in actual work but would like to read through the proposals to make sure we're building something that meets your needs as well as our own?

Don't be shy ...


[edit : It's been suggested that we put the project up on osflash.org - a really good idea, but when I tried to do it I found that the sign up page has the following message : 

New project signups are currently on hold as we transition to an automatic system. The old manual system just isn’t working out as neither John nor I (Aral) have time to go through the submissions and that’s not fair for you guys. 

If anyone has another suggestion please let me know, otherwise I'll stick to the blog for now and set up a svn repository as soon as it's going to be useful. ]

Combining MVC with the AIR sandbox


Identity seems to be an ideal candidate for the Model-View-Controller design pattern.

I recently converted a large application into an Air app and had to grapple with the differences in how loaded content can access the loader Air file.

There are lengthy and comprehensive white-papers available from Adobe, and they do explain the new model very comprehensively, but I feel quite strongly that the 'What's new in AIR?' overview stuff for flash developers should have had the following simple point:

In order for a loaded swf to be able to communicate with the parent AIR file you must create an API class with public functions within the AIR application and assign this to the loaded swf as a bridge.  The only data which can pass between the parent AIR file and the loaded swf is simple type data : Number, String, Boolean. You cannot pass complex typed data between a loaded swf and a parent AIR file.

The implementation of this into our application was initially a bit painful.  The application is a training environment.  The main AIR app loads external swfs of individual lessons and quizzes. The app GUI has all the interface and the loaded swfs basically only contain a timeline with a voice over and animations and a small amount of functionality.  There is quite a lot of communication between the two however - with the loaded swf prompting the GUI to update all sorts of things - messages on screen, navigation state, icons indicating the availability of other resources.

We had previously achieved a lot of decoupling by using events.  In the new model it was no longer possible for a typed object, such as an event, to pass between the swf and the AIR app. Of course it took a whole bunch of testing and digging through various white-papers to realise that this was the issue ... but we got there in the end.

The result is an even more cleanly decoupled app, with less requirement for the animators to put code into their lessons, and the AIR app is at far less risk of being broken by anything they do.  At the moment there is a small loss in compile-time error checking, though I suppose we could define constants within the local lesson to get back what we had with the events.

So - I am thinking about what the AIR security sandbox will mean for Identity.

It makes sense to have a number of the core functions held in separately compiled swfs, so that they can be extended / swapped easily.  This also gives a lot of protection to the core application as it means that only expected data can pass through.  We can check and place limits on this data before it is used within the app.  Lovely.

For example - the ECMAScript-based parser should be able to handle AS2, AS3, AS4 and probably PHP5 and 6, but I haven't a clue what other languages people might find this useful for.  The logic for creating / stripping an AS3 file is quite clear to me - you need a file that defines how a class is built and then you do some regexy things and some iteration through the properties and functions.  How universal that logic is I don't know.  How much customisation you can do without editing the parser, I don't know.  How much benefit coders might get out of editing the parser to suit a specific need, I don't know.  So - if the parser is an externally loaded swf then you can select a parser to use and introduce a layer of flexibility.  You can even build your own.  People can experiment easily with their parser and make public 'improved' ones maybe.  

[I'd love to see a parser that simultaneously builds your asDoc html, for example ... not sure how this would be possible right now, but it doesn't feel completely unrealistic, if the parser simply called file writing functionality within the API].

You can assign a specific API to each loaded swf, but you can only assign one.  So, that API needs to deal with all relevant aspects of Model, View and Controller in one class, though of course it's just a gateway through which simple-typed data passes.

Application-sandbox loaded components do have a lot more potential for interaction with the parent AIR app, but I think the outside-the-app model offers a much more secure and controlled environment for plug-ins, so this seems like the best route.  Identifying the kinds of functionality each of the plug-in API classes needs to have is a pretty big task in itself ... doing the planning for this project is making me more certain that I need this piece of software though!

(For mac users, if you don't already have it then you should check out Omnigraffle Pro 5 - the best piece of software I've ever used just got a whole load better.)

Monday, 5 May 2008

Project language spaces & class interchange

I'm definitely hooked on the idea of being able to model once and export stub code in multiple languages.

The potential benefits in terms of providing shared 'Class swatches' are pretty attractive.  

So far what I'm imagining is that when you start a new project you select a language space for that project.  You would then be able to drag previously defined classes from a classes swatch thingy (best to be specific about the lack of definition here!) into that project - and the app would translate unsupported types according to the type mapping spec for that language. Swatch classes would only be able to be edited within the language space they were defined in - so you couldn't start adding MovieClip types to a class which you've created in ECMAScript.

You would also be able to create a new class 'based on' an existing class in your class swatches - this would import the class types into your project language and allow editing within that language.

Making sense?

Introducing identity modeller

Dauntless pointed out on email that I can't keep calling it "Air UML tool thing" ... and I thought coming up with a half-decent name would take ages, but here I am already, introducing Identity modeller.  Whadya think?

I wanted it to convey the fact that the code and the model are intended to stay in step with each other ... and 'congruent' isn't exactly catchy.

Plus, like all good math-geeks, I'm a long term fan of Euler. Couldn't resist ... sorry!


Sunday, 4 May 2008

Air UML Tool : File formats and more on typing

I've been trying to wrap my head around the xmi specification for describing UML models using xml.  The purpose of the spec is obviously to allow models to be imported / exported and switched between different UML tools.

It has given me a focus for the core functionality of the application - to be able to read and write both xmi models and language specific class files.  The application would then also have the ability to write extended xmi files, containing the compliant xmi model stuff but also the project data relating to everything else - non uml stuff to do with getter/setters, positioning, etc etc. 

The language specific element will be provided by external xml configs - one to describe how a class file is structured, and one to map generic types to language specific types.

I've been having a bit of useful exchange with Dauntless on the types issue.  The thinking I have at the moment is that some classes are clearly language specific - anything using or extending MovieClip for example is only useful in Actionscript - whilst other classes might be much more generic, in which case it would be nice to be able to move them across different language projects.  I have a few utility type classes which I use in both AS3 and php5.  

The most basic type set is that provided by UML itself: boolean, integer, float and string.

Then there is the set provided by ECMAScript 4 - discussed in the previous post.

As Dauntless pointed out, Java has useful stuff like Enum. 

I think I've almost reached a clear enough understanding of the multiple-languages issues to be able to post more detail of that tomorrow.

As always - the more the merrier - please chip in if you're interested in contributing.

Meantime - if anyone can think of a good name for this baby ... Dauntless has rightly pointed out that AIR UML Tool is getting a bit dull ...!

Friday, 2 May 2008

AIR UML tool : Working with types across different languages

One of the most obvious changes when switching between AS2 and AS3 is the difference in built-in types.

I'm talking Number vs int / uint. Void vs void.

From time to time I plan something that I want to execute in more than one language - in php5 or Actionscript 3 ... I've been fortunate to be able to leave AS2 behind but I know a lot of people are working on legacy projects.

With Colin Moock already talking about Actionscript 4, the focus for future-proofing seems to be on ECMAScript 4.

The release data for the new spec isn't til December 2008, but I'm guessing the end of the year will be upon us in no time.

Reading through the ECMAScript 4 Overview, it's struck me that building with this spec in mind will force us to include the kind of flexibility that will make it easier to extend this app to other languages.

For example - some of the Number types proposed - byte, int, uint, double and decimal - may not make it into the final spec, and we may continue to have the current AS3 set: int, uint and Number.

If each language contains a type mapping spec for the core types then AS3 can map byte, double and decimal to Number, and if AS4 supports them then they can be supported.

eg:

translations/as2/typeMapping.xml :


<typeMapping>
<type_byte>Number</type_byte>
<type_int>int</type_int>
<type_uint>uint</type_uint>
<type_double>double</type_double>
<type_decimal>decimal</type_decimal>
<type_Number>Number</type_Number>
</typeMapping>



translations/as3/typeMapping.xml :


<typeMapping>
<type_byte>uint</type_byte>
<type_int>int</type_int>
<type_uint>uint</type_uint>
<type_double>Number</type_double>
<type_decimal>Number</type_decimal>
<type_Number>Number</type_Number>
</typeMapping>



translations/as4/typeMapping.xml :


<typeMapping>
<type_byte>byte</type_byte>
<type_int>int</type_int>
<type_uint>uint</type_uint>
<type_double>double</type_double>
<type_decimal>decimal</type_decimal>
<type_Number>Number</type_Number>
</typeMapping>


So far, the types I can identify in the ECMAScript 4 list are:
null, undefined, void

Object

Number, byte, int, uint, double, decimal

Boolean, boolean

String, string

Array

Vector (a strictly typed array?)

Function

Map (binary relations)

Date

RegExp

Name, Namespace, NamespaceSet, NamespaceSetList

Error, EncodingError, EvalError, RangeError, ReferenceError, SyntaxError, TypeError, UndefinedError, URIError

AnyString = (string,String)
AnyBoolean = (boolean,Boolean)
AnyNumber = (byte,int,uint,double,decimal,Number)
FloatNumber = (double,decimal)

XML, XMLList, AttributeName, AnyName

IterableType, IteratorType


I've also spotted a few more in the documentation - FieldIterator and ControlInspector perhaps?

Either way - this strategy allows us to be highly specific in our documentation, and then water that precision down for each language. Of course, coming back the other way it's trickier. Do we want reverse engineering to simply pick the most generic type, or do we need a special comment that can specify how types are backward translated? Something like ... (for AS3)

// *strictType:decimal //
public var salary:Number;

Obviously the app also needs to support types from your own library.

Something else I've noticed is the support for ! ? notation to specify that an object can / can't be null. Eg

// "!" indicates that v can't be assigned null
var v : MyType!

// "?" indicates that v can be assigned null
var v : MyType?

// "!" indicates that this whole class is non-nullable
class MyClass! { ...


The idea is that this will allow earlier detection of null-pointer errors - ideally at compile-time rather than run-time. That would make me very very happy!

----

It's a pain that ECMAScript 4 is still six and a bit months from completion, but I think the rigour that having to build for an almost-complete standard gives us is probably a good thing.

Thursday, 1 May 2008

AIR UML Tool : Defining the UML scope

UML 2.0 is pretty vast.

This is an attempt to summarise the parts of the UML that need to be available within the tool. My current thinking is that different languages will have an xml spec file that maps these UML Language elements to the translated element for that language.  We should begin with AS3 as a primary goal, but ensure we support parts of the UML which aren't yet available to actionscript but might be included in PHP6 or AS4.

For example - AS3 doesn't support 'private' or 'protected' on a constructor, so the AS3 xml config might map it to 'public' in this case.  AS3 also doesn't support 'abstract', so that would be skipped when constructing the stub AS3 code.  

The list below is probably incomplete but it's a really good place to begin.  Strict UML terms are given in (brackets).

Stuff
  • package
  • class
  • interface
  • property
  • function (operation)

Visibility
  • public
  • protected
  • private
  • internal (package)

Scope / implementation modifiers
  • static
  • abstract (unsupported in AS3 but we can hope and at least add to comments)
  • const (readOnly)
  • binds
  • dynamic (not sure this has a strict UML equivalent?)
  • overrides [thanks dauntless]
  • final [thanks dauntless]

Class relationships
  • extends  (generalizes)
  • implements (realizes)

Any glaring errors?  If you're out there following this and it makes sense to you please do speak up, encouragement, questions, interrogation and the pointing out of obvious fundamental flaws are all appreciated.

[edit]: Dauntless has also mentioned composition, which is definitely required within the laying out of diagrams / relationships, but doesn't really map to an AS3 file other than by declaring a property of that type - or am I missing something?  

We'll also need to represent the Aggregation / one-to-many : many-to-many : many-to-one type relationships as well, and also event listener lollipop etc, but again I don't think they map into the final exported AS3 files.

Dauntless also brought up the issue of types - something I've been thinking a lot about and hope to post some ideas for a strategy later today.

AIR UML tool : A clearer concept


To save any confusion - this is just a graphic, a jpg exported from a flash file which has absolutely no functionality and is purely intended to help rough out an interface concept.

I started thinking in more depth about what I personally needed this tool to be able to do, given that I'm pretty happy with my current working strategy but it just feels like there's a fair bit of friction in the system in terms of duplicating work.

So, I went right back to basics - my current process, which I'm sure is not unique, is to use index file cards for a fair bit of my modeling.  On one side I scribble the CRC stuff (Class Responsibilities and Collaborations).  On the other I outline the most important public properties and functions.


At a later stage I do a more formal UML diagram in Omnigraffle, using the UML-General template.  Then, once I'm satisfied that it's close enough to what I'll finally need, I create skeleton AS3 classes in Flash or Flex, and then write in skeleton asDoc comments ... both of which are rather tedious.

Inevitably the coding process throws up unforeseen stuff and functions, structure or even the whole model can be subject to changes.  Unless I am feeling particularly disciplined, many of these changes go mostly undocumented, usually only being written up if the code is then applied to a new project or handed over to a new developer.

I no longer work as part of a large team of developers, so I've only my own experience to call upon, but if there's one thing I've learned in my time as an engineer (in both the physical and the software world) it is to begin by making a product that a single concrete person needs, and not a product that doesn't actually satisfactorily meet the needs of any of a whole bunch of abstract people :)

Where I've landed is that this tool should be like a digital version of my index file card box, which integrates my workflow all the way through from creating CRCs to assembling them into a project, to defining public interfaces on the flip side, to drawing that up in a UML sketching tool, to defining private functionality, to adding comments to explain usage, to generating AS3 skeleton functions with asDoc compatible comments and getter / setter functions where desired ... it has to take care of that whole shebang.

That process has to be 2 way, preferably with 'intelligent' (the magic word for 'haven't defined the rules for this yet') syncing.

Returning to my dodgy graphic at the top - I'm no designer, so will be looking to get some major input on that side - the concept is that you have a bunch of index cards on screen, you click the little arrow in the top right corner to flip 'em round.  They expand and contract to give enough space for the properties / functions.  All the standard spec of UML 2 is available to you and they also have a neat interface (represented by the G S on the right of the properties) for requesting that Getter / Setter functions be created for those properties. 

I'm sure there will be other, sexier, less geeky skins that people want to add later but this one seems like a great one to kick off with because it focusses the mind on what we're trying to do - take the friction out of a tried-and-tested way of working, not revolutionise the whole process!

Tuesday, 8 April 2008

AIR UML thingy overview


So ... here's the overview of the project.

The green box contains the most basic possible release of the software - no real whistles and bells beyond getting something useful that we can start using / testing.

The boxes above that are the language / saved file format stuff.

The blue boxes are things for versions 2 to 100 ... 

All saved data / parameters / language specs etc will be in xml.  The entire app will be written in AS3 only - nothing specific to Flex or Flash.  No assets ... well, maybe a png library later, but it should be possible to compile the project from either an empty FLA or a simple Flex project without requiring any assets.

So - with the whole project written in pure AS3, anyone who uses the software will also be able to modify / adapt / enhance / reskin it.

In terms of UML elements, I think we should start with the most commonly used elements and then add further ones later.  

As far as interface / usability goes, my 2 favourite pieces of software are coda, by panic, and omnigraffle by omnigroup.  If we get anywhere near to something as beautifully usable as those two I'll be a very very happy bunny.

The 'class swatches' add on is something I'm kind of excited about myself.  It would allow you to have templates for classes / design patterns that you drop in and edit.  

I'll expand more on the diagram above as soon as I get a chance, and it's by no means a concrete solution, just the one that I've come to so far - all feedback / ideas gratefully received.