I thought I'd share a discussion we had on Matrices as it demonstrates some
problems in deciding how to do things 'the FlexJS way'.

We needed a TransformBead which uses a matrix as its model. We started out
by implementing the original AS3 matrix, which has members a, b, c, d, tx,
ty and a bunch of utility methods (copyColumnFrom, copyRowTo, rotate, etc.).
The utility methods seemed like clutter for most cases so in keeping with
PAYG we derived an interface that includes that mostly included access
methods to the members (get a, set a, get b, etc.) Now we had the option of
using more lightweight matrix when the utility methods were not necessary.
TransformBead relied on IMatrix implementors, which could be lightweight or
rich with convenience methods.

This sounds like 'the FlexJS way' but we ditched it for the following
considerations:

1) Method calls in JS are slower than direct access of properties. Forcing
models to implement methods rules out using a faster object.

2) The supposedly heavyweight model that is rich with convenience methods
doesn't actually result in heavy instances. The methods are all stored once
on the prototype and not duplicated per instance. So using the 'lightweight'
model doesn't really make the difference one might hope it would.

3) Removing the convenience methods from the main model opens up the
question of where they should be placed instead. An initial thought is to
implement them on different TransformBeads which require them (e.g.
RotateBead would have a matrixRotate() method), but that's not easily
reusable code. It seems to make sense to allow model manipulations to be
done on the model.

The main downside I see to the approach we took is that the application size
is unnecessarily bloated. If someone just needs a simple translation
transformation s/he will be confused and perhaps annoyed to see that the JS
code contains all sorts of methods that seem irrelevant. Also, we don't want
FlexJS mobile apps gaining a reputation of being device memory hoggers. 

So I'm still not decided on this. Any thoughts?



--
View this message in context: 
http://apache-flex-development.2333347.n4.nabble.com/FlexJS-Interfaces-Pay-as-You-Go-Performance-tp54380.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Reply via email to