Custom events in JavaScript
Without a doubt, the most often-used paradigm in JavaScript is events. Events are a manifestation of the observer pattern, a well-defined computer science design pattern for loose coupling. Loose coupling is incredibly important for creating maintainable, stable codebases. I talk a lot about loose coupling and its importance in my talk, Scalable JavaScript Application Architecture (video), so I won’t talk too much about it here. However, the concept is very important to grasp if you wish to progress as a software engineer.
EventsUnless you’ve never written any JavaScript before, you’ve used events at some point in time (admittedly, if you’ve never written JavaScript before, the chances of your reading my blog are probably pretty slim). Put quite simply: the way that you tie behavior to web pages is through events. Events are a way of letting interested parties know that an important moment has occurred in the lifecycle of the application. For instance:
window.onload = function(){
Application.init();
};
In this example, the load event is the interesting moment. I want to know when the window is fully loaded so that I can initialized the JavaScript application. The onload event handler is the location to where an event handler is assigned. The brilliant part is that window doesn’t care what web page is loaded or who is writing the code; it just knows that there’s a function to call when load occurs. This is the essence of loose coupling: when parts of an application have very limited knowledge of one another.
The Browser Object Model (BOM) and Document Object Model (DOM) publish events to allow developers access to the interesting moments of the browser and web page, respectively.
Custom eventsIt’s no surprise that most JavaScript libraries rely heavily on custom events since this is a pattern that web developers are familiar with. Every major JavaScript library provides its own events, components to enable easy custom event definition, or both. This makes sense, of course, since libraries want to be loosely-coupled to the execution environment, and therefore, to your code.
There’s nothing magic about custom events, though, and there’s no need to load an entire library if you’d like to experiment with custom events. An object that supports custom events needs to be able to do a small set of things:
- Assign an event handler for a particular event.
- Remove an event handler for a particular event.
- Fire an event and call all assigned event handlers.
The following implements all of this basic functionality:
//Copyright (c) 2010 Nicholas C. Zakas. All rights reserved.
//MIT License
function EventTarget(){
this._listeners = {};
}
EventTarget.prototype = {
constructor: EventTarget,
addListener: function(type, listener){
if (typeof this._listeners[type] == "undefined"){
this._listeners[type] = [];
}
this._listeners[type].push(listener);
},
fire: function(event){
if (typeof event == "string"){
event = { type: event };
}
if (!event.target){
event.target = this;
}
if (!event.type){ //falsy
throw new Error("Event object missing 'type' property.");
}
if (this._listeners[event.type] instanceof Array){
var listeners = this._listeners[event.type];
for (var i=0, len=listeners.length; i < len; i++){
listeners[i].call(this, event);
}
}
},
removeListener: function(type, listener){
if (this._listeners[type] instanceof Array){
var listeners = this._listeners[type];
for (var i=0, len=listeners.length; i < len; i++){
if (listeners[i] === listener){
listeners.splice(i, 1);
break;
}
}
}
}
};
The EventTarget type has three methods: addListener(), fire(), and removeListener.
The addListener() uses the private _listeners object to store event handlers for various events. When an event handler is added, the method first checks to see if there’s a named property for that event type on the _listeners object, and if not, creates one containing an array. The event handler function is then saved to the array for later.
The fire() method fires an event with a given name. In effect, this method’s only job is to execute each event handler for the given event type. The method accepts either an object, in which case it’s expected to have a type property, or a string, in which case a new object is created and the string is assigned as the value of type. Next, if the event object doesn’t have a target property assigned, it is set to the current instance. This effectively creates an event object similar to the one most are familiar with via the BOM and DOM. Once the event object is created, the _listeners object is checked for event handlers, and if found, they are executed. Note that in order to mimic the BOM/DOM approach, event handlers are executed in the scope of this via the call() method.
The last method, removeListener(), simply reverses the process of addListener(). It searches through the _listeners property for the given event type to locate the specified event handler. If found, the event handler is removed by using the array’s splice() method, and otherwise it exits without doing anything.
Basic usage:
var target = new EventTarget();
function handleEvent(event){
alert(event.type);
};
target.addListener("foo", handleEvent);
target.fire({ type: "foo" }); //can also do target.fire("foo")
target.removeListener("foo", handleEvent);
Practically speaking, you’ll likely not want to use an instance of EventTarget directly, but rather inherit from it:
function MyObject(){
EventTarget.call(this);
}
MyObject.prototype = new EventTarget();
MyObject.prototype.constructor = MyObject;
MyObject.prototype.foo = function(){
this.fire("foo");
};
var o = new MyObject();
o.addListener("foo", function(){
alert("Foo just happened.");
});
o.foo();
Typically, events are fired in reaction to some other method call, as in this example (events are usually not fired external to the object that is publishing the events).
What about…?This is a pretty barebones implementation of a custom event providing object, so inevitably someone will come along and ask why I didn’t include one feature or another. There are, of course, a lot of enhancements you can make to custom events if you so desire. Some enhancements others have implemented:
- Bubbling of events
- Continue to execute event handlers even if one throws an error
- Allow event handlers to cancel further processing or default actions
Each of these can be built pretty easily on top of the base presented in this post.
ConclusionCustom events are a very powerful and useful pattern in JavaScript programming, and your usage of them doesn’t have to rely on a large JavaScript library. Implementing your own custom events is easy. The implementation presented in this post is a minimum feature set that typically fulfills most requirements, but you can consider it as a starting point for more advanced functionality if your requirements are more complex.
Related posts
P.S. My new book, High Performance JavaScript is coming out in early 2010. Need help now? Check out Professional JavaScript, 2nd Edition.
J4D update: My Book, Other Books, Workshops and talks
Oracle CHR Function
One example of the usefulness of CHR is in the creating of results that include characters that are significant in the query itself. Using CHR appropriately allows the SQL developer to avoid the need to escape these characters with query syntax significance. For example, to print the last names of employees in Oracle's HR sample schema with single quotes surrounding the last names, one could write a query like this:
select '''' || last_name || '''' from employees;
The four single quotes successfully escape the quote mark both before and after the last name. Unfortunately, it can become easy to get lost in the quotes, especially for more complex queries. Because the ASCII decimal code of 39 produces a single quote when passed to CHR, the expression CHR(39) can be used instead as shown next:
select CHR(39) || last_name || CHR(39) from employees;
For me, this is more readable. Similarly, even more difficult characters can be represented with the CHR function. For example, Stephen pointed out in his presentation that CHR(10) can be used to have a new line printed in the output.
One of the interesting ideas that Stephen discussed was use of a simple script to display the various character representations available via the CHR function. One can always reference a resource like Tech on the Net's ASCII Chart or asciitable.com, but it is interesting to simply display the representations via code:
-- displayCHR.sql
--
-- Display the characters associated with basic and extended ASCII codes.
--
SET head off
SET pagesize 0
SET linesize 120
SET trimspool on
SET feedback off
SET verify off
SET serveroutput on size 5000
BEGIN
FOR i IN 32..255 loop
Dbms_output.put_line(i || ' ' || chr(i));
END loop;
END;
/
The above snippet of code, when executed in SQL*Plus, will display a large number of the characters available in the basic and extended ASCII character set. One can use the spool command to spool the output to a file. On my Windows-based machine, I was even able to view these generated symbols in the spooled output file using the basic Notepad application.
Conclusion
As Stephen pointed out in his presentation, the CHR function can make SQL*Plus scripts more readable and maintainable.
The Flash Mobile Advantage
A post up about Jeff Smith from Smule and why he won’t ever target Android.
Smith is part of a small but vocal chorus of app developers who say they don’t want to move to Android, even though it is growing quickly. His complaints: He doesn’t like the way the store merchandises its wares, and he doesn’t want to have to create different apps for each handset Android supports.
To me, that helps show the value proposition of Flash on mobile devices. You’re going to have to create custom Flash mobile content for each device. It’s not going to be write once, run everywhere. But you’re not going to have to rewrite an app from scratch and you’ll be able to use the same technologies and tools across multiple platforms which means you can crank out applications faster and make sure they’re higher quality.
As developers get more sophisticated, just like agencies have their own frameworks to give them a head start on the apps they build, you’ll see frameworks that decrease the time to market of mobile applications for different sized screens and different functionality. But the key is being able to use the same tools, the same language, and the same platform so that you can easily tweak and write those applications for multiple platforms.
seantheflexguy DJing at 360 Flex!
I’d like to thank Tom at 360 Flex for the opportunity to open up this morning at 360 Flex by providing some early morning tunes for the crowd. I was spinning a live set from my office across the web. The set was shown for the crowd on the big screens, you can see the action in the photo in this post. Per request I played old school Hip Hop, mostly from the 80s. Tracks like: The Message, Rappers Delight, Peter Piper, La-Di-Da-Di, The Show, Boyz n the Hood, etc. It was a huge honor and I really can’t thank the crew at 360 enough for the opportunity. I should be spinning another live set on Wednesday morning, via the web for the 360 Flex attendees. In addition there is a rumor that I may be spinning at Flash and the City, still working out the details on that…
HP’s Flash-enabled Tablet
Some very cool video of Flash Player and AIR running on HP’s Slate tablet computer.
It’s great to see Flash Player running on a tablet. One of the nice things about the tablet versus the mobile device is that because of the larger screen size, more content will work out of the box. Flash on mobile devices performs really well but the screen size is going to require some UI changes for sites that will be visited heavily by mobile devices. Tablets provide a more big-screen experience.
Flex Camp Wall Street and Flex on the Cloud Videos
Two great Flex conferences have recently posted their video recordings:
There were numerous great sessions and speakers at each of these conferences. At Flex Camp Wall Street I presented “Flex Stuff I am Excited About”. Check it out and let me know what you think.
A syntax highlighting TextBlock for Silverlight 3
I’ve adapted a syntax highlighting engine to generate a syntax highlighting TextBlock control for Silverlight. This control has built-in syntax highlighting C#, C++, JavaScript, VB.NET, XAML/XML.
In the future, once Silverlight 4 is out, I’ll of course make sure to update this to work with the rich text control to allow for copying and pasting as well, but in the meantime, this works great for displaying code.
Based on ColorCodeA while ago I was happy to see that Drew Miller released a simple syntax highlighting engine called ColorCode. It is a good implementation that moves forward through a stream, provides scoping information, and is compact enough for client use.
The control, however, was designed to only target ASP.NET. It writes out the results using an HtmlWriter. I had to rip out a lot of this implementation requirement that was threaded throughout the code, but what I have now effectively takes a TextBlock and outputs a bunch of Inline elements to it for all the processed code.
Note that I did what it took to get this control functional, this isn’t any sort of reference implementation.
Download the controlHere’s the source and quick sample in a Visual Studio 2010 Silverlight 3 project:
Using the controlAdd the control assembly to your Silverlight project. Then, add an XMLNS prefix to your Silverlight page where you’d like to use the control.
There are two properties of interest that should be set or bound: SourceCode (the actual source text), and SourceLanguage. The names probably could be better, sorry!
SourceCode dependency property is the source to syntax highlight, just like the Text property of a TextBlock. The name is different to make it clear that this is not just a TextBlock control since you also need to specify the language type to colorize.
Since this implementation does not “auto-sense” the language, you must provide the language for interpretation. The SourceLanguage property defines this and has a value of either CSharp, Cpp, JavaScript, VisualBasic, Xaml, or Xml. It defaults to CSharp.
This control is small enough that I think it’ll be useful inside code sample apps. It’s 40 KB uncompressed, and 16 KB in a typical Silverlight Xap.
How to get additional language supportThe original ASP.NET implementation on CodePlex contained support for a lot of other additional languages and file types:
- ASHX
- ASAX
- ASPX
- ASPX.CS
- ASPX.VB
- HTML
- SQL
- PHP
- CSS
To add any of these to your control, you just need to:
- Add the language name to the SourceLanguageType enum, and plumb its value through the control (sorry for the pain in this step)
- Add the ILanguage file to the control inside the Compilation\Languages\ folder
- Make sure that the language is also in Languages.cs. Note that I’ve kept all the original CodePlex-provided values inside this file to make it easy to add them back.
Hope this helps.
Share and Enjoy:
grammar.coffee
grammar.coffee (via). The annotated grammar for CoffeeScript, a new language that compiles to JavaScript developed by DocumentCloud’s Jeremy Ashkenas. The linked page is generated using Jeremy’s Docco tool for literate programming, also written in CoffeeScript. CoffeeScript itself is implemented in CoffeeScript, using a bootstrap compiler originally written in Ruby.
plugins for AMFPHP
We’ve been tossing the idea of plugins for AMFPHP around, and so here’s what come of it. Please share your thoughts on this. Note: this is a copy of a mil I’ve sent to the amfphp-cvs mailing list
Why?
People who want to contribute to the AMFPHP community currently mst have their contribution vetted by me. Not only am I a poor judge, but I’m also lazy. So the idea is to provide a system where someone who has a cool idea can push it to the community and let the community decide.
Design Goals
Flexibilty, extensibilty, simplicity, convention over configuration
How (global design)?
I’ve looked around a bit, and what seems to work elsewhere and that I quite like is a system of hooks. The idea is that at certain points in the execution of the script the possibility is given to the plugins to interact with the data flow. Here’s a simple example: Your plugin wants to add a service to those available in the usual “services ” folder. When the gateway tries to direct a service call, instead of just routing it to the services folder, it can ask the plugins first if they have a matching service.
How (technical specifics)?
There will be a new “plugins” folder in amfphp. Each plugin will consist at the very least of a subfolder and an index.php. When called this index.php will register for all needed hooks. To continue with the example, the index.php will register a function “addMyService” for the hook “LIST_SERVICES”. When LIST_SERVICES is called by the gateway, the plugin’s “addMyService” function will be called, and it will return the path to the plugin’s service.
What about plugins for the service browser?
The plugin registers for the hook GET_SERVICE_BROWSER_PLUGINS, and naturally takes the opportunity to add a nearby SWF.
That’s all for now. I know it’s a bit sketchy, but once we get the basics down I’ll flesh this out.
Ariel
Ultimate guide to table UI patterns
JavaFX - How to Layout
Just thought of providing an outline for design and implementation of JavaFX application. I briefly described this in one of previous post - Custom Layout.To start with we will most likely receive a huge PSD file from designer. You may use Production Suite tools to import the content into JavaFX. Here is manual approach..
First we need to identify various functional areas in the UI. Most likely the UI is already grouped. Areas can be Settings, Authentication, Data-Entry/Update View, ToolBar, Search etc. From this we can identify set of packages to be created in JavaFX. If the UI is simple, we may have the entire UI under "view" package. Now we can breakup the UI in to multiple classes based on the functional area. It will be easier if we could make these classes extend Container or CustomNode. From there we come down to actual layout of Controls..
Given below is the layout used in one of MiG Layout Demos - Layout Showdown. Refer to MiG Layout Site for more information. Refer to JFXtras project for more information on MiG Layout for JavaFX.
We will try to implement this UI in JavaFX..
Now we need to visualize a grid on top of the layout so as to identify some pattern in UI. It will be much easier if we could do this mapping. You may refer to various sites such as Layout Cookbook, RIA Screen Layouts or RIA Screen Design to get some idea..
Once we get the mapping, we can implement the layout using various layoutNode functions in Container. Please refer to PersonalDetailsView.fx source for more information.
To launch click on above image or
Please try it out and let me know feedback..
var dzone_style = '2';
Ready to test those Silverlight and Windows Phone 7 Series apps?
That’s right, my MIX 10 session’s been announced! Come learn about testing those apps.
UNIT TESTING SILVERLIGHT AND WINDOWS PHONE APPLICATIONS
Jeff Wilcox in Lagoon B (Mandalay Bay)
Tuesday, March 16, 2010 2:05 PM (30 minutes)
Synposis from http://live.visitmix.com/MIX10/Sessions/CL59:
Learn how to create and maintain Silverlight and Windows Phone 7 Series applications using the Silverlight Unit Test Framework. See what tools are available to easily validate controls and application interfaces, add automatic testing to builds, and gain a solid understanding of test principles to deliver great experiences for your clients and customers.
What’ll be new at MIX for testing?
- Support for testing those Windows Phone 7 Series apps!
- New release of the Silverlight Unit Test Framework, with a modern user interface, Out of Browser support, and more.
Hope to see you all in Vegas! And if not – these sessions always make it online super quick. Let me know if there’s anything in particular you want covered in the talk.
Share and Enjoy:
An Ad-less Internet
A fascinating experiment and follow-up by Ars Techinca on ad blockers.
If you read a site and care about its well being, then you should not block ads (or you subscribe to sites like Ars that offer ads-free versions of the site). If a site has advertising you don’t agree with, don’t go there. I think it is far better to vote with page views than to show up and consume resources without giving anything in return. I think in some ways the Internet and its vast anonymity feeds into a culture where many people do not think about the people, the families, the careers that go into producing a website.
I was recently on a roadshow with some folks from EyeWonder, a company that provides a framework to build and place a lot of the ads on the Internet. Some are very clever, others would fall into the annoying category. During the trip I talked to a lot of the creatives at big agencies who are working with sites to place these ads for their brands and the adblocker concern was a big topic. If their brands aren’t getting the views on the ad, they’re not going to want to pony up, and sites lose money.
What’s worse, is that it becomes a downward spiral where the ads being served become more intrusive in order to get the attention of a fading audience. Ultimately, one of the best conversations I had was with someone who used to be the creative “gate” for agencies on a major network of sites. Agencies came to her with their ad ideas and she was the person who gave thumbs up or thumbs down on the ad depending on whether or not it was too obnoxious or wouldn’t jive with what the network’s users expect.
To me, that’s the key. Flash may be synonymous with advertising now, but the same obnoxious ads are going to be created with HTML5 when it becomes prevalent, so the people creating ads have to build them so that they’re targeted and interesting. I don’t think they have to be static, or can’t take up the whole page, but they should follow some basic guidelines (auto-playing sound being a terrible, terrible scourge) and leave the user in control. Close buttons should be obvious, mouse out events should minimize the ad, and it should be difficult to accidentally trigger it. And making sure ads are optimized so they aren’t causing Flash to spin up the CPUs is key to a good user experience.
The web is an interactive place and there is a lot of very interesting work going on in the interactive advertising space. That work directly funnels money back to your favorite sites and pays a lot of bills.
Correlation Between Typing Speed and Programming Competence
I do know a few exceptions where a particularly talented developer is not even in the top half in terms of typing skills, but it is the rare exception. The majority of the best developers I've had the good fortune to work with are in the "top half" in terms of typing speed. I am a strong believer that good software development is much more than just hacking some code. So, I in this post, I look at the correlation between the ability to type rapidly and the likelihood of being a successful software developer.
It goes without saying that a fast typist is not necessarily a good developer. I've never seen (other than on television) anyone type faster than my mom. She had been an administrative assistant (called secretary at the time) for several years. This experience combined with an obvious knack for the skill had led to her typing 120+ words per minute with few or no mistakes (on typewriters no less). She was not a software developer.
Although it is true that typing is a big part of the software developer's job, so are many other things such as understanding customer needs, coming up with architectures and designs that feature the most important -ilities, working on teams, knowing language syntax, understanding various third-party products and frameworks, and so forth. Typing is clearly a big part of most software developers' daily routine, but what makes it seem to be so highly correlated with the most successful software developers?
We Do Well What We Do Often
In many ways, the correlation between typing and software development success is not so as much about faster typing leading to a better developer as it is about faster typing being evidence of countless hours spent with the keyboard writing code. In other words, it is not necessarily that faster typing makes the developer better or more efficient (though it obviously cannot hurt) as it is that the great developer is a fast typist simple because that developer has spent so much time coding (and learning to be a better typing as a pure side effect of those many hours). One could make the argument that becoming experienced and accomplished in software development makes one a better typist rather than making the argument that being a better typist makes one a better developer.
I have noticed that my fastest typing comes when I type the same thing over and over. What this means is that I end up being very quick to type things like build commands, database/SQL commands, application server administrative and deployment commands, configuration management commands, and the like. The things I do everyday are the things I do most quickly.
Efficient Typing Allows Time for Other Things
One advantage that faster typists have compared to developers with lesser typing skills is that less time spent typing in characters means more time doing the many other things that good software developers do: scripting routine tasks, writing and running tests, documenting for users and maintainers, learning new things, writing e-mail messages, writing blogs, etc. In an almost recursive fashion, many of these tasks that can have more time dedicated to them because a developer was able to type code more quickly are themselves beneficiaries of better typing skills as well.
Efficiency of Typing can Lead to Perceived Faster Typing
One of the interesting characteristics I've observed in many of the best developers I've worked with is their ability to take advantage of many different key strokes, macros, and other devices to accomplish the same task more quickly. Although just about every developer I work with these days uses an IDE, it wasn't all that long ago when certain developers could make the (truthful) argument that they could write and develop code more quickly in their simple text editor than most developers around them could with the IDE.
For the smallest of projects, I still find myself sometimes using these simple tools when the IDEs or other more advanced tools just feel unnecessarily heavy. I have amazed some people around me with my perceived vi prowess, but what they don't realize is that I'm really an amateur compared to some of the vi skills I have seen others possess. When these developers combine a powerful IDE with a vi emulator, it can be dizzying trying to watch them in action.
Some of the fastest developers I have worked with complement their own typing speed with knowledge of and familiarity with their favorite tools. This is often seen in the world of IDEs where a developer who knows the IDE well can take advantage of all types of different features to developer more quickly and accurately.
Fast Typing is an Inherent Advantage in Some Aspects of Software Development
Although it can be argued (as I did above) that fast typing is a side effect or consequence of years of inadvertently practicing typing while writing code, there is no question that some areas of software development are prone to benefit from faster typing. It is obvious that a fast typist has advantage when getting his or her thoughts into code, though I have seen that advantage at least partially mitigated by IDE code completion and other features.
Writing original code is an obvious area where faster typing is an advantage. Faster typing is also an advantage, however, for the person doing refactoring outside that supported well by the IDE. Faster typing might make a developer less concerned about having enough time to write that one last test he or she feels would be nice to have.
Typing is Not Writing
One of the areas where the correlation between fast typist and great developer breaks down most is when typing without creativity is considered. Developers' typing is more like authors' and reporters' typing and less like administrative assistants' typing and stenotyping. By this, I mean that a developer typically must insert his or her own creativity and thought into what he or she is typing. Rarely is the developer asked to simply type up some pseudocode or other previously dictated implementation. What this can mean is that the raw speed of typing may be not quite as important as it would be if typing up what someone else was saying or writing because some time is spent in that thinking.
Conclusion
It's not all that surprising that, at least in my experience, that the better developers generally tend to be faster typists. The correlation between productive developer and typing skills seems to enjoy somewhat of a causal relationship from both sides. Being a better developer as a result of years spent toiling over a keyboard writing code cannot help but make one more efficient with the keyboard. From the other perspective, faster typing skills help a developer to get more done in the same amount of time. As with just about everything in life and especially in software development, there are exceptions. I do know of some really good developers who are probably not in the top half of typist abilities, but they are the exception. Most of the best developers I know are also better than average typists. The good news is that developers can practice both at the same time. As one writes code, one also practices typing.
Additional References
⇒ Programming's Dirty Little Secret
⇒ We Are Typists First, Programmers Second
⇒ Speed Chess
⇒ Stack Overflow: Should Programmers Be Excellent Typists?
Icon Fight
I thought the new Techmeme share icon was a bit strange but after reading Gabe’s comment, I discovered that there’s a bit of a dust-up over what icon people are using to indicate sharing.
![]()
But what I didn’t realize until now is that part of the Open Icon set includes a Geotag Icon, which I will now be using extensively.
A couple of new tutorials by JavaFX Geeks Nancy Hildebrandt, Vaibhav Choudhary and Scott Hommel
Demo of Apache MyFaces 2 and OpenWebBeans
Recently the Apache MyFaces project released its second beta release and yesterday the Apache OpenWebBeans project released its M4 release.
These are great milestones in the direction of JavaEE at Apache!
A few month ago Bernd Bohmann and I were giving a JSF2 + X presentation in Muenster, at the JUG. The presentation was great and we showed a lot of cool features of JSF2 and CDI. The big plus was that we were Apache projects (MyFaces and OWB), which we build from the trunk. Now since there are these important milestones, I was able to actually make the demo project available under my “facesgoodies” demo/kickstart project.
Get the source of the Maven project from here.
Once you extracted the source, just run “mvn” and Maven downloads all you need!
Enjoy!
Memory Barriers article published by InfoQ
"A trip to main memory costs hundreds of clock cycles on commodity hardware. Processors use caching to decrease the costs of memory latency by orders of magnitude. These caches re-order pending memory operations for the sake of performance. In other words, the reads and writes of a program are not necessarily performed in the order in which they are given to the processor. When data is immutable and/or confined to the scope of one thread these optimizations are harmless. Combining these optimizations with symmetric multi-processing and shared mutable state on the other hand can be a nightmare. A program can behave non-deterministically when memory operations on shared mutable state are re-ordered. It is possible for a thread to write values that become visible to another thread in ways that are inconsistent with the order in which they were written. A properly placed memory barrier prevents this problem by forcing the processor to serialize pending memory operations."
You can read the rest over at InfoQ ...
Flex Saving Flash
Interesting writeup over on PHPArchitect.
That is the most important thing that Flex brings to Flash: professional grade tooling. The Flex framework, which Adobe has open sourced, makes application development quick and painless for programmers familiar with event driven programming.
One of the things that fascinates me about the Flash Platform is the number of different types of web professionals it attracts. Those web professionals have very different goals so we largely try to stay out of the way and let them create what they want. But to make them productive we create tools and sell them. But trying to have one tool that does everything isn’t practical. Flex was always intended to be a developer-centric way to create Flash applications and I think Flash Builder 4 is going to show that off better than the previous versions.


