Feeds:
Posts
Comments

WARNING: Turns out that this is probably not as good of an idea as it first appeared to be, I’m adding some details at the bottom…

I’m working on a really cool Flex 3 project at work. One of the things we’ve done architecturally is to wrap up major portions of the server communication and business logic into manager classes (think of these as MVC controllers.) We use the IMXMLObject interface for these managers so that they can be instantiated in our main Application MXML and we pass managers to other managers explicitly rather than having components reaching up to the application to obtain these references. One of the main drivers for passing this stuff in explicitly is that we’d like the managers to be testable (with FlexUnit) without having to setup loads of application state that isn’t well defined.

Unfortunately when instantiating a class via MXML there is no way that I’m aware of to pass constructor parameters to the object. You can of course set a bunch of properties, but unfortunately there also does not appear to be a way to indicate that certain properties are required prior to a component being used (yeah I realize it’s hard to define when the component is being used.)

I’ve been noodling on this in the back of my mind for a while. Last night I did some searching and didn’t come up with anything. Then I had this idea that we could put a set of conditions into the initialized() method of these components that checks if all of the required properties have been set. If they have, all is good, if they have not, we throw an exception. Yes I know this is simple and probably obvious, but since I couldn’t find references to this after searching for some time, I figured I’d post about it.

Unfortunately this doesn’t allow us to catch a missing dependency at compile time, but the code simply won’t work if a component hasn’t had all of its required attributes set… whereas previously the component could attempt to work and fail in weird and hard to quantify ways. The other downside of this is that we have to add an explicit call to initialized() in all of our unit tests that construct these managers (or their surrogates.) But all-in-all, I feel more comfortable that someone won’t accidentally use one of these managers without first providing all of the required input properties and that even if this is done in Unit tests, the code will fail quickly with a message that will allow folks to provide the missing dependency and move on.

UPDATE:

We pass managers to each other like so: <primarymanager secondaryManager=”{secondaryManagerId}”/>. This is the only way I’m aware of passing other instances of MXML objects to each other. As I’m sure you are aware the squiggly-brace syntax is turned into binding in the background. What you may or may not know is that initialized is called before your binding expressions are initialized!

My solution to this is to throw up my hands in disgust and instantiate my manager objects in the constructor for the code-behind for our application; I can use regular constructor parameters now. I really don’t like this because the object instantiation is no-longer visible to the user working with the application MXML; i.e. they need to know about the manager instances.

What we have here is one more catch-22, can’t pass instances to properties without using binding, and binding doesn’t get called prior to initialized() being called on objects that implement IMXMLObject. I sure wish Adobe would just give us a [Requierd] annotation for properties, also wish they’d allow for parameter initialization with object instances without requiring the overhead of Binding. I only set these things once, don’t need to watch for changes, etc.

If anyone figures out an elegant solution for setting up an initialization contract for MXML components, I’d sure appreciate a comment/link.

We recently purchased a Vitamix 5200 (which is a super powerful blender) in order to help us prepare food at home more regularly. The Vitamix 5200 comes with a great ring bound recipe book that contains all sorts of things you can make:

  • Smoothies (green and otherwise)
  • Juice (a little tricky see comments further down)
  • Fresh Fruit Margaritas
  • Salsa
  • Guacamole
  • Humus
  • Soups hot (it boils liquid from room temperature in about 6 minutes with just friction) and cold
  • Sorbet/Ice-Cream
  • Nut Butter (Cashew is GRRRREEAT)
  • Nut Milk
  • Savory sauces to put on other dishes (Sour-cream/Dill for fish is wonderful)

We’ve tried variations on most of these, other things you can make (stuff we haven’t tried):

  • Scrambled Eggs (I wanted too, but sounds like nasty cleanup)
  • Salad Dressings
  • Emulsions
  • Crushed Ice
  • Chop a quarter of a cabbage for slaw in about 1 second!
  • Mayo
  • Marinades
  • Pesto
  • Butter (from heavy cream)
  • Cold compost

Seriously the list just keeps going on and on, you can checkout loads of recipe’s, video’s etc on the Vitamix website. Oh and with the exception of the Nut Butter, it’s seriously easy to clean (rinse, half fill with warm water, one drop of dish soap and blend for 15-30 seconds, then rinse again.) I’ve seen posts from others that if you leave it for even an hour or two after decanting your creation, cleaning can become seriously painful.

