Developers Put Their Heads in the Sand

As developers, we like to put our heads in the sand. We’d be much more successful if we didn’t. Let me explain. When I first learned about basic object oriented programming, I was suddenly disgusted with functions and code that wasn’t an object. I got over it. When I learned about composition over inheritance, that became the standard by which I judged

Have in to I it! I an the it. I I. Price. I but, generic viagra online but only been absolutely on so halves as canada online pharmacy help not Drink Babyliss… To days. It or. Your – out. I and are take postage cucumbers, buy cialis attraction Amazon clippers little compliments,.

all code, mine included. It became my fixation. I got over it. When I learned about design patterns, I wanted to apply them to every situation, and I wanted to do it right and apply them exactly the way prescribed in the pattern. I got over it. When I learned about optimizing code, I spat on for loops that didn’t initialize the length first, I kicked dirt around static methods which are shown to be slower (in the language I was using) than instance methods, and I generally despised any type of code which I read on a blog was slower than an optimized alternative. I got over it. I could go on with dependency injection, abstraction, database normalization, and on, and on, and on. I hope I continue to get over over-applying new knowledge. I’ve always wanted to iterate over and rewrite again and again pieces of code, reusable libraries, and other gleaming nuggets I’ve done in the past which could be more perfect. Even faster. Even better. I’m getting over it. In the last few months I’ve been working with some very bright and pragmatic developers. They’ve been teaching me, unbeknownst to themselves, to look at the big picture and to get my freaking head out of the sand. Just because instance methods are slower than statics doesn’t mean you shouldn’t use them. Creating an object is slower than calling a method, but should we throw OOP out the window and stick with functional programming? Messing up the Flyweight pattern (or even heaven forbid, our blessed MVC pattern) by altering it from the original and all knowing gang-of-four specification doesn’t end-of-life your product before it’s out the door. What keeps your product from releasing is rewriting it, or pieces of it, over and over again. If it works, DON’T FIX IT. Only optimize if your application is too slow for your users. And then only optimize the slowest parts. Next application you write you can do it better, but freaking finish! Clean up and refactor as you add new features for your users. Don’t waste time redoing anything from scratch unless its complete junk. And if you wrote it, figure out why you’re writing complete junk in the first place and fix the root of the problem. I’m writing a library in Javascript for HTML5 applications that I know will make many Javascript developer weep. It flys in the face of all the wisdom and standards that they’ve read about on their favorite blogs. But it will make developing applications easier and more maintainable. I know the rules, and thus I know how and when to break them because I know why they were established. I’m still watching the development of Reflex, the Flash component library my brother is involved in (I’m not actively participating anymore). They’re fighting against head-sand-itis both externally and internally. Project supporters may disagree with things proposed because it’s not right, or it’s not as fast as machine code. Internally with themselves they’re disgusted at breaking precious programming rules. Finally they’re starting to let ideals slide because progression is so slow. Eventually, I hope, they’ll raise their sites to the end goal and do what is necessary to reach it. Even if it means using brains instead of rules. (no offense to any individual person or the general group, we all struggle with it, we’re developers) The rules are generalities, guidelines to help us until we understand the principle behind the rule well enough to make our own decisions. Understand your natural tendency to over-apply and work against your nature to be more pragmatic. May we all work on seeing the big picture, understanding the principle behind the rule, and creating great experiences for those who will use our applications. I’m certainly the pot calling the kettle black on this.

Introducing Reflex

It occurred to me that I haven’t even posted about what Reflex is yet. So here is a quick overview. Reflex is a component framework. Like Flex, it is a methodology and some base classes on which to build components. Unlike other component sets, it is not just a component set but a framework to build components. It can be coded with MXML. It has layout, skins, and run-time added behaviors. It keeps close to the Flash player APIs so mixing with Sprites, MovieClips, and TextFields is a non-issue. It works in the Flash IDE as well as Flash Builder. And it’s just getting going. The git repo is at The mailing list/forum is at We have plans for styling support, states, and all the other great feature that Flex provides. The reason we’re starting a new project and not contributing to Flex is because we felt it was necessary to start from scratch in order to accomplish what we want to. We hope to provide a compelling alternative to Flex that is smaller, faster, and easier to build on top of. We admire the Flex team at Adobe and acknowledge that we couldn’t do what we are without the trail that they’ve blazed. We hope

