Flex Devs, KISS, please, for the Love of the FSM

I have been writing some acceptance tests for a Flex application in Selenium using Nose, and VirtualBox. To do so, I had to fix quite a few bugs in the Selenium Flex API. Are all Flex devs over-engineers? The SFAPI had a scary series of interacting methods, a helper class, multiple pieces of shared state mutated by what appeared to be simple query methods, and two entirely different ways of handling two objects which have the same formal interface, all of which was just to walk a tree of nodes (at least, as far as I could see).

I spent quite a bit of time staring at and debugging this code, trying to fathom why it was so complex. When you're new to an environment you often think there must be some *reason* you just don't understand yet. Thing is, it didn't *work*, so I had to fix it (on a deadline, no less).

Turns out the whole edifice really *is* just walking a tree of nodes, and all the messy side-effect laced, implicit operations were just attempting to eliminate duplicate visits (with a broken algorithm, as it turned out). In my hastily bashed out code, the tree traversal is a 48 line function that takes a functor and applies it to each node in the tree (with some logic to allow for short-circuits). It replaces all of the complex, error-prone, side-effect-laced methods, and the pointless helper class and can be used in all locations where traversal is needed in the code-base (with a single line of code) instead of requiring that the traversal logic be duplicated for each traversing method.

Thing is, all of the documentation I read on Flex, all of the examples, they seem to follow these same overly formal and rather obtuse patterns. I want a form that submits data to a web server and updates with error messages and the like... of course I need a model, a presentation model, a view, a controller, custom error handlers, a few classes to do the http submission, observers to handle data-change events, etceteras. Argh.


Comments are closed.


Pingbacks are closed.