We’ve gone from maybe cooking at home 2 nights a week to eating out about 2 nights a week. The main thing we make is smoothies, although these vary from something approaching fresh and delicious V8 to something approaching blended tropical fruit cocktail and even mixtures of both (yes fruit and veg and even spices taste great together) so in a way it’s hard to consider all of these delicious concoctions under the one uber title of smoothie…

We make the fruit margaritas described in the getting started guide pretty regularly on a Friday evening after work. I generally am not a drinker, but this drink is to-die-for (we use a little more fruit and a little more sugar than is called for, but even the original recipe is fab.)

I’m a bit sensitive to milk so one of the things I tried the first day was to make some almond milk. The recipe from Vitamix says to load up 1 cup of chopped raw almonds and 3 cups of water and mix for about 2 minutes.. Unfortunately, this mixture had a noticeable fine grit to it (to be frank it felt a bit like drinking super fine sand paper.) I strained some through a couple of paper towels, which improved things but it was still a bit harsh and also a bit watery. After doing some research on the net and obtaining a nut milk bag (actually just a nylon bag used to filter stuff when canning) I had the most amazing second experience making alternate milk today. I put 1 cup of chopped raw almonds into our 32oz container, added 3 cups of water, a small splash of vanilla extract (most folks suggest using real vanilla, but I don’t have any) and let stand for an hour or two. Then mixed for 2 minutes, strained through nut milk bag, put back into freshly rinsed Vitamix container with a few dates and whizzed around for 30 seconds or so… Comes out warm, frothy and delicious. No more sand paper and oh my god it tastes amazing!

Unlike a juicer, the Vitamix leaves all the fiber of your ingredients in your concoction. In many cases this is great, but if you want an actual juice (orange, applet, etc) you can end up with a rather too thick liquid for some folks tastes… I rather enjoyed the orange mouse we got from whizzing up a few oranges with pith… well at least I liked the idea of it… but it was pretty weird in reality. Again after some research I discovered that the pith, while extremely good for you, can make your recipe very foamy, adding ice/water and getting rid of most of the pith helps. Today I tried straining some apple juice (was the consistency of very watery apple sauce) using the nut milk bag and got a lovely glass of regular apple juice sans thickener. Based on net searches, I believe this will also work for OJ.

Overall I’d say this little machine has proven to be a life changing force in our lives. I’m thrilled to have it and expect we’ll be using it for very many years to come (did I mention it comes with a 7 year warranty?) Yes it’s expensive and may not have quite as good technical specs as it’s main similarly priced competitor, but I believe (again based on research) that this is the finest blender you can buy. The Vitamix marketing is all focused on making delicious food rather than silly stuff like blending iPods/Golf-Clubs/etc… for some reason this makes a huge difference to me… After all, I’m looking for a blender to make tasty and simple to prepare food with!

Just posted the following bug report to the adobe bugs site.

Steps to reproduce:
Construct an XML variable with no explicit namespaces and any xml: attribute such as xml:lang or xml:id. E4X will correctly construct an implicit namespace for xml:, but will not assign the xml prefix to it, as such you end up with a default namespace which now applies to anything in your XML that doesn’t explicitly have another namespace associated with it.

Here’s a sample flex app that demonstrates the issue.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:Script>
<![CDATA[
private function init():void
{
var x:XML = <root xml:lang="en"><element/></root>
ta.text = x.toXMLString();
}
]]>
</mx:Script>
<mx:TextArea id="ta" width="100%" height="100%"/>
</mx:Application>

Actual Results:

<root lang="en" xmlns="http://www.w3.org/XML/1998/namespace">
<element/>
</root>

Notice that the root and element elements now incorrectly exist in the http://www.w3.org/XML/1998/namespace namespace.

Expected Results:

<root someprefix:lang="en" xmlns:someprefix="http://www.w3.org/XML/1998/namespace">
<element/>
</root>

Where someprefix is probably xml…

Workaround (if any):

  • The xml:lang element was being added by our XML database and is not actually used by our app, so we simply removed it.
  • You can specify xmlns:xml=”http://www.w3.org/XML/1998/namespace” in the root element and then the correct prefix is applied.