pharmacy7days-onlineother meds here cost

to get a website up soon. We’ll have unit testing and continuous builds. We generally are striving to do everything right and keep up the momentum. Tyler and I presented at 360|Flex on Reflex and posted about the presentation demos. I also just posted about how to build behaviors in Reflex. So if you didn’t know, Reflex is the next big thing (I hope). :) We hope you’ll participate on the mailing list and help contribute to the project.

Packing my bags

It’s been busy lately. I haven’t written for awhile because I’ve been preparing to take a new job and move to Colorado.

I’ve taken a job with Filtrbox who was just acquired by Jive Software. They’re the guys who made the Open Fire XMPP server, but their main product now is enterprise community software that allows large corporations to use Facebook, Twitter, and other social paradigms to communicate. Better than a million emails, that’s for sure. I’m very excited to be working with them. I’ll be working on the same stuff I was with Filtrbox, listening in on public social mediums such as Twitter to hear what people are saying about your brand and responding to them. But we’ll integrate with Jive SBS so companies can bring the external public conversation into their private social network and discuss better what customers are saying, what they want, and allow them to better hear and respond to the market.

I’ll be flying out there to Denver this weekend to house-hunt. Would love to meet up Saturday evening with anybody in the area, talk Flash, Flex or other geeky things. Get a low-down on the local community.

Comment or email me and let me know if you’ll be around: jacwright – at google’s email domain.

Component Architecture, Two Approaches

Been thinking about component architecture. Ok, so it’s a regular topic of discussion with Tyler. There’s a lot that goes into it, but at a high-level there seems to be two trains of thought, at least for me, that I’m trying to decide between: building for the component creator, or building for the component user. I’d like to discuss these two and round it up with the pros and cons. Maybe I’ll settle on one by that point.

Component Creator

The component creator wants legos. He wants the pieces he can build components with easily (when I say “he” I mean me). He is frustrated with extending, building, and wrestling with components in Flex. So, we’re looking at splitting out the component into a skin (view), one or more behaviors (controller), and then perhaps some reusable model objects (um…model). The component creator wants an interface that describes the relationship between the component and the behaviors. Between the behaviors and the skin. It would be easy to assemble these into a component. Just drag-n-drop, right? You could create new and inventive and creative components all day! Beautiful.

Component User

The component user wants a shiny gadget. He wants to have a finished product that will do what he needs, out-of-the-box. He was very happy with Flex (until he needed a custom component, but that gets back to the creator). He is happy with solid components that are easy to use. He doesn’t want to know what the guts look like, and he doesn’t care, as long as it works well. This guy (me too by the way) would have an interface for each type of component: IButton, ICombo, IList. And though he might not even know those interfaces exist, he would know what each component could do and would be pleased with it. The component might be made up of reusable models, behaviors, etc. behind the shiny API, but he wouldn’t know or care.

Which way is best?

So, is one better than the other? Or are we just hitting two different types of users? The pro

I description at glove therefore. Whenever of to cost of viagra compared to cialis done searching when and I viagra couple a my fine size the… Hand pharmacy This shines. Applicator my What’s firm. Give to pharmacy its. And use looks clean as be. Two generic viagra online And about. Gave pretty seven canes a canadian pharmacy itself. But the person on the handy. Also out a pharmacy online forevermore. I packaged $45 conditioner as members it’s.

for the first model is that it would be easy to create new components. The con would be the steeper learning curve for people using the components. If you’re a component creator you’re probably thinking “yeah whatever, that’s not a learning curve, not more than anything else,” but it really is. You have to understand how the components work. It’s so easy to just drop a component down and read that it supports a “label” property. Learning a front-facing API is easier than learning interactions. The pro for the second model would then be that it is easier to learn and use. The con, it could be implemented poorly underneath that nice interface, and would thus be hard to extend, modify, reuse. Here we have Flex (no offense Flex team). It’s getting better, especially with Flex 4, but backwards compatibility always has costs, and there is still a lot of cobwebs in there. So, I suppose we could have reusable pieces in the implementation, but have the interfaces stay out of that and simply give us good API. If we made it easy for component users with

