<?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:georss="http://www.georss.org/georss">

<channel>
	<title>the source</title>
	<atom:link href="http://www.zebrafive.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zebrafive.com</link>
	<description>www.zebrafive.com</description>
	<pubDate>Tue, 01 Dec 2009 01:08:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>Java Coding - Best Practises - 1</title>
		<link>http://www.zebrafive.com/2009/12/java-coding-best-practises-1/</link>
		<comments>http://www.zebrafive.com/2009/12/java-coding-best-practises-1/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 00:54:17 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
		
		<category><![CDATA[Java]]></category>

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

		<category><![CDATA[Best practices]]></category>

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

		<guid isPermaLink="false">http://www.zebrafive.com/?p=5</guid>
		<description><![CDATA[<br/>This is the first in a series of posts covering best practices for java coding.
As with most things in life, there are few hard-and-fast rules. Best practices for Java coding are no exception. Treat the following as guidelines, and remember to add comments to your code wherever you choose to ignore them.

Don&#8217;t use strings in [...]]]></description>
			<content:encoded><![CDATA[<br/><p>This is the first in a series of posts covering best practices for java coding.</p>
<p>As with most things in life, there are few hard-and-fast rules. Best practices for Java coding are no exception. Treat the following as guidelines, and remember to add comments to your code wherever you choose to ignore them.<br />
<span id="more-5"></span></p>
<h3>Don&#8217;t use strings in loops</h3>
<pre><span style="color: #ffffff;">String numbers = "";
for(int i = 0;i &lt; 10; i++) {
    numbers = numbers + "," + i;
}</span></pre>
<p>This code is inefficient because in each loop it creates an immutable string and then in the next loop discards the string and replaces it with a new one. This leads to poor performance.</p>
<p>Instead, use the StringBuilder (Java 1.6+) or StringBuffer (Java 1.4+). They are both mutable strings.</p>
<pre><span style="color: #ffffff;">StringBuilder sb = new StringBuilder();
for(int i = 0; i &lt; 10; i++) {
    sb.append(",");
    sb.append(i);
}
String numbers = sb.toString();</span></pre>
<h3>Testing strings for equality</h3>
<p>To avoid null pointer exceptions when testing for equality between a string variable and a constant string, always use the constant string first.</p>
<pre><span style="color: #ffffff;">public void doLoginStuff(final String action) {
    if("login".equals(action) {
        // do something
    } else {
        // do something else
}</span></pre>
<p>Unless you want the code to throw a null pointer exception, in which case you should generally provide a comment explaining why.</p>
<h3>Don&#8217;t use magic numbers or strings</h3>
<p>Consider the following code:</p>
<pre><span style="color: #ffffff;">if(obj.getWorkflowState() == 53) {
   // do something
}</span></pre>
<p>1. The meaning of 53 is completely unknown without further investigation.<br />
2. A developer could change this value to some other integer and completely break the code (even though it would compile).</p>
<p>Use an enum instead:</p>
<pre><span style="color: #ffffff;">public enum WorkflowState {
    NEW(0),
    DATA_SAVED(53),
    CLOSED(162);

    private int workflowStateNumber;

    WorkflowState(final int stateNumber) {
        workflowStateNumber = stateNumber;
    }

    public String toString() {
        return "Workflow State: " + workflowStateNumber;
    }
}

// now when you want to use it (as before):

if(WorkflowState.DATA_SAVED.equals(obj.getWorkflowState()) {
   // do something
}</span></pre>
<p>1.  It is much more obvious what the if statement means.<br />
2. There is now a compile-time check that reduces the risk of a mistake.</p>
<p>Note also that the constant is specified first in the if statement. This avoids any possible null pointer exception that would otherwise have been thrown if obj.getWorkflowState() had returned null.</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=the%20source&amp;siteurl=http%3A%2F%2Fwww.zebrafive.com%2F&amp;linkname=Java%20Coding%20-%20Best%20Practises%20-%201&amp;linkurl=http%3A%2F%2Fwww.zebrafive.com%2F2009%2F12%2Fjava-coding-best-practises-1%2F"><img src="http://www.zebrafive.com/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Save/Bookmark"/></a>

	</p>]]></content:encoded>
			<wfw:commentRss>http://www.zebrafive.com/2009/12/java-coding-best-practises-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Solving the Soap Cross Domain Problem for Flash Player 9,0,124,0</title>
		<link>http://www.zebrafive.com/2008/06/solving-the-soap-cross-domain-problem-for-flash-player-901240/</link>
		<comments>http://www.zebrafive.com/2008/06/solving-the-soap-cross-domain-problem-for-flash-player-901240/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 03:05:43 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
		
		<category><![CDATA[Rich Internet Applications]]></category>

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

		<category><![CDATA[Cross Domain File]]></category>

		<category><![CDATA[Flash Player]]></category>

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

		<guid isPermaLink="false">http://www.zebrafive.com/?p=4</guid>
		<description><![CDATA[<br/>Recently, the Flash Player update (9,0,124,0) crippled one of our clients&#8217; sites by stopping the Flash-based application from making Soap calls to a web server other than the one that served the SWF.
Despite consulting various internet resources, we were unable to find any solution that worked. Wade Arnold&#8217;s blog entry came the closest, but unfortunately [...]]]></description>
			<content:encoded><![CDATA[<br/><p>Recently, the Flash Player update (9,0,124,0) crippled one of our clients&#8217; sites by stopping the Flash-based application from making Soap calls to a web server other than the one that served the SWF.</p>
<p>Despite consulting various internet resources, we were unable to find any solution that worked. <a href="http://wadearnold.com/blog/?p=17" target="_blank">Wade Arnold&#8217;s blog entry</a> came the closest, but unfortunately included a tag that stopped even previous versions of the Flash Player from working.<br />
<span id="more-4"></span><br />
The following crossdomain.xml file is the working solution that we came up with. In production, you should restrict the &#8216;domain=&#8217; fields to the domains that serve your SWFs.</p>
<pre>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE cross-domain-policy SYSTEM
"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt;
&lt;cross-domain-policy&gt;
  &lt;allow-access-from domain="*" /&gt;
  &lt;allow-http-request-headers-from domain="*" headers="*" /&gt;
&lt;/cross-domain-policy&gt;
</pre>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=the%20source&amp;siteurl=http%3A%2F%2Fwww.zebrafive.com%2F&amp;linkname=Solving%20the%20Soap%20Cross%20Domain%20Problem%20for%20Flash%20Player%209%2C0%2C124%2C0&amp;linkurl=http%3A%2F%2Fwww.zebrafive.com%2F2008%2F06%2Fsolving-the-soap-cross-domain-problem-for-flash-player-901240%2F"><img src="http://www.zebrafive.com/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Save/Bookmark"/></a>

	</p>]]></content:encoded>
			<wfw:commentRss>http://www.zebrafive.com/2008/06/solving-the-soap-cross-domain-problem-for-flash-player-901240/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Flash Player 9 Update 3 and the Socket Policy File</title>
		<link>http://www.zebrafive.com/2008/06/flash-player-socket-policy-file/</link>
		<comments>http://www.zebrafive.com/2008/06/flash-player-socket-policy-file/#comments</comments>
		<pubDate>Sat, 07 Jun 2008 00:32:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Rich Internet Applications]]></category>

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

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

		<category><![CDATA[Flash Player]]></category>

		<category><![CDATA[Socket Policy File]]></category>

		<guid isPermaLink="false">http://www.zebrafive.com/?p=3</guid>
		<description><![CDATA[<br/>With the release of Flash player 9 Update 3, many Flash applications are beginning to break due to Flash&#8217;s new socket policy rules.
The executive summary is that a server that allows Flash Player to connect to its sockets must now provide a socket policy file on either port 843 or the port that the player [...]]]></description>
			<content:encoded><![CDATA[<br/><p>With the release of Flash player 9 Update 3, many Flash applications are beginning to break due to <a href="http://flexbits.wordpress.com/2008/05/07/adobes-new-flash-socket-policy-rules/" target="_blank">Flash&#8217;s new socket policy rules</a>.</p>
<p>The executive summary is that a server that allows Flash Player to connect to its sockets must now provide a socket policy file on either port 843 or the port that the player is connecting to.<br />
<span id="more-3"></span><br />
There are several scripts available for <a href="http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html" target="_blank">setting up a socket policy file server on port 843 on linux</a> to solve this problem, but how do you test if your socket server is running correctly before opening the port up to the world through your firewall?</p>
<p>The following java source and class file is one way to check that the socket server is responding correctly. Download the class file (or source, if you know how to build it for your environment) and upload to your server:</p>
<ul>
<li><a href="http://www.zebrafive.com/wp-content/uploads/Flash843/Flash843.java" target="_blank">Flash843.java</a></li>
<li><a href="http://www.zebrafive.com/wp-content/uploads/Flash843/Flash843.class" target="_blank">Flash843.class</a> (built for Java 1.4.2)</li>
</ul>
<p>For information on using the utility:</p>
<p>/path-to-java/bin/java Flash843 -h</p>
<p class="addtoany_share_save_container">
    <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?sitename=the%20source&amp;siteurl=http%3A%2F%2Fwww.zebrafive.com%2F&amp;linkname=Flash%20Player%209%20Update%203%20and%20the%20Socket%20Policy%20File&amp;linkurl=http%3A%2F%2Fwww.zebrafive.com%2F2008%2F06%2Fflash-player-socket-policy-file%2F"><img src="http://www.zebrafive.com/wp-content/plugins/add-to-any/share_save_171_16.gif" width="171" height="16" alt="Share/Save/Bookmark"/></a>

	</p>]]></content:encoded>
			<wfw:commentRss>http://www.zebrafive.com/2008/06/flash-player-socket-policy-file/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
