<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Mastering the Tao of Personal Computing</title>
	<atom:link href="http://npacemo.com/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://npacemo.com/wordpress</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sat, 19 Jul 2008 06:49:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Flex Application Bootstrapping - Totally Custom Preloader</title>
		<link>http://npacemo.com/wordpress/2008/07/06/flex-application-bootstrapping-totally-custom-preloader/</link>
		<comments>http://npacemo.com/wordpress/2008/07/06/flex-application-bootstrapping-totally-custom-preloader/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 20:17:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Adobe Flex]]></category>

		<category><![CDATA[bootstrapping]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[preloader]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=52</guid>
		<description><![CDATA[I&#8217;m not going to define and discuss what a RIA is, but I rather stress here on one very important aspect of rich internet applications and in particularly saving time. Time is money (or opportunities for pleasures and entertainment), having more time is having more money (or opportunities for pleasures and entertainment), so that&#8217;s where [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not going to define and discuss what a <a href="http://en.wikipedia.org/wiki/Rich_Internet_application">RIA</a> is, but I rather stress here on one very important aspect of rich internet applications and in particularly <strong>saving time</strong>. Time is money (or opportunities for pleasures and entertainment), having more time is having more money (or opportunities for pleasures and entertainment), so that&#8217;s where &#8216;rich&#8217; comes from. Flex applications that take eternity to load and don&#8217;t offer you something enough valuable as compensation for your patience are waiting in vain, just as in the <a href="http://www.youtube.com/watch?v=AzMUfYpCwQk">song</a>. This is one reason why rich internet applications come with very specific requirements and tight restrictions about what&#8217;s loaded and when. Chunks of functionality and data are dispersed in time and are ordered by their purpose in the concrete application. </p>
<h3>The Specific Requirements</h3>
<p><a href="http://bombaysapphire.com">BombaySapphire.com</a> - that&#8217;s a typical example. The requirements for the application loading can be summarized in the following diagram, where the gray bars depict the life-span of the different visual phases of the Bombay application, and the red ones are showing the time needed for loading the various parts and data, comprising the application. In case you wonder the LDA abbreviation stands for Legal Drinking Age validator.<br />
<img style="margin: 20px 0 20px 0;" title="bootstrapping-timeline" src="http://npacemo.com/wordpress/wp-content/uploads/2008/07/bootstrapping-timeline.jpg" alt="Schematic Application Timeline" width="500" height="219" /><br />
Instead of having all the gray bars be part of a monolithic whole, the guys from Adobe had provided us with the 2-frame Flex application model, where the first frame of the application is solely devoted on the preloader, while the second is available for the actual application.<br />
<img style="margin: 20px 0 20px 0;" title="bootstrapping-frames" src="http://npacemo.com/wordpress/wp-content/uploads/2008/07/bootstrapping-frames.jpg" alt="Flex Application Two Frames Model" width="500" height="219" /><br />
In the rest of the article I&#8217;m going to describe how to setup not just a skinned preloader, but a totally custom preloader. For those interested in just skinning the default Flex preloader - <strong>mx.preloaders.DownloadProgressBar</strong> - you should continue with <a href="http://jessewarden.com/2007/07/making-a-cooler-preloader-in-flex-part-1-of-3.html">Jesse Warden&#8217;s</a> great article on the topic. But before proceeding with the implementation of the IPreloaderDisplay interface, we need to take a look at the Flex <strong>SystemManager</strong> and its responsibilities and also to get familiar with some events that the Preloader dispatches. </p>
<h3>The Flex <strong>SystemManager</strong></h3>
<p>1. The <strong>SystemManager</strong> is the first display class created within a Flex application.<br />
2. It is responsible for creating the Preloader and handling its events.<br />
3. The <strong>SystemManager</strong> is also responsible for advancing the Flex application to the second frame once the application SWF is fully downloaded.</p>
<p/>
Besides these responsibilities directly related to the Preloader, the <strong>SystemManager</strong> is also responsible for:<br />
4. Managing an application window and sending events if the size of the window changes.<br />
5. Maintain tooltips, cursors and popup windows.<br />
6. Expressly trapping the keyboard and mouse activity.<br />
7. Some other stuff, I hadn&#8217;t time to read about.</p>
<h3>Preloader&#8217;s most important events</h3>
<p>1. <strong>ProgressEvent.PROGRESS</strong><br />
This is a typical progress event - it indicates what part of the application is loaded.<br />
2. <strong>FlexEvent.INIT_PROGRESS</strong><br />
This event is dispatched when the Flex application completes an initialization phase - once the application SWF is fully loaded, the <strong>SystemManager</strong> advances the playhead to the next frame. Usually you&#8217;ll need to control the specific moment when the application advances to the second frame in the 2-frame model. In the samples below I&#8217;ll show one ways to achieve this - basically you need to capture the event, store it as pending and suspend the succeeding dispatches of these type of events - later you should re-dispatch the stored pending event.<br />
3. <strong>FlexEvent.INIT_COMPLETE</strong><br />
This is the last event the Preloader dispatches. Next the Preloader should dispatch <strong>Event.COMPLETE</strong> indicating that the <strong>SystemManager</strong> is ready to remove the Preloader and to add the application to the display list.</p>
<h3>Implementing the <strong>IPreloaderDisplay</strong> interface</h3>
<p>I think this is the right place in the article to show you a sample implementation of the <strong>IPreloaderDisplay</strong> interface. Let&#8217;s start with the trivial part of the interface - some background and stage related properties. In the <strong>IPreloaderDisplay</strong> these are defined as get and set functions, which allows me to implement them by just declaring the corresponding public variables.</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
public var backgroundAlpha : Number;
public var backgroundColor : uint;
public var backgroundImage : Object;
public var backgroundSize : String;
public var stageHeight : Number;
public var stageWidth : Number;
</pre>
<p>The most convenient place for adding listeners for the events dispatched by the Preloader-component is in the <strong>set preloader()</strong> method of the interface.</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
private var _preloader : Sprite;
public function set preloader(value : Sprite) : void
{
    _preloader = value;

    _preloader.addEventListener(ProgressEvent.PROGRESS, onPreloaderProgress);
    _preloader.addEventListener(FlexEvent.INIT_PROGRESS, onPreloaderInitProgress,
        false, int.MAX_VALUE);
    _preloader.addEventListener(FlexEvent.INIT_COMPLETE, onPreloaderComplete);
}
</pre>
<p>The last method we must implement is the <strong>initialize()</strong> method. This method is called right after the Preloader is added as a child. This is the entry point where you can configure your preloader. For example I use this method to draw the background, filling it with a custom pattern or just adding visual components as children to this totally custom preloader.</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
public function initialize() : void
{
    // e.g. draw a background
    ...
    // or add visual children to the totally custom preloader
    ...
}
</pre>
<p>Let&#8217;s take a look how I handle the above mentioned event <strong>FlexEvent.INIT_PROGRESS</strong>:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
private var readyToAdvanceToSecondFrame : Boolean = false;
private var pendingInitProgressEvent : FlexEvent;
public function onPreloaderInitProgress(e : FlexEvent) : void
{
    if (readyToAdvanceToSecondFrame)
    {
        pendingInitProgressEvent = e.clone();
        e.stopImmediatePropagation();
    }
}
</pre>
<p>It worths taking note on the way I&#8217;m subscribing to <strong>FlexEvent.INIT_PROGRESS</strong>:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
_preloader.addEventListener(FlexEvent.INIT_PROGRESS, onPreloaderInitProgress,
    false, int.MAX_VALUE);
</pre>
<p>I&#8217;m setting the priority of the specified handler to the maximum possible value, making this handler the first one to execute when the event is dispatched. </p>
<h3>Duplicating Binary Class Definitions</h3>
<p>This probably needs a separate post, but I&#8217;ll share it here anyway. It is very possible that you&#8217;ll end up using a Flash component as your Preloader. The reasons for such a solution are clear. If your Preloader does a lot of stuff before your main application is even loaded, this better be a separate component. If you choose to put it in the application it will first increase the size of it, and second you&#8217;ll need to wait loading the whole application before using it. But making it separate imposes the question whether to use Flash or Flex when implementing it. Making this component a separate Flex application means you&#8217;ll have a preloader for the actual preloader, which is acceptable if you find a way how to load and use one Flex application inside of another Flex application. If you&#8217;ve done this, please share it with us and write a comment about it. Another thing we can&#8217;t rely on is whether the Flex framework is loaded - the size of the framework can be much bigger than the size of the Preloader you want to use. </p>
<p/>
Well, let&#8217;s assume we end up using a Preloader component written in Flash. When I did this I ran into a very subtle problem - duplicating binary class definitions. The picture below illustrates the problem:<br />
<img style="margin: 20px 0 20px 0;" title="bootstrapping-domains" src="http://npacemo.com/wordpress/wp-content/uploads/2008/07/bootstrapping-domains.jpg" alt="Flex Application Domains" width="500" height="284" /><br />
The Bombay Application Domain is the domain with the code of the main application. If this code holds a reference to the concrete type of the Flash-component, represented here by the LDA Application Domain we&#8217;ll run into trouble if the above application domain contains definitions of same classes - in this example the problematic duplication is the <strong>Tweener</strong> class. Such a duplication makes the application behave strange and unpredictable. </p>
<p/>
One way to avoid ugly situations like these is to use the <i>exclude command</i> before compiling the Preloader Flash component. The Flash 8 IDE provided this feature, but unfortunately it was removed from the new Flash IDE that has no such <i>exclude definitions command</i>.</p>
<p/>
Another way to avoid duplication is to avoid the above application domain to reference the concrete type of the Flash component. All you need to do is to encapsulate the preloader component under an interface Facade, thus the Flash component will conform with the Facade interface and the above application domain will not need to know the concrete type of the Flash component. </p>
<h3>A Skeleton Implementation</h3>
<p>I want to finish with a skeleton implementation, so you can base your code on it.</p>
<p/>
<strong>IPreloaderContentFacade.as</strong>:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
package preloader
{
import flash.events.IEventDispatcher;

public interface IPreloaderContentFacade extends IEventDispatcher
{
    function setApplicationProgress(bytesLoaded : Number, bytesTotal : Number) : void;
}
}
</pre>
<p><strong>TotallyCustomPreloader.as</strong>:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
package preloader
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;

import mx.events.FlexEvent;
import mx.preloaders.IPreloaderDisplay;

public class TotallyCustomPreloader extends MovieClip implements IPreloaderDisplay
{
    public static const PRELOADER_CONTENT_URL : String = "preloader_content.swf";

    public var backgroundAlpha : Number;
    public var backgroundColor : uint;
    public var backgroundImage : Object;
    public var backgroundSize : String;
    public var stageHeight : Number;
    public var stageWidth : Number;

    private var _preloader : Sprite;
    public function set preloader(value : Sprite) : void
    {
        _preloader = value;

        _preloader.addEventListener(ProgressEvent.PROGRESS, onPreloaderProgress);
        _preloader.addEventListener(FlexEvent.INIT_PROGRESS, onPreloaderInitProgress,
            false, int.MAX_VALUE);
        _preloader.addEventListener(FlexEvent.INIT_COMPLETE, onPreloaderComplete);
    }

    private var preloaderContentFacade : IPreloaderContentFacade;

    public function TotallyCustomPreloader()
    {
        super();
        loadPreloaderContent();
    }

    public function initialize() : void
    {
    }

    private var loader : Loader;
    private function loadPreloaderContent() : void
    {
        loader = new Loader();
	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);

	var loaderContext : LoaderContext = new LoaderContext(false, new ApplicationDomain());
	var request : URLRequest = new URLRequest(PRELOADER_CONTENT_URL);
	loader.load(request, loaderContext);
    }

    private function onLoaderComplete(e : Event) : void
    {
        preloaderContentFacade = IPreloaderContentFacade(loader.content);
        addChild(MovieClip(preloaderContentFacade));
    }

    private function onPreloaderProgress(e : ProgressEvent) : void
    {
        if (preloaderContentFacade != null)
        {
            preloaderContentFacade.setApplicationProgress(e.bytesLoaded, e.bytesTotal);
        }
    }

    private var readyToAdvanceToSecondFrame : Boolean = false;
    private var pendingInitProgressEvent : FlexEvent;
    private function onPreloaderInitProgress(e : FlexEvent) : void
    {
        if (readyToAdvanceToSecondFrame)
        {
            pendingInitProgressEvent = e.clone();
            e.stopImmediatePropagation();
        }
    }

    private function onPreloaderComplete(e : FlexEvent) : void
    {
        readyToAdvanceToSecondFrame = true;
        if (pendingInitProgressEvent != null)
        {
            dispatchEvent(pendingInitProgressEvent);
        }
        dispatchEvent(new Event(Event.COMPLETE));
    }
}
}
</pre>
<p>This skeleton implementation is omitting a lot of things a real implementation can have - all depends on the specific requirements of the application you develop. But I think the code above is general enough to serve as a guideline for a concrete implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/07/06/flex-application-bootstrapping-totally-custom-preloader/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introduction to Flex Application&#8217;s Architecture - Part 2 - PureMVC</title>
		<link>http://npacemo.com/wordpress/2008/06/08/introduction-to-flex-applications-architecture-part-2-puremvc/</link>
		<comments>http://npacemo.com/wordpress/2008/06/08/introduction-to-flex-applications-architecture-part-2-puremvc/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 14:09:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[Adobe Flex]]></category>

		<category><![CDATA[architecture]]></category>

		<category><![CDATA[Cairngorm]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[introduction]]></category>

		<category><![CDATA[pattern]]></category>

		<category><![CDATA[PureMVC]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=51</guid>
		<description><![CDATA[Discussing PureMVC or for a matter any micro-architecture is pointless without clear understanding of the Publish/Subscribe pattern. Why is that Publish/Subscribe is such a fundamental pattern?
The Publish/Subscribe Pattern
One of the first things a programmer should acquire about object oriented programming is the attitude not to care. Not to care about the internal workings of an [...]]]></description>
			<content:encoded><![CDATA[<p>Discussing PureMVC or for a matter any micro-architecture is pointless without clear understanding of the Publish/Subscribe pattern. Why is that Publish/Subscribe is such a fundamental pattern?</p>
<h3>The Publish/Subscribe Pattern</h3>
<p>One of the first things a programmer should acquire about object oriented programming is the attitude not to care. Not to care about the internal workings of an object implementation, not to care about the unrelated details, relationships, component dependencies and underlying technology. Not carrying is not just about avoiding brain stress or being cool, but to put additional effort to achieve exactly 3 things:<br />
1. <strong>Encapsulation</strong> or please, hide this dirty underwear.<br />
2. <strong>Strong cohesion</strong> for doing one thing, but doing it right.<br />
3. <strong>Loose coupling</strong> for being independent and not to need more to get more.</p>
<p/>
The goal of <strong>encapsulation</strong> is to expose only enough of a system to allow others to make use of it. We need to hide things in order to allow others not to care about them.</p>
<p/>
<strong>Cohesion</strong> refers to the degree in which elements within a system form a single, unified concept, with no excess elements. Cohesion affects the ease with which we can comprehend a system, and also unit test it, thus turning it into more reliable code.</p>
<p/>
<strong>Loose coupling</strong> refers to the degree in which a system relies on the knowledge about other components details. Depending on less, means carrying about less.</p>
<p/>
The Publish/Subscribe pattern is an established approach of reducing coupling in cases where a publisher-component needs to collaborate with other subscriber-components in a way, where this publisher needs not even know about the subscribers existence and the communication between them should remain ignorant of the system topology - the architectural layout between these components.</p>
<p/>
ActionScript 3 or I should say the Flash (not Flex) Framework provides an implementation of the Publish/Subscribe pattern through the <strong>EventDispatcher</strong> class. Event dispatchers provide an interface for subscribers to establish and discontinue interest in particular events through the public methods <strong>addEventListener</strong> and <strong>removeEventListener</strong>. I won&#8217;t go into further detail, because most probably by now you&#8217;ve done lots of event handling in Flex and also used Publish/Subscribe on variety of languages and frameworks. Just want you to be aware that this pattern is not just useful technique for programming UI, but a fundamental meaning for reducing coupling. </p>
<p/>
After you get acquainted with the PureMVC framework&#8217;s ActionsScript implementation you&#8217;ll notice that PureMVC does not rely on the Flash Framework and instead of using the Publish/Subscribe pattern in the form of dispatching Flash Events they use custom implementation of the Observer pattern (a.k.a. Publish/Subscribe). Well, no matter which implementation is in use PureMVC is a nice sample of how to achieve loose coupling through Publish/Subscribe.</p>
<h3>The PureMVC Micro-Architecture</h3>
<p>On almost every Flex event organized by the Bulgarian Flex User-group there are guys asking about how to use Cairngorm or PureMVC. As I said before it&#8217;s perfectly normal for a beginner to seek for an architecture with which he can approach every new application in relatively uniform way. That&#8217;s why I&#8217;m writing about Cairngorm and PureMVC - both are pretty general approaches and the focus of this second part is the PureMVC micro-architecture. </p>
<p/>
As the name says this is an MVC micro-architecture. It&#8217;s comprised from <strong>Model</strong>, <strong>View</strong> and <strong>Controller</strong> - all these three are hidden under a <strong>Façade</strong> - a singleton delegating corresponding responsibilities to the <strong>Model</strong>, <strong>View</strong> and <strong>Controller</strong> singletons. These are the core actors.<br />
<a href="http://npacemo.com/wordpress/wp-content/uploads/2008/06/puremvc-conceptual-diagram.jpg"><img style="margin: 20px 0 20px 0;" title="cairngorm-diagram-small" src="http://npacemo.com/wordpress/wp-content/uploads/2008/06/puremvc-conceptual-diagram-small.jpg" alt="Cairngorm Diagram" width="500" height="349" /></a><br />
The <strong>Model</strong> caches named references to <strong>Proxies</strong>, which expose an API for manipulating the data model (including data retrieved from remote services).</p>
<p/>
The <strong>View</strong> primarily caches named references to <strong>Mediators</strong>, which adapt and steward the UI components that make up the user interface.</p>
<p/>
The <strong>Controller</strong> maintains named mappings to <strong>Command</strong> classes, which are stateless, and only created when needed.</p>
<p/>
The <strong>Façade</strong> initializes and caches the core actors (<strong>Model</strong>, <strong>View</strong> and <strong>Controller</strong>), and provides a single place to access all of their public methods.</p>
<p/>
If you pay attention you&#8217;ll see 3 new concepts in the above description - <strong>Mediators</strong>, <strong>Proxies</strong> and <strong>Commands</strong> - well, almost new, because these are very similar respectively to the <strong>ViewHelpers</strong>, <strong>BusinessDelegates</strong> and <strong>Commands</strong> from Cairngorm, but they&#8217;re definitely not the same and the differences between them are worth noting.</p>
<p/>
<strong>Mediators</strong> help us to create or reuse existing user interface components without the need to imbue them with knowledge about the PureMVC application they communicate with. The benefit of using <strong>Mediators</strong> is they can be positioned closer to the view compared to the Cairngorm <strong>ViewHelpers</strong>. Being closer <strong>Mediators</strong> can handle immediately user interaction events that are not significant for the whole application, but just for the sake of the UI components comprising the corresponding view. Just like <strong>ViewHelpers</strong>, <strong>Mediators</strong> can be retrieved from the <strong>View</strong> and used within <strong>Commands</strong> or other <strong>Mediators</strong>. To register or retrieve a <strong>Mediator</strong>, you should use the <strong>Façade</strong>. Another advantage is the ability to use immediately <strong>Proxies</strong> without the need to trigger execution of <strong>Commands</strong> - this is not the way Cairngorm works - <strong>BusinessDelegates</strong> are invoked only from within <strong>Commands</strong>.</p>
<p/>
<strong>Proxies</strong> help us to expose data structures and entity classes (and the domain logic and services that support them) to our application in such a way that they may be easily reused elsewhere, or refactored with a minimum amount of impact to the rest of the application. Major thing to note is that we can use <strong>Proxies</strong> to simply manage a reference to a data object, and interact with this data object synchronously through the <strong>getData()</strong> and <strong>setData()</strong> methods. This seems to me messier than the approach used in Cairngorm. While in PureMVC you can use the <strong>Proxies</strong> for both synchronous and asynchronous interactions with data, Cairngorm makes clear separation between these two types of interaction - you can only interact synchronously with the data stored in the <strong>ModelLocator</strong> and every time you need to store or retrieve data from the back end, which is asynchronous operation  you should use <strong>BusinessDelegates</strong>. Another point to ponder is that Cairngorm also advocates clear separation of services from the <strong>BusinessDelegates</strong> with the use of the <strong>ServiceLocator</strong> - a centralized storage for all the services the application consumes. PureMVC provides no such separation, but you can always try to organize your <strong>Proxies</strong> in a layered fashion where synchronous and asynchronous interactions are on different layers.</p>
<p/>
I won&#8217;t say much about the <strong>Commands</strong>, because you&#8217;ll find them pretty analogous to the Cairngorm commands. </p>
<h3>Conclusion</h3>
<p>In conclusion I should say that you really need to read the documentation for the framework you&#8217;re planning to use, especially if you&#8217;re a beginner or have not enough experience to accept or reject such a reasonably looking micro-architectures like PureMVC and Cairngorm. Take PureMVC for example - if you read carefully the documentation you won&#8217;t omit the <strong>Goals&#038;Benefits</strong> section, which clearly states the following under Goals:</p>
<p><center><i>Avoid platform dependencies</i></center></p>
<p>This simply means that the PureMVC is avoiding the use of Flex, and it&#8217;s originally designed not to use Flex. So, where is PureMVC applicable? I should say, it&#8217;s applicable to the design and development of big Flash applications, but in cases of big Flash applications it&#8217;s always good to take some time to consider doing it with Flex.</p>
<h3>Reference</h3>
<p><a href="http://puremvc.org/" alt="PureMVC.org">PureMVC.org</a> - the official site of the PureMVC framework</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/06/08/introduction-to-flex-applications-architecture-part-2-puremvc/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introduction to Flex Application&#8217;s Architecture - Part 1 - Cairngorm</title>
		<link>http://npacemo.com/wordpress/2008/05/28/introduction-to-flex-applications-architecture-part-1-cairngorm/</link>
		<comments>http://npacemo.com/wordpress/2008/05/28/introduction-to-flex-applications-architecture-part-1-cairngorm/#comments</comments>
		<pubDate>Wed, 28 May 2008 20:23:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Design]]></category>

		<category><![CDATA[Software Engineering]]></category>

		<category><![CDATA[Adobe Flex]]></category>

		<category><![CDATA[Alan Kay]]></category>

		<category><![CDATA[architecture]]></category>

		<category><![CDATA[Cairngorm]]></category>

		<category><![CDATA[feature driven development]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[front to back]]></category>

		<category><![CDATA[introduction]]></category>

		<category><![CDATA[methodology]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=48</guid>
		<description><![CDATA[Bony (a colleague of mine) and I were invited to make the closing lecture for the Flex course in Sofia University. They wanted us to make 2 consequent lectures that will summarize the whole course, but also leave the students the door wide open for new stuff to learn and experiment with. This led me [...]]]></description>
			<content:encoded><![CDATA[<p>Bony (a colleague of mine) and I were invited to make the closing lecture for the Flex course in Sofia University. They wanted us to make 2 consequent lectures that will summarize the whole course, but also leave the students the door wide open for new stuff to learn and experiment with. This led me to the decision to talk about architecture and instead of doing a thorough lecture on such a complex topic I wanted it to feel more like an introduction. I was afraid that a simple introduction will eventually leave the audience with empty hands, so I included some very typical Flex design patterns, related to Data Binding and Inversion of Control, but also wanted to share couple of approaches to Rich Internet Application development - Front to Back development and Feature Driven Development.</p>
<p/>
I usually prefer to use very short slides with just enough information on them, but I&#8217;m aware that this kind of slides are only effective during the presentation and completely useless after that. Publishing them is not enough, because they are very short and not very informative. So, I write this post in order to be used as notes accompanying the presentation.</p>
<p/>
Before rushing into the popular Flex application architectural frameworks we need to answer one question.</p>
<h3>Why architecture is important?</h3>
<p>Alan Kay gave a nice sample on importance of architecture in his OOPSLA&#8217;97 keynote and I will use it here too. We can build a decent dog house from almost anything - you just need a hammer, nails and some randomly picked wooden boards. Having a plan is not necessary, but even if we need one it is going to be very simple.<br />
<img style="margin: 20px 0 20px 0;" title="dog-house-drawing" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/dog-house-drawing.jpg" alt="Dog House Drawing" width="500" height="282" /><br />
Now, let&#8217;s expand this thing about the factor of a 100, thus we can get something with the size of a cathedral. Every engineer should know that scaling this thing 100 times, will actually increase its mass 1,000,000 times and its strength only by the factor of a 10,000, which actually means that the new construction is going to be 100 times weaker than the original dog house. Most probably it&#8217;s going to collapse under its own weight.<br />
<img style="margin: 20px 0 20px 0;" title="gothic-cathedral-drawing" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/gothic-cathedral-drawing.jpg" alt="Gothic Cathedral Drawing" width="500" height="332" /><br />
Well, if you want to stick with small creations and simple structures you don&#8217;t need an architecture. But if you want to deal with complex and big structures, then you should start getting interested in architecture - literary the designing and building of successful arches. But to build something expanded by the factor of a 100 we need a new concept - a non-obvious, non-linear interaction between simple materials that would give you a non-obvious synergies and a vast multiplication of materials. As complexity starts becoming more and more important architectures are always going to dominate material, which in the context of this topic simply means that architecture is always going to dominate the technology of our interest. That&#8217;s why architecture is important!</p>
<h3>A word on architectural frameworks</h3>
<p>A framework is defined as a set of cooperating classes that make up a reusable design for a specific type of software, but what&#8217;s an architectural framework? We can define an architectural framework as a set of cooperating design patterns that make up a reusable micro-architecture for a specific type of applications. Now as you know what an architectural framework is I can start making an overview of the popular Flex architectural frameworks.</p>
<h3>Cairngorm</h3>
<p>This is the most popular architectural framework for Flex. It is so popular that developers are starting to overexploit it, as it is some kind of a panacea for the design and development of RIAs. Well, if you have no experience at all, most probably you&#8217;ll start with Cairngorm, because of its straight forward usage and the fake sense of confidence it gives to beginners.</p>
<p/>
Generally speaking Cairngorm is an MVC micro-architecture composed from a <strong>FrontController</strong> which maps application specific events to commands, a <strong>ViewLocator</strong> which is a dictionary for <strong>ViewHelper</strong> classes, a <strong>ModelLocator</strong> which is the main abstract representation of the application state and data, and a <strong>ServiceLocator</strong> that stores the variety of services an application consumes. Most of the application logic goes in the <strong>Commands</strong> implementations. The easiest way to define a command is as the actions and logic that should be performed in response to the meaningful user gestures. By meaningful I refer not just to all user gestures, but only these that trigger the execution of the business logic behind the application.<br />
<a href="http://npacemo.com/wordpress/wp-content/uploads/2008/05/cairngorm2-rpc-600dpi.tif"><img style="margin: 20px 0 20px 0;" title="cairngorm-diagram-small" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/cairngorm-diagram-small.jpg" alt="Cairngorm Diagram" width="500" height="394" /></a><br />
It&#8217;s relatively easy to incorporate Front to Back Development when using the Cairngorm micro-architecture. Basically, you start with some <strong>View</strong>, define all user gestures and corresponding <strong>Events</strong> and <strong>Commands</strong> for that <strong>View</strong>. Because of the rich component set provided with the Flex framework developing a prototype that broadcasts the defined <strong>Events</strong> is a piece of cake. The next step is to implement  the corresponding <strong>Commands</strong>. Usually the commands are just updating locally the state of the application stored in the <strong>ModelLocator</strong> or before updating the model the data is processed remotely from a back end service. To implement such commands that require remote processing the Cairngorm team proposes the use of <strong>BusinessDelegates</strong> which encapsulate the whole request-result logic. You only need to configure the needed <strong>BusinessDelegate</strong> by providing it with <strong>result</strong> and <strong>fault</strong> handlers. Usually these handlers are functions within the <strong>Command</strong> that uses this <strong>BusinessDelegate</strong>. By the time you build the prototype, most probably you won&#8217;t have an available back end application. If that&#8217;s the case, you can use mockup <strong>BusinessDelegates</strong>, which process the data locally and return fake results. As soon as the back end is ready you can easily switch to remote processing and real data, but instead of waiting for this task to be accomplished you&#8217;ll have already evaluated the prototype with the customers and the precious feedback is going to be available much sooner, thus boosting requirements elicitation, customer communication and satisfaction, and drastically improve the overall user experience. </p>
<p/>
Another way to approach Flex application development is Feature Driven Development. First, you need to build the overall application model. Second or in parallel, you need to compile a list of required features. It is useful to map features to user gestures, which in the context of Cairngorm can be mapped to <strong>Commands</strong>. With Cairngorm it&#8217;s easy to streamline the development of <strong>Commands</strong> - you can easily define concrete steps for implementing every feature - something like, define and dispatch <strong>Event</strong> from <strong>View</strong>, create entries in the <strong>ModelLocator</strong>, implement the needed <strong>BusinessDelegate</strong>, implement the <strong>Command</strong> that updates the model and finally define a mapping in the <strong>FrontController</strong> between the <strong>Event</strong> and the <strong>Command</strong>. This type of streamlining can be useful within big projects with 10,000 features and a staff of 100 not very experienced developers. You start dividing this huge list of features into sets, that can be developed and deployed within short iterations - usually 2 weeks. Well, that&#8217;s a Feature Driven Development!</p>
<p/>
Don&#8217;t get me wrong Front to Back development and Feature Driven Development are not orthogonal approaches. Combining them is an intelligent decision, but this is a matter of a different discussion. </p>
<h3>Some words of warning</h3>
<p>By the time, you get to this paragraph, you should have some really nice impressions on Cairngorm. It looks like you can handle almost everything with this so influential framework, but you should be aware of the huge disadvantages, which you&#8217;re about to uncover in the middle of the development of your next big Rich Internet Application.</p>
<p/>
First, the number of <strong>Commands</strong> can easily grow from 10 to 1,000. By the time you hit the count of 100 you&#8217;ll realize that most of the <strong>Commands</strong> are very similar, just differing in the type of data they process. This huge number of <strong>Commands</strong> means huge number of classes, which leads to a huge size of the application, not to mention the annoying compilation time. You should start thinking about generalization and new ways to reuse this repetitive logic.</p>
<p/>
Second, as the project grows in complexity it&#8217;s model or application state stored in the <strong>ModelLocator</strong> are going to get very complicated. It&#8217;s kind of difficult to decompose this model into something smaller, more granular and not that monolithic.</p>
<p/>
Third, in cases of complicated user interaction the logic for that interaction appears too far from the <strong>View</strong>. <strong>Commands</strong> that need to manage and use the <strong>Views</strong> are utilizing the <strong>ViewHelper</strong> classes. While this sounds reasonable in the context of this architecture, I see no point in getting through the whole Cairngorm cycle of processing of events to execute some logic that should be rather positioned near the <strong>View</strong>. Well, it&#8217;s just the way how Cairngorm tries to uniformly treat every user gesture.</p>
<h3>What&#8217;s next?</h3>
<p>Part 2 of this topic is going to be about the <strong>PureMVC</strong> architectural framework. In Part 3 I plan to show you a very different approach - an approach more natural to Flex. You don&#8217;t need more to get more! So, stay tuned!</p>
<h3>Reference</h3>
<p><a href="http://npacemo.com/wordpress/wp-content/uploads/2008/05/introduction-flex-application-architecture.pdf" title="Introduction to Flex Application\'s Architecture">Introduction to Flex Application&#8217;s Architecture</a> - the slides of the talk I gave at the Sofia University<br />
<a href="http://video.google.com/videoplay?docid=-2950949730059754521&#038;q=alan+kay&#038;ei=J-4RSNS7LIe82wKR7uSeAg" title="Alan Key: The Computer Revolution hasn\’t happened yet OOPSLA 97">Alan Key: The Computer Revolution hasn’t happened yet OOPSLA 97</a><br />
<a href="http://www.cairngormdocs.org/" title="Cairngormdocs.org">CairngormDocs.org</a> - a community driven site, devoted on systematizing the documentation and learning resources for the Cairngorm micro-architecture for Adobe Flex.</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/05/28/introduction-to-flex-applications-architecture-part-1-cairngorm/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flex 3 Designer ScrollBar - Fixed Size ScrollThumb</title>
		<link>http://npacemo.com/wordpress/2008/05/20/flex-3-designer-scrollbar-fixed-size-scrollthumb/</link>
		<comments>http://npacemo.com/wordpress/2008/05/20/flex-3-designer-scrollbar-fixed-size-scrollthumb/#comments</comments>
		<pubDate>Tue, 20 May 2008 16:19:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Adobe Flex]]></category>

		<category><![CDATA[designer]]></category>

		<category><![CDATA[fixed size]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[Grant Skinner]]></category>

		<category><![CDATA[ScrollBar]]></category>

		<category><![CDATA[ScrollThumb]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=47</guid>
		<description><![CDATA[Recently Grant Skinner wrote about Designer ScrollBars in Flex 3 - this post is very useful in helping you amputate important usability features of the ScrollBars, but it omits another further disabling requirement which is also very common when implementing designer scrollbars. I&#8217;m talking about scrollbars with fixed size ScrollThumbs. One of the scrollbar features [...]]]></description>
			<content:encoded><![CDATA[<p>Recently Grant Skinner wrote about <a href="http://www.gskinner.com/blog/archives/2008/05/designer_scroll.html">Designer ScrollBars in Flex 3</a> - this post is very useful in helping you amputate important usability features of the <strong>ScrollBars</strong>, but it omits another further disabling requirement which is also very common when implementing designer scrollbars. I&#8217;m talking about scrollbars with fixed size <strong>ScrollThumbs</strong>. One of the scrollbar features is to set the size of the <strong>ScrollThumb</strong> according to the size of the content that needs to be scrolled. Take a look at the sample application - the scrollbars are skinned and the <strong>ScrollThumb</strong> is sized nicely (or not so nicely) according to the content:</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 205px;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="205" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="TestFixedSizeScrollThumb" /><param name="bgcolor" value="#869ca7" /><param name="align" value="middle" /><param name="src" value="http://npacemo.com/sample-applications/bin-release-scrollthumb/TestFixedSizeScrollThumb.swf" /><embed type="application/x-shockwave-flash" width="500" height="205" src="http://npacemo.com/sample-applications/bin-release-scrollthumb/TestFixedSizeScrollThumb.swf" align="middle" bgcolor="#869ca7" name="TestFixedSizeScrollThumb"></embed></object></div>
<p>Well, I find this feature very useful - the size of the <strong>ScrollThumb</strong> is giving the user a hint about the amount of content that needs scrolling. But vanity has almost never been in favor of usability, so I&#8217;ll have to share with you how to accomplish this further amputation of the scrollbar features.</p>
<p/>
To make a fixed size <strong>ScrollThumb</strong> you need to do roughly two things:<br />
1. To extend the <strong>ScrollThumb</strong> class by overriding the <strong>setActualSize()</strong> method.<br />
2. To replace the <strong>ScrollThumb</strong> on the existing <strong>ScrollBar</strong> instance.</p>
<p/>
I&#8217;m providing a sample application with a <strong>View Source</strong> option, so you can check how I&#8217;ve implemented the <strong>FixedSizeScrollThumb</strong> and how the scrollbar is skinned: </p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 205px;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="205" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="TestFixedSizeScrollThumb" /><param name="bgcolor" value="#869ca7" /><param name="align" value="middle" /><param name="src" value="http://npacemo.com/sample-applications/bin-release-fixedsizescrollthumb/TestFixedSizeScrollThumb.swf" /><embed type="application/x-shockwave-flash" width="500" height="205" src="http://npacemo.com/sample-applications/bin-release-fixedsizescrollthumb/TestFixedSizeScrollThumb.swf" align="middle" bgcolor="#869ca7" name="TestFixedSizeScrollThumb"></embed></object></div>
<p>I prefer to specify the size of the <strong>FixedSizeScrollThumb</strong> with styles. In case of a very tiny thumb it&#8217;s useful to make the <strong>hitArea</strong> of the thumb a bit larger. I use styles again to specify this additional padding for the <strong>hitArea</strong>.</p>
<p/>
Now, we&#8217;re ready to replace the traditional <strong>ScrollThumb</strong> with the new <strong>FixedSizeScrollThumb</strong>, and this is the most tricky and controversial part of the task. I use a simple utility class <strong>ScrollBarUtil</strong>, which provides the <strong>static replaceScrollThumb</strong> method:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
public static function replaceScrollThumb(scrollBar:ScrollBar):void
{
    if (scrollBar != null &#038;&#038; !(scrollBar.scrollThumb is FixedSizeScrollThumb))
    {
	scrollBar.removeChild(scrollBar.scrollThumb);

	var fixedSizeScrollThumb:FixedSizeScrollThumb = new FixedSizeScrollThumb();
	fixedSizeScrollThumb.x = scrollBar.scrollThumb.x;
	fixedSizeScrollThumb.y = scrollBar.scrollThumb.y;

	fixedSizeScrollThumb.styleName = new StyleProxy(scrollBar, null);
        fixedSizeScrollThumb.upSkinName = "thumbUpSkin";
	fixedSizeScrollThumb.overSkinName = "thumbOverSkin";
        fixedSizeScrollThumb.downSkinName = "thumbDownSkin";
	fixedSizeScrollThumb.iconName = "thumbIcon";
	fixedSizeScrollThumb.skinName = "thumbSkin";

	scrollBar.scrollThumb = fixedSizeScrollThumb;
	scrollBar.addChildAt(fixedSizeScrollThumb, scrollBar.getChildIndex(scrollBar.downArrow));
    }
}
</pre>
<p>This method needs an initialized <strong>ScrollBar</strong> instance, which you can get usually like this:</p>
<pre class="prettyprint" style="font-size: 12px; overflow: auto;">
ScrollBarUtil.replaceScrollThumb(
    ScrollBar(someFlexContainer.rawChildren.getChildByName("verticalScrollBar")));
</pre>
<p>By now, we know how to replace the <strong>ScrollThumb</strong>, but still we don&#8217;t know when to do it. Which is the moment when the container&#8217;s scrollbar is available and needs to change its thumb? In the sample above I&#8217;m using the <strong>updateComplete</strong> event handler of the <strong>Flex Container</strong>.</p>
<p/>
I know this <strong>ScrollBar</strong> looks more like a <strong>VSlider</strong> or <strong>HSlider</strong>, and maybe you will try using a skinned slider instead of a scrollbar, but you should be aware that this approach will need custom code to detect whether the content needs scrolling, which is already implemented in the <strong>Container</strong> class from the <strong>Flex Framework</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/05/20/flex-3-designer-scrollbar-fixed-size-scrollthumb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sprite or FlexSprite? Bitmap or FlexBitmap?</title>
		<link>http://npacemo.com/wordpress/2008/05/15/sprite-or-flexsprite-bitmap-or-flexbitmap/</link>
		<comments>http://npacemo.com/wordpress/2008/05/15/sprite-or-flexsprite-bitmap-or-flexbitmap/#comments</comments>
		<pubDate>Thu, 15 May 2008 15:05:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Adobe Flex]]></category>

		<category><![CDATA[Bitmap]]></category>

		<category><![CDATA[CompositeEffect]]></category>

		<category><![CDATA[flex]]></category>

		<category><![CDATA[FlexBitmap]]></category>

		<category><![CDATA[FlexSprite]]></category>

		<category><![CDATA[Sprite]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=46</guid>
		<description><![CDATA[If you have to make a very effects-intensive Adobe Flex application, you&#8217;re definitely going to face a lot of performance issues, which need optimization. One way to optimize is to use as less as possible UIComponent components. So instead of UIComponent you start using Sprite and Bitmap components where possible.

But you should be aware that [...]]]></description>
			<content:encoded><![CDATA[<p>If you have to make a very effects-intensive Adobe Flex application, you&#8217;re definitely going to face a lot of performance issues, which need optimization. One way to optimize is to use as less as possible <strong>UIComponent</strong> components. So instead of <strong>UIComponent</strong> you start using <strong>Sprite </strong>and <strong>Bitmap</strong> components where possible.</p>
<p/>
But you should be aware that Adobe Flex effects are designed to be used with <strong>UIComponent</strong> components, so replacing with <strong>Sprite</strong> and <strong>Bitmap</strong> will cause problems, which beside the obvious run-time errors, can be really difficult to debug and correct.</p>
<p/>
Let&#8217;s observe a typical issue with Flex <strong>CompositeEffect</strong> effects, such as <strong>Parallel</strong> and <strong>Sequence</strong> effects. I want to animate simultaneously some sprites - the sprites should move horizontally and fade slightly. But as you&#8217;ll see in the sample application, only the bottom sprite is animated, the rest two are just jumping to their end positions:</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 190px;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="190" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="TestFlexSprite" /><param name="bgcolor" value="#869ca7" /><param name="align" value="middle" /><param name="src" value="http://npacemo.com/sample-applications/bin-release-sprite/TestFlexSprite.swf" /><embed type="application/x-shockwave-flash" width="500" height="190" src="http://npacemo.com/sample-applications/bin-release-sprite/TestFlexSprite.swf" align="middle" bgcolor="#869ca7" name="TestFlexSprite"></embed></object></div>
<p>This is completely unexpected behavior and you will get no run-time error whatsoever. We should dig deep to see what&#8217;s going on?</p>
<p/>
Well, at least we see what&#8217;s happening. Only the bottom sprite is animated, so it looks like the <strong>Parallel</strong> is not getting its children effects targets correctly. Let&#8217;s see the <strong>CompositeEffect.getChildrenTargets()</strong> method. The following excerpts are getting my attention:</p>
<pre class="prettyprint" style="font-size: 12px;">
var resultsArray:Array = [];
var results:Object = {};
//&#8230;
results[childTargets[j].toString()] = childTargets[j];
//&#8230;
for (var p:String in results)
{
    resultsArray.push(results[p]);
}
return resultsArray;
</pre>
<p>The <strong>results </strong> object is an <strong>Object </strong>instead of a <strong>Dictionary</strong>, therefore only <strong>String</strong> can be used to index the child effect targets. But the <strong>sprite.toString()</strong> method will return always the same string <strong>[objects Sprite]</strong>, and  the <strong>results</strong> object will index only one of the sprites and eventually the <strong>resultsArray</strong> will end up containing only the last sprite.</p>
<p/>
To avoid that and to index all sprites with different strings, we can use <strong>FlexSprite </strong>instead of a simple <strong>Sprite</strong>. Actually the <strong>FlexSprite </strong>adds only a unique name to the <strong>Sprite </strong>and also overrides the <strong>toString()</strong> method with the use of the <strong>NameUtil</strong>:</p>
<pre class="prettyprint" style="font-size: 12px;">
override public function toString():String
{
    return NameUtil.displayObjectToString(this);
}
</pre>
<p>This implementation will return the string indicating the location of this object within the hierarchy of <strong>DisplayObjects</strong> in the <strong>Application</strong>.</p>
<p/>
This is the same sample application, but <strong>Sprite </strong>is now replaced with <strong>FlexSprite</strong>:</p>
<div style="margin: 20px 0 20px 0; width: 500px; height: 190px;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="190" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="name" value="TestFlexSprite" /><param name="bgcolor" value="#869ca7" /><param name="align" value="middle" /><param name="src" value="http://npacemo.com/sample-applications/bin-release-flexsprite/TestFlexSprite.swf" /><embed type="application/x-shockwave-flash" width="500" height="190" src="http://npacemo.com/sample-applications/bin-release-flexsprite/TestFlexSprite.swf" align="middle" bgcolor="#869ca7" name="TestFlexSprite"></embed></object></div>
<p>Now it functions as intended!<br />
<strong>FlexBitmap</strong> overrides <strong>Bitmap</strong> in exactly the same way, and you should always use <strong>FlexBitmap</strong> instead of <strong>Bitmap</strong> in such situations.</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/05/15/sprite-or-flexsprite-bitmap-or-flexbitmap/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Copying a file name to the clipboard on Mac OS X</title>
		<link>http://npacemo.com/wordpress/2008/05/11/copying-a-file-name-to-the-clipboard-on-mac-os-x/</link>
		<comments>http://npacemo.com/wordpress/2008/05/11/copying-a-file-name-to-the-clipboard-on-mac-os-x/#comments</comments>
		<pubDate>Sun, 11 May 2008 16:27:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Personal Computing]]></category>

		<category><![CDATA[clipboard]]></category>

		<category><![CDATA[copy]]></category>

		<category><![CDATA[file name]]></category>

		<category><![CDATA[finder]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[mac os x]]></category>

		<category><![CDATA[osx]]></category>

		<category><![CDATA[terminal]]></category>

		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=42</guid>
		<description><![CDATA[Well, to copy the file name and the location of the file to the clipboard on a Mac OS X and then paste it in your texts is not a common task. But imagine you need to do it. The most intuitive approach is to open the Finder application and navigate to the file. If [...]]]></description>
			<content:encoded><![CDATA[<p>Well, to copy the file name and the location of the file to the clipboard on a Mac OS X and then paste it in your texts is not a common task. But imagine you need to do it. The most intuitive approach is to open the <strong>Finder</strong> application and navigate to the file. If you need just the file name, without it&#8217;s location, you can just click on the name, thus entering in edit mode, then select the whole name and copy it with the <strong>Command-C</strong> keyboard shortcut.<br />
<img style="margin: 20px 0 20px 0;" title="click-select-file-name" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/click-select-file-name.jpg" alt="Click Select File Name Screenshot" width="500" height="154" /><br />
If you need not just the name but also the location of the file, most probably you&#8217;ll open the <strong>Get Info</strong> dialog for the specified file, and then just try to copy the text. Ooops, you can&#8217;t, because the text is not selectable.<br />
<img style="margin: 20px 0 20px 0;" title="open-get-info-dialog" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/open-get-info-dialog.jpg" alt="Open Get Info Dialog Screenshot" width="245" height="228" /><img style="margin: 20px 0 20px 10px;" title="get-info-dialog" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/get-info-dialog.jpg" alt="Get Info Dialog Screenshot" width="245" height="228" /><br />
On the Windows XP operating system the location of the file is selectable, so you can copy it to the clipboard. All you need to do is to open the <strong>Properties</strong> dialog:<br />
<img style="margin: 20px 0 20px 0;" title="copy-location-windows-properties-dialog" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/copy-location-windows-properties-dialog.jpg" alt="Copy File Location on Windows Screenshot" width="499" height="365" /><br />
I can&#8217;t think of a logical reason, why the Mac OS X designers have decided to make these texts not selectable. You can always write the file name and its location by hand, but there is a way to guarantee that you write it down correctly and also to speed up the writing of the file name.</p>
<p/>
To do that open the <strong>Terminal</strong> application, and start typing the change directory command, which is <strong>cd</strong> followed by the new location. When you type the location you can start with <strong>/</strong> - the root directory, type few symbols, then hit <strong>Tab</strong> and the command shell will try to auto complete the rest of the directory name, thus assuring you that what you type is correct.</p>
<p/>
You should be aware of that the command shell is case sensitive, so if the auto completion doesn&#8217;t work, probably you&#8217;ve started typing with the incorrect case. When you&#8217;ve done typing the file location, instead of executing the <strong>cd</strong> command, you can select and copy that location.<br />
<img style="margin: 20px 0 20px 0;" title="copy-file-location-from-terminal" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/copy-file-location-from-terminal.jpg" alt="Copy File Location From Terminal Screenshot" width="500" height="170" /><br />
If there are any spaces in the file location, the command shell will escape them prefixing every space with the <strong>\</strong> escaping symbol.</p>
<p/>
The moral of the story is that designers work rather with great variety of assumptions than with fixed requirements about how the creation is going to be used. In this particular case the <strong>Windows</strong> designers have predicted correctly that copying the file name might be in handy, in opposite to the <strong>Apple</strong> designers which have easily overlooked this mini feature.</p>
<p/>
To be honest I haven&#8217;t done any thorough research on how to accomplish copying the file name to the clipboard on <strong>Mac OS X</strong> and I&#8217;ve approached the problem as I would approach it in <strong>Windows</strong>. But it turns out that there is even easier way to copy the file name. You need to open the <strong>Finder</strong> application, navigate to the file location, select the file, then chose from the main menu <strong>Finder>Services>TextEdit>New Window Containing Selection</strong>. The <strong>TextEdit</strong> application will open a window that contains the file name encoded in URL encoding.<br />
<a href="http://npacemo.com/wordpress/wp-content/uploads/2008/05/copy-file-name-services-large.jpg"><img style="margin: 20px 0 20px 0;" title="copy-file-name-services-small" src="http://npacemo.com/wordpress/wp-content/uploads/2008/05/copy-file-name-services-small.jpg" alt="Copy File Name from Services Menu" width="500" height="307" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/05/11/copying-a-file-name-to-the-clipboard-on-mac-os-x/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://npacemo.com/wordpress/2008/05/10/hello-world/</link>
		<comments>http://npacemo.com/wordpress/2008/05/10/hello-world/#comments</comments>
		<pubDate>Sat, 10 May 2008 13:30:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[hello world]]></category>

		<category><![CDATA[introduction]]></category>

		<guid isPermaLink="false">http://npacemo.com/wordpress/?p=1</guid>
		<description><![CDATA[Starting a blog is not an easy task. There is so much to consider&#8230; But the whole process is genuinely fun, especially for a guy like me, who in its main time is doing solely programming to implement already designed layout, interactions and graphical requirements. Starting a blog is like picking into a designers&#8217; life, [...]]]></description>
			<content:encoded><![CDATA[<p>Starting a blog is not an easy task. There is so much to consider&#8230; But the whole process is genuinely fun, especially for a guy like me, who in its main time is doing solely programming to implement already designed layout, interactions and graphical requirements. Starting a blog is like picking into a designers&#8217; life, confronting with their problems and using their tools. It&#8217;s a whole new area of knowledge and completely different set of skills is required to get the job done. Separate post on what designers and programmers have in common is coming soon.</p>
<p>But now it&#8217;s time to explain shortly what this blog is going to be about.</p>
<p>As the title says it&#8217;s going to be about personal computing. It&#8217;s going to be a huge criticism on the current state of personal computing and it will reveal to you a very intimate and controversial journey towards an improved personal computing. I&#8217;m planing to publish not only technical stuff that you can use in your daily job, but also philosophical disputes about programming, software engineering, design in general and simply how to use computers to make our lives better. </p>
<p>Feеl free to suggest me topics to write about!</p>
<p>My first major post will be about how do I imagine a more sophisticated and yet simplified personal computing. This post should serve as a long-term goal and as an abstract roadmap of my journey towards a better personal computing.</p>
<p>In the mean time I&#8217;ll write about some Adobe Flex issues me and my colleagues in Gugga have discovered during our latest project. </p>
<p>So stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://npacemo.com/wordpress/2008/05/10/hello-world/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