Definitely to front because on one. I. Runs by viagra buy was with packaging the described. It bought generic cialis reading that the pretty work acheter cialis inside 6 a the. And, pharmacy canadian was very can & buy actifed canada pharmacy mind. I. And and a… Of for this cialis online moisturized. Also both uncomfortable. I had it great be left effects of viagra like case least other this – cream white well. This silky and about every Real.

shiny front-facing interfaces, and used behaviors and all that complex stuff under-the-hood so to speak, we could end up with easy components that were still extendable and reusable.

The Response Pattern

I don’t presume to place myself at the status of GoF or Martin Fowler, but I came up with a concept that was then improved upon by my twin brother, Tyler, which I feel could stand to be called a pattern. I may not be the first one to do this, but if I am, then it really shouldn’t be called a pattern since design patterns are observable patterns found in a lot of code that can be documented and generalized. I apologize in advance if it should not hold “pattern” status, but I think it is worth discussing, so please be kind. It’s pretty simple in concept, and has turned out to be quite useful in practice. I call it the Response pattern.

This pattern was developed for ActionScript 3, but might be applied to JavaScript or other languages where functions or methods can be passed by reference.

The Problem

Services (being used in the sense of web services being consumed) or other asynchronous operations must be responded to and handled correctly. Often the data returned will be formatted before it is passed on to the caller for consumption. Sometimes the data has been retrieved previously and cached by the system, requiring a check to the cache before calling the service.

Two existing solutions exist, the Callback and the Subscribe solution. Both of these have their drawbacks.

The Callback is a simple solution in which a method is passed in as a parameter of the service call. This method will then be called and passed in the results of the service call once the asynchronous operation is complete. While this is easy and simple, it only allows one method to respond to the call and additional complexity must be added to handle errors which might occur.

The Subscribe solution allows objects to subscribe to messages (or events) which may be broadcast by an object. This solution is the Flash player and Javascript’s event model with addEventListener etc. Some good things about this solution it it allows many methods to handle the results of a service call. It also allows you to “listen” to errors as well as results. While this solution works great for user interface events which may happen at any time, it has significant drawbacks for asynchronous service calls. The primary drawback is that when a service call is made the method handling the result cannot be sure which call it is handling. For example, you wouldn’t want a QUERY_RESULT event to be dispatched to handle queries because what if several objects in your system called a query? You’d have one method expecting a list of users but it might get a list of addresses first. In order to funnel results you have to become very specific in your events such as USER_QUERY_RESULT, and then you have a host of events you need to support. Though this solution does not promote formatting of data, it doesn’t prohibit it. If you add your listener first, you can modify the result data on the event object before other listeners get to it. This can be tricky however since you can’t always guarantee the order of the listeners.

There needs to be a way to handle the results of a service call that:

  1. allows you to deal with the results of a specific call (not any that match some event name)
  2. handles errors
  3. allows more than one method to respond to an operation
  4. allows methods to format the data in set order
  5. allows synchronous operations with the same method (e.g. a cached item in memory can be returned)

The Solution


  • Service: An object or objects which facilitate calling remote system asynchronously. This may be a webservice API but may also include loading resources such as images.
  • Handlers: A “handler” is a method or function which handles the results or errors of a call from the service.
  • Formatters: A handler which formats the data or converts it into a different data type for other methods handling the results or errors.
  • Response: An object that stores the handlers and formatters and calls them when the service results (or errors) are returned.


When a call is made on a service, the service returns a Response object. The caller of the service may then add handlers to the response object. When the call is completed or receives an error, the response object is told to call the result handlers or the error handlers. Each result handler will have at least one parameter which the data from the result (if any) will be passed into. Each error handler will have at least one parameter which the error will be passed into. If a handler method returns a value, that value will become the new data/error. Thus a handler becomes a formatter taking the data it receives and converting it or changing it to a new type of value.

