<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>foomonger&#039;s blog &#187; flash</title>
	<atom:link href="http://blog.foomonger.com/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.foomonger.com</link>
	<description>Tips and Musings on Software Development, Flash, and Flex</description>
	<lastBuildDate>Wed, 14 Jul 2010 20:18:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SwizLogger Helpers: SwizLoggerConfig and LoggerProcessor</title>
		<link>http://blog.foomonger.com/2010/03/20/swizlogger-helpers-swizloggerconfig-and-loggerprocessor/</link>
		<comments>http://blog.foomonger.com/2010/03/20/swizlogger-helpers-swizloggerconfig-and-loggerprocessor/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 23:46:56 +0000</pubDate>
		<dc:creator>Sam Ahn</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[custom processor]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[swiz]]></category>

		<guid isPermaLink="false">http://blog.foomonger.com/?p=142</guid>
		<description><![CDATA[I started using the SwizLogger recently and quickly realized I wanted to do the following:

Create ILogger instances without importing Swiz classes in my application classes
Easily add targets in MXML

#1 isn't a huge deal if you consider logging to be more of a system tool than an application dependency, but if I'm avoiding Singletons why not [...]]]></description>
			<content:encoded><![CDATA[<p>I started using the SwizLogger recently and quickly realized I wanted to do the following:</p>
<ol>
<li>Create ILogger instances without importing Swiz classes in my application classes</li>
<li>Easily add targets in MXML</li>
</ol>
<p>#1 isn't a huge deal if you consider logging to be more of a system tool than an application dependency, but if I'm avoiding Singletons why not keep it up. #2 also isn't a big deal because it doesn't take much ActionScript to add logging targets, but I think it makes a lot of sense to do it declaratively.</p>
<p>Piotr Walczyszyn created a <a title="LogProcessor" href="http://www.riaspace.net/2009/12/logprocessor-custom-metadata-processor-for-swiz-1-0-0/" target="_blank">custom LogProcessor</a> to address #1, but I didn't like how the TraceTarget was hard-coded into it. Instead of building more complex processor I decided to create a bare-bones <a title="LoggerProcessor" href="http://code.google.com/p/foomonger-swizframework/source/browse/trunk/FoomongerSwizFramework/src/com/foomonger/swizframework/processors/LoggerProcessor.as" target="_blank">LoggerProcessor</a> and <a title="SwizLoggerConfig" href="http://code.google.com/p/foomonger-swizframework/source/browse/trunk/FoomongerSwizFramework/src/com/foomonger/swizframework/utils/SwizLoggerConfig.as" target="_blank">SwizLoggerConfig</a> class.</p>
<p>Here's an example application's source (the SWF is just a button):  <a title="SwizLoggerConfigExample" href="http://www.foomonger.com/swizframework/SwizLoggerConfigExample/srcview/" target="_blank">Source</a></p>
<p>The LoggerProcessor is again bare-bones. All it does is inject an ILogger instance using SwizLogger:</p>
<pre class="actionscript"><span style="color: #66cc66;">&#91;</span>Logger<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> logger:ILogger;</pre>
<p><br/><br />
The LoggerProcessor priority is set to be one above [Inject] so the injected ILoggers are available at [Inject] and [PostConstruct].</p>
<p>SwizLoggerConfig doesn't do too much either. It's just provides a default public Array property which is used to add targets to the SwizLogger.</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:Application</span> <span style="color: #000066;">xmlns:mx</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span>
        <span style="color: #000066;">xmlns:utils</span>=<span style="color: #ff0000;">&quot;com.foomonger.swizframework.utils.*&quot;</span>
        <span style="color: #000066;">xmlns:view</span>=<span style="color: #ff0000;">&quot;example.view.*&quot;</span>
        <span style="color: #000066;">xmlns:local</span>=<span style="color: #ff0000;">&quot;*&quot;</span>
        <span style="color: #000066;">layout</span>=<span style="color: #ff0000;">&quot;absolute&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:Script<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #339933;">&lt;![CDATA[</span>
<span style="color: #339933;">            import mx.logging.LogEventLevel;</span>
<span style="color: #339933;">        ]]&gt;</span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx:Script<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;utils:SwizLoggerConfig<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:TraceTarget</span>
                <span style="color: #000066;">includeCategory</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
                <span style="color: #000066;">includeDate</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
                <span style="color: #000066;">includeLevel</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
                <span style="color: #000066;">includeTime</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
                <span style="color: #000066;">level</span>=<span style="color: #ff0000;">&quot;{LogEventLevel.INFO}&quot;</span>
                <span style="color: #000066;">filters</span>=<span style="color: #ff0000;">&quot;*&quot;</span>
                <span style="color: #000066;">fieldSeparator</span>=<span style="color: #ff0000;">&quot; | &quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/utils:SwizLoggerConfig<span style="font-weight: bold; color: black;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;local:SwizLoggerConfigExampleSwiz</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;view:MainView</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx:Application<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<p><br/></p>
<p>The value of these classes will depend on your personal style and preference. I wrote them so I like them. They're available on <a href="http://code.google.com/p/foomonger-swizframework/" target="_blank">Google Code</a>.</p>
<p>Happy coding.</p>
<p><br/><br />
* Update: Here's the MXML syntax for adding multiple packages to the filters Array:</p>
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:TraceTarget</span>
        <span style="color: #000066;">includeCategory</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
        <span style="color: #000066;">includeDate</span>=<span style="color: #ff0000;">&quot;false&quot;</span>
        <span style="color: #000066;">includeLevel</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
        <span style="color: #000066;">includeTime</span>=<span style="color: #ff0000;">&quot;true&quot;</span>
        <span style="color: #000066;">level</span>=<span style="color: #ff0000;">&quot;{LogEventLevel.INFO}&quot;</span>
        <span style="color: #000066;">fieldSeparator</span>=<span style="color: #ff0000;">&quot; | &quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx:filters<span style="font-weight: bold; color: black;">&gt;</span></span></span>
        [&quot;foo.bar.*&quot;, &quot;com.foomonger.*&quot;]
    <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx:filters<span style="font-weight: bold; color: black;">&gt;</span></span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx:TraceTarget<span style="font-weight: bold; color: black;">&gt;</span></span></span>
&nbsp;</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.foomonger.com%2F2010%2F03%2F20%2Fswizlogger-helpers-swizloggerconfig-and-loggerprocessor%2F&amp;linkname=SwizLogger%20Helpers%3A%20SwizLoggerConfig%20and%20LoggerProcessor"><img src="http://blog.foomonger.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.foomonger.com/2010/03/20/swizlogger-helpers-swizloggerconfig-and-loggerprocessor/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Testable-Driven Development</title>
		<link>http://blog.foomonger.com/2010/02/23/testable-driven-development/</link>
		<comments>http://blog.foomonger.com/2010/02/23/testable-driven-development/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 15:53:10 +0000</pubDate>
		<dc:creator>Sam Ahn</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test-driven-development]]></category>
		<category><![CDATA[testable-driven development]]></category>

		<guid isPermaLink="false">http://blog.foomonger.com/?p=96</guid>
		<description><![CDATA[Test-driven development. Tried it. Sometimes loved it. Rest of the time hated it.
I think TDD is great when you know what the code should do. When I'm writing parsing code or something else very utilitarian I definitely prefer to write the tests first. As a Flex/Flash developer, most of my code is directly for the [...]]]></description>
			<content:encoded><![CDATA[<p>Test-driven development. Tried it. Sometimes loved it. Rest of the time hated it.</p>
<p>I think TDD is great when you know what the code should do. When I'm writing parsing code or something else very utilitarian I definitely prefer to write the tests first. As a Flex/Flash developer, most of my code is directly for the UI, and often I find that I'm not entirely sure what my code should do right away. I'm becoming a big fan of the Presentation Model pattern, but even with that, I find that it takes exploratory development to determine exactly which component should do what and which logic should go where.  I found it very burdensome to update both the regular code and tests step-by-step . Not being a TDD expert I could easily be doing something or interpreting something incorrectly. Or perhaps I'm just lazy.</p>
<p>I've decided, at least when it comes to UI development, to follow a looser <strong>Test</strong><em><strong>able</strong></em><strong>-driven development</strong> technique. As I'm fleshing out my component logic, I constantly ask myself, "Is this code testable?" or more generally "How will I know if this works?" This primitive technique gives me the freedom to write exploratory code while helping to reign in potential magic logic. I then write tests once things have settled down, refactoring any logic to make things more testable as necessary. This technique also fits my style of coding where I like to sketch out logic with small tracer bullets.  It definitely takes some discipline to think about the testability of the code, but so far I'm much more comfortable with testable-driven development for UI work.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fblog.foomonger.com%2F2010%2F02%2F23%2Ftestable-driven-development%2F&amp;linkname=Testable-Driven%20Development"><img src="http://blog.foomonger.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://blog.foomonger.com/2010/02/23/testable-driven-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