We discovered a couple of very strange bugs in how Flex trees handle data binding today. Our tree has showRoot=”false”. We are using e4x to bind to a sub-element of some source XML. Here is a sample MXML file:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”vertical” creationComplete=”init()”>
<mx:Script>
<![CDATA[
public function onAdd():void
{
x2.structure.appendChild(<entry label="dynamic"/>);
}
]]>
</mx:Script>
<mx:XML id=”x1″ xmlns=”">
<project label=”root”>
<metadata label=”metadata root”>
<entry label=”1st metadata entry”/>
<entry label=”2nd metadata entry”/>
</metadata>
<structure label=”content”>
<entry label=”one”>
<entry label=”one.one”/>
</entry>
<entry label=”two”/>
</structure>
</project>
</mx:XML>
<mx:XML id=”x2″ xmlns=”">
<project label=”root”>
<metadata label=”metadata root”>
<entry label=”1st metadata entry”/>
<entry label=”2nd metadata entry”/>
</metadata>
<structure label=”structure”>
</structure>
</project>
</mx:XML>

<mx:Tree id=”t1″ dataProvider=”{x1.structure}” showRoot=”false” labelField=”@label” width=”100″ height=”100″/>
<mx:Tree id=”t2″ dataProvider=”{x2.structure}” showRoot=”false” labelField=”@label” width=”100″ height=”100″/>
<mx:Button label=”Add” click=”onAdd()”/>

</mx:Application>

Second Tree Should Be Empty

Second Tree Should Be Empty

After Adding An Entry To An Empty Container The Tree Renders From The DataProviders Parent

After Adding An Entry To An Empty Container The Tree Renders From The DataProviders Parent

The first thing you notice when you run this is that while the second tree (on the left) should be empty it is in fact not! The showRoot=”false” setting does not appear to be honored if the root element doesn’t have any children. This appears to be written up at Adobe as Bug SDK-15083.

The second extremly strange behavior occurs when we add an item to the structure container that’s mapped to the second tree (we do this by clicking the Add button). Instead of ending up with a tree with our new entry, we end up with a tree that has a node for the metadata element and a node for the structure element… It appears that the databinding has been pushed up a level somehow (see picture on right.)

We were able to workaround the first bug using the workaround described in the SDK-15083 writeup. We had to force a full refresh of the data binding for the tree when adding a first item in order to resolve the second issue.

I just created a Documentum room on FriendFeed if folks are interested in either lurking or posting information related to EMC Documentum and their products.


Think “The Tick” meets the “Once More with Feeling” episode of Buffy and you might begin to imagine the enjoyment that can be had watching Joss Whedon’s new “show”, uh… “fictional video blog”… or “musical”… there are 3 episodes, each about 15 minutes long and if you are at all interested in Joss Whedon’s work (Buffy, Angel, Firefly, Serenity, etc.) definately check out: Dr. Horrible’s Sing-Along Blog.

I have an NTFS disk that was ejected uncleanly from a windows box, as such when macfuse/ntfs-3g attempts to mount the disk I get the follwoing error:

$LogFile indicates unclean shutdown (0, 0)

Failed to mount ‘/dev/rdisk1s1′: Operation not supported

Mount is denied because NTFS is marked to be in use. Choose one action:

Choice 1: If you have Windows then disconnect the external devices by

  • clicking on the ‘Safely Remove Hardware’ icon in the Windows taskbar then shutdown Windows cleanly.

Choice 2: If you don’t have Windows then you can use the ‘force’ option for your own responsibility.

For example type on the command line:

  • mount -t ntfs-3g /dev/rdisk1s1 /Volumes/ntfs -o force

Or add the option to the relevant row in the /etc/fstab file:

  • /dev/rdisk1s1 /Volumes/ntfs ntfs-3g defaults,force 0 0

I’m not sure why the command-line and the /etc/fstab options listed in the error message don’t work for me, but they don’t. So I did some noodling around and found a post on the ntfs-3g focums that suggested using the following command:

ntfs-3g /dev/rdisk1s1 /Volume/ntfs -o volname=”Windows Disk”,force

I had to run this via sudo, but it did the trick.

Pretty good general purpose post about bug fixing, here is a synopsis:

1. Is this mistake somewhere else also?

2. What next bug is hidden behind this one?

3. What should I do to prevent bugs like this?

[From Three Questions About Each Bug You Find]

I found the attached commencement speach by Oprah Winfrey to the Stanford University 2008 graduating class quite refershing:



Embedded Video

I was surprised to hear her talking about Eckhart Tolle (after a quick google, I guess I shouldn’t have been). I really enjoyed reading his book “The Power of Now” a few years back. Kewl to hear that kind of thinking making it so directly into the mainstream…

Just stumbled upon a pretty sweet weblog about many things Documentum, although I wouldn’t say it’s a beginner’s guide…:

Ajith Prabhakar’s Weblog
A beginner’s guide to Documentum

[From Ajith Prabhakar’s Weblog]

Older Posts »