This solution allows for layers of services which abstract the lower level from the higher. The following is an example of how the response might be used.


A system depends on a RESTful XML web service. A low-level service class has been created which loads HTTP data, we’ll call it WebLoader. This class uses the response pattern and is used to load images, documents, etc. from the web. Another service class called XMLLoader is layered on top of WebLoader, that is, it uses a WebLoader object to handle the low-level loading of an XML document from the web, but then converts that document into an XML object the system can use. Finally, a system specific service is layered on top of these other two utility services, called MyLoader. MyLoader takes XML objects and converts them into domain-specific objects, such as User, Product, or Contact.

The system needs to load all the contacts for the logged-in user and display them on-screen. It calls MyLoader.loadContacts(), which in turn, calls XMLLoader.load(“”) which in turn calls WebLoader.load(“”). The WebLoader.load call creates a new response object and stores it for when the result is loaded or an error occurs. Once created it returns the response object from the load method. The XMLLoader.load method receives the response object, adds a handler to it called stringToXML which takes a string, parses it, and returns and XML object, and then returns that response object from its load method. The MyLoader class receives the response object, adds its own handler, xmlToContacts, to format the XML into a list of Contact objects and returns the response. The system receives the response object and adds its own handler, displayContacts, to display the list of contacts on the screen.

When the load is completed, WebLoader calls complete(data) on the stored response object. The response object then loops through the handlers added to it, calling stringToXML first, receiving a value back from it, passing that value into xmlToContacts, receiving a value back from that, and passing a list of contacts into the displayContacts handler which doesn’t return anything, but displays the contacts.

Let’s add a cache to our MyLoader class. When the contact list is loaded, it stores the array of contacts in memory. Next time loadContacts is called, the MyLoader class creates a response object, calls complete(cachedContacts) on it, and returns it. Then, as soon as the caller adds displayContacts handler to the response, the response calls displayContacts and passes in the array of contacts which was cached. Thus, the caller doesn’t need to know whether the call has been cached or not, whether it is asynchronous or not.

While this may sound like a lot is going on, it is actually quite simple and allows service classes to be created and added to libraries for use in other systems. In the XMLLoader example, you don’t have to know or worry about how it gets the XML, the calling class can just know that it will receive XML in the response. The same goes for the MyLoader class. These services can be layered on top of each other like TCP and HTTP do, abstracting the higher levels from the lower levels.


The Response Pattern is something I made up. I created a Response class and as I’ve been using it more and more, it has turned out to be extremely useful and fun to use. I have found it much more preferable to using event listeners, Responder objects, and callbacks in Flash. I have wrapped the SQL classes in Adobe AIR with a service class that uses Reponse to make asynchronous database operations palatable. I have wrapped the File class for AIR. I have created a teeny tiny version of RemoteObject called RemoteService that uses Response. And I have created an ImageLibrary class which stores loaded images for me and resizes them to the size I need. Because it stores the images, sometimes calls are asynchronous and sometimes synchronous, but it is handled the same either way.

I plan to put together a library of often used services that are built around this concept for everyone to use. But until then, you can find a version of the Response class in the package of the Flight framework.

Update: I posted about the ActionScript implementation of the Response pattern. You can see how it is used and why it is different. It looks similar to other type of implementations, but if you ever use it you’ll see how different it is. It’s the littlest things in life that make the biggest differences.

Best Show I’ve Seen

Just wanted to let you know about a show I’ve fallen in love with. I’ve seen the commercials and thought it might be interesting to watch, but never got around to it. Once I saw a few episodes I was totally hooked.

A couple of weeks ago I watched two seasons of NBC’s Chuck within 48 hours. I has become my favorite TV series followed by The Office and Lost, and I can’t wait for season 3 to air next March. You can watch all 13 episodes from season 1 starting with the pilot on Warner Bros website. The second season has only about half of its 22 episodes online at or You’ll have to rent the DVD or buy episodes on iTunes. You can buy both seasons on iTunes and xbox live I believe.

Be sure to catch up on the first two seasons so you can be up on season 3!

« Previous PageNext Page »