<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Big Endian - Do you know what your bytes are doing RIGHT NOW?</title>
	<atom:link href="http://bigendian.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigendian.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 27 Aug 2009 20:28:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='bigendian.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Big Endian - Do you know what your bytes are doing RIGHT NOW?</title>
		<link>http://bigendian.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://bigendian.wordpress.com/osd.xml" title="Big Endian - Do you know what your bytes are doing RIGHT NOW?" />
	<atom:link rel='hub' href='http://bigendian.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Important updates from Microsoft (KB970653)</title>
		<link>http://bigendian.wordpress.com/2009/08/27/important-updates-from-microsoft-kb970653/</link>
		<comments>http://bigendian.wordpress.com/2009/08/27/important-updates-from-microsoft-kb970653/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 20:27:17 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Found online]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Personal Computing]]></category>
		<category><![CDATA[operating systems]]></category>
		<category><![CDATA[updates]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=97</guid>
		<description><![CDATA[Not every "important" update is actually that important. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=97&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been on vacation for a couple of weeks, trying first to battle the <a href="http://www.apple.com">Evil Overlords</a> (details on that later) and then spending some time at the <a href="http://www.il4all.com/files/images/215.jpg">beach </a>(and yes, that&#8217;s the actual beach.. ) but this afternoon, when I laid my sunburned hands on the keyboard, I encountered the friendly (and highly obnoxious) icon in the system try telling my that I had new updates for my Vista system. Including one &#8220;Important&#8221; update for windows, and two &#8220;recommended&#8221; updates.  I thought that was a little odd, since I&#8217;ve just installed a bunch of updates a couple of days ago. Every time I install updates it\s a pain because I have to stop everything I&#8217;m doing and restart my machine. So it was with some trepidation that I clicked the system icon, and sure enough, it told me I would have to restart after I apply these changes. Yuck.</p>
<p>Well it doesn&#8217;t do to leave your system unpatched, I thought, and if Microsoft has updates for my machine, and labels them &#8220;important&#8221; I should probably install them right away, right? Especially if they have gone out of their way and released a second update package in the same week, got to be crucial.</p>
<p>Not so much. Turns out that <a href="http://support.microsoft.com/kb/970653">KB970653 </a>- the update in question &#8211; was an update to the time zone feature in my windows system. Apparently the people at Microsoft were so worried that I&#8217;d get the time wrong on my system that they felt the need to push out a special update package, and make me restart my system, just so that the timer wont be off.</p>
<p>Now I agree that the system time functions are important, especially if you are running database systems or servers. But for most of us, simple mortals who just use our computers for everyday life. Is all this hassle really necessary? Couldn&#8217;t this wait for the normal <a href="http://en.wikipedia.org/wiki/Patch_Tuesday">Update Tusday</a> cycle? It makes me wonder what other junk Microsoft pushes down the pipe just because no one actually bothers to check if those &#8220;important&#8221; and &#8220;critical&#8221; updates really are all that crucial. Those of use who were around a few years ago probably remember Microsoft&#8217;s &#8220;Critical&#8221; update <a href="http://office.microsoft.com/en-us/downloads/HA011071511033.aspx">KB833404 </a>that was put out in 2004 for every MS Office product there was. You&#8217;d think that a &#8220;critical&#8221; update for ALL of Office meant that they found and fixed some gaping security hole or something, but no, that critical update did nothing more than remove two swastika symbols that ended up in the wrong font. <a href="http://www.pcmag.com/article2/0,2817,1526828,00.asp">I&#8217;m not making this up</a>.</p>
<p>Personally, I opted not to install the important update just yet. When I&#8217;m done with my vacation, and the laptop gets shutdown anyway so I can take to work, then I&#8217;ll do it. Until then I will stay with me, alas, not accurate time zone info. In the meantime, if anyone in Microsoft is reading this, I&#8217;d like to offer one thought: Before you randomly label updates as important and critical, you might want to take a moment to re-read the story about the boy who cried wolf. Not every update deserves panic mode treatment. Thanks.</p>
<p>B.E.</p>
<br />Posted in Found online, Microsoft, Personal Computing Tagged: Microsoft, operating systems, updates <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/97/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/97/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/97/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=97&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/08/27/important-updates-from-microsoft-kb970653/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>Side Channel attacks</title>
		<link>http://bigendian.wordpress.com/2009/08/03/side-channel-attacks/</link>
		<comments>http://bigendian.wordpress.com/2009/08/03/side-channel-attacks/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 09:23:51 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Found online]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Cool sites]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=94</guid>
		<description><![CDATA[Side Channel attacks can defeat the best security before it even has a chance to work<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=94&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Last month I attended <a href="http://www.itsoc.org/people/chapters/israel-section-chapter/events/cryptoday-2009-1">Cryptoday 2009</a> &#8211; a workshop on cryptography and security hosted by the Computer Science department of the <a href="http://www.cs.technion.ac.il/">Technion</a>. Amongst the lectures there was one by <a href="http://www.wisdom.weizmann.ac.il/~naor/">Prof. Moni Naor</a> of the <a href="http://www.weizmann.ac.il/">Weizmann Institute</a> that focused on the feasibility of, and defense from, certain kinds of attacks on security that circumnavigate traditional encryption by attempting to read information directly from the physical medium. Attacks which are known as &#8220;<a href="http://en.wikipedia.org/wiki/Side-channel_attack">side-channel</a> attacks&#8221;.</p>
<p>I&#8217;m mentioning this because the June issue of <a href="http://www.scientificamerican.com">Scientific American Magazine</a> published a really interesting article on the topic titled &#8220;<a href="http://www.scientificamerican.com/article.cfm?id=hackers-can-steal-from-reflections">How Hackers Can Steal Secrets from Reflections</a>&#8221; which explains this kind of attack in a simple and interesting language. It&#8217;s a little far fetched, but well worth reading.</p>
<p>B.E.</p>
<br />Posted in Found online, Internet, Security Tagged: Cool sites, Security <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=94&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/08/03/side-channel-attacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>Reflection and Singletons</title>
		<link>http://bigendian.wordpress.com/2009/07/29/reflection-and-singletons/</link>
		<comments>http://bigendian.wordpress.com/2009/07/29/reflection-and-singletons/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 12:39:23 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Programming workarounds]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[Singletons]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=90</guid>
		<description><![CDATA[Using Reflection to call a Singleton can be be tricky... If you're not sure if it's really a Singleton.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=90&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>*** Posted on <a href="http://bigendian.wordpress.com">http://bigendian.wordpress.com</a> All rights reserved ***</p>
<p>Java reflection is one of those tools that you may go for years without using, and never miss it. Until the day comes that you have to invoke methods without knowing what they are in advance. When that happens, reflection will be the thing that would prevent you from jumping off the nearest cliff. IF you do it right.</p>
<p>Invoking a method by reflection is fairly straight forward: You get a Class object that describes the class of the method that you are trying to use, get the method you want, and create a method object that represents that method. I wont go into the details or code for this, but you can find a fairly comprehensive guide <a href="http://java.sun.com/docs/books/tutorial/reflect/TOC.html">here</a>.</p>
<p>The tricky part starts when you attempt to invoke the method. The signature for invoking a method requires an object that the method is invoked on, and the list of parameters. In other words, if you are trying to invoke method myMethod() from Class MyClass, the reflection API wants to know which object of MyClass do you want to call that method. The API even goes a step further and lets you specify that a new object should be created for this by invoking the Class.newInstance() method which calls the default no-args constructor of the class. So far so good.</p>
<p>But what happens if the class you are trying to call is a singleton? (I know I said that <a href="http://bigendian.wordpress.com/2009/07/20/java-singletons-dont-exist/">Java doesn&#8217;t have real singletons</a>, but what it does have behaves enough like a singleton to cause this problem) Remember that in a singleton, there are no public constructors, and the only way to get an object of the class is by calling getInstance(). Unfortunately, if you are using reflection you can run into a situation where the object you are invoking at any particular iteration may or may not be a singleton and you wont know in advance, and calling newInstance() on a singleton will definitely not work as advertised. So what do you do?</p>
<p>What you can try to do is something like this:</p>
<pre style="padding-left:30px;">Object obj = null;
Class&lt;?&gt; cls = Class.forName(className);
Method methodIWantToInvoke = cls.getMethod(methodName, Params);

try{
     Method getinst = cls.getMethod("getInstance",null);
     obj = getinst.invoke(null, null);
     }catch(NoSuchMethodException n){
     try {
         obj = cls.newInstance();
     } catch (InstantiationException e) {
      e.printStackTrace();
     }
 }
Object result = methodIWantToInvoke.invoke(obj, params);</pre>
<p>What you are doing here is using reflection to get an object so that you can use reflection to invoke a method. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If the Class object cls describes a class that is a singleton, then the request to getMethod(getInstance(), null) will give ou back a Method object that you can invoke to get the instance of the singleton you need. If it isn&#8217;t a singleton, it will throw a MethodNotFoundException, in which case you know you can use plain old newInstance you invoke the constructor.  Either way, but the end of this, you can an Object that you can then pass to the method you originally wanted to invoke in order to invoke it.</p>
<p>Note that the order of actions here is arbitrary: You can just as easily call newInstance first and then (upon getting an IllegalAccessException) try getInstance(). You can also combine this with a static factory method to allow calling of constructors other than the no-args, which adds to your flexibility.</p>
<p>Using reflection is realy not as complicated as it might seem, but there are (at least) two things you must by mindful of:</p>
<p>1. Reflection is slow and heavy. It adds a lot of overhead to your code and should be used very judiciously (for a bit of insight to the overhead, checkout Dennis Sosnoski&#8217;s <a href="http://www.ibm.com/developerworks/java/library/j-dyn0603/">Java programming dynamics</a> article. It&#8217;s a little dated, and reflection HAS become more efficient, but it&#8217;s still no where near directly coding)</p>
<p>2. One of the more common uses of reflection is with serialization, to examine and use de-serialized objects. This is exactly where Java Singletons fails. If you have an Object that was serialized and then deserialized in different JVMs, even though you can successfully call its getInstance() method with the code above, you are still not getting the same object.</p>
<p>Good luck, and happy coding,</p>
<p>B.E.</p>
<br />Posted in Java, Programming Tagged: Java, Programming workarounds, Reflection, Singletons <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=90&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/07/29/reflection-and-singletons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>Java Singletons don&#8217;t exist.</title>
		<link>http://bigendian.wordpress.com/2009/07/20/java-singletons-dont-exist/</link>
		<comments>http://bigendian.wordpress.com/2009/07/20/java-singletons-dont-exist/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 07:23:48 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[coding pitfalls]]></category>
		<category><![CDATA[Programming workarounds]]></category>
		<category><![CDATA[Singletons]]></category>
		<category><![CDATA[Threaded programming]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=85</guid>
		<description><![CDATA[Singletons are great tools for coordinating application states. Except when they're not really singular. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=85&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>*** Posted on <a href="http://bigendian.wordpress.com">http://bigendian.wordpress.com</a> All rights reserved ***</p>
<p>When I first started in my current project I set down to a code review with the lead programmer to see &#8220;my&#8221; project. At some point during the review, the man pointed to a certain class that was being used as part of the startup sequence for the application and said &#8220;this should be reimplemented as a singelton&#8221;. Up until then I was following him closely, but that statement took me by surprise, because as far as I knew, singletons don&#8217;t exist in Java.</p>
<p>To understand why, we have to look at the definition of a Singelton:</p>
<p style="padding-left:30px;"><em>A singleton is a pattern that permits exactly one object that is needed to coordinate actions across the system.</em></p>
<p style="text-align:left;">In other words, whereever I am, if I try to use a class that is defined as a singleton, I would always, always, get the SAME object.  Usually, a native implementation of a Singleton looks something like this:</p>
<pre style="text-align:left;">public final class MySingleton{

private MySingelton me=null;

private MySingleton(){
   ...instantiation code here...
}

public Mysingelton getInstance(){
  if (null==me) me = new MySingelton();
  return me;
}

}</pre>
<p>As you can see, MySingleton has no public contractors. It can&#8217;t be directly instantiated or inherited. You can only get a MySingleton Object by calling getInstance(), which always returns the same object. This makes the singleton very handy for coordinating actions across a system. System states, for example, can be saved as singletons, as can factories, shared queues (a synchronized singleton), thread states, etc. Everywhere in the system that you can the singleton&#8217;s name, you&#8217;re guarantied to have the exact same object returned to you.</p>
<p>So why are there no Java singletons? Clearly the code above is written in Java and would run in Java, and would function as expected in a Java program. The reason this is not a singleton is the last part of the singleton definition &#8220;across the system&#8221;.</p>
<p>Consider: In C++, I can use code very much like the one above to tell me if a program has been launched. On the first time that the program runs, it asks for the singleton object, gets it (after it has been allocated by the system) and modifies it to indicate that it had been launched. If the program is then launched again, the second instance of the program would request and get the SAME singleton, see that the &#8220;running&#8221; state has already been set, and exit. The singleton is used across the system in coordinate states.</p>
<p>In Java, on the other hand, every program instance would run in its own instance of the JVM. This means that when the second instance of the program is launched, it would NOT get the same object as the first instance, but rather it would get the instance that has just been instantiated in its own JVM. The code above can coordinate across the same JVM, but it fails to coordinate across the system. Therefore, it does not qualify as a true singleton.</p>
<p>This may seem like splitting hairs, but it&#8217;s a very important thing to know. The guy I set with in the code review was pointing at a class who&#8217;s job was to make sure only one instance of the application would ever launch. We work on a project that does network measurements and topographies. It sends out packets with different addresses and TTLs and uses the returns to map the Internet. If we have two instances of the application running at the same time, we may not know which packet was sent by which instance, and our results would be compromised. Furthermore: We allow our users to run the application as a service, or as a standalone GUI based program. If we don&#8217;t have mutual exclusion, we can run into a situation where a user had installed the service AND the GUI, and starts both, thinking that the GUI just reflects the service. This could very easily lead to corruption in our data, and problems in the whole research.  All because Java singletons aren&#8217;t really singletons.</p>
<p style="text-align:left;">The good news is that in 95% of the cases, the code above would work quite nicely as a singleton. So long as you are staying within the JVM, it&#8217;s fine. For the last 5%, there are workarounds that can make mutual exclusion possible in Java. I will post about that some other time, though.</p>
<p style="text-align:left;">Good Coding,</p>
<p style="text-align:left;">B.E.</p>
<br />Posted in Java, Programming Tagged: coding pitfalls, Java, Programming workarounds, Singletons, Threaded programming <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=85&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/07/20/java-singletons-dont-exist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>Just because it&#8217;s not an error doesn&#8217;t mean it&#8217;s right</title>
		<link>http://bigendian.wordpress.com/2009/07/15/just-because-its-not-an-error-doesnt-mean-its-right/</link>
		<comments>http://bigendian.wordpress.com/2009/07/15/just-because-its-not-an-error-doesnt-mean-its-right/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 13:53:02 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Code Readability]]></category>
		<category><![CDATA[coding pitfalls]]></category>
		<category><![CDATA[Coding Style]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=82</guid>
		<description><![CDATA[Improving code readability is one of the best things you can do for the person who has to maintain the code after you. Especially if it IS you. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=82&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>*** This post belongs to <a href="http://bigendian.wordpress.com">http://bigendian.wordpress.com</a>, all rights reserved ***</p>
<p>I was working on a PHP script the other day, and the damn bastard just wouldn&#8217;t work. I mean, the code was fine, no errors, no problems in compilation or anything like that. It ran perfectly, except that it didn&#8217;t do what I wanted. Worse than that: it was inconsistent about it, sometimes it was fine, and sometimes the results just didn&#8217;t make sense. It all depended on the input it got.</p>
<p>After much head scratching and dark thoughts about throwing my computer out the window and becoming a Shepperd, I found the problem: in one of the functions that was suppose to cleanse the input had a call to <a href="http://us.php.net/manual/en/function.strripos.php">strripos</a> when it really needed a call to <a href="http://us.php.net/manual/en/function.strrpos.php">strrpos</a>, happens.</p>
<p>The thing is that this really shouldn&#8217;t happen, and if it does it shouldn&#8217;t take so long to diagnose. What a function does should be immediately and unambiguously clear by looking at its name. when you have strripos and strrpos, strtr and strstr, and stripslashes and stripcslashes, that makes it very hard to understand the code. I consider this readability problem to be one of the most fundamental flaws of PHP as a language. Luckily, this was a fairly simple and easily tested script. But consider having to read through 10,000 lines of code just to figure this out. (Yes, I know, you wouldn&#8217;t actually read all the code, you&#8217;d debug and trace the problem. But the point still stands that the code is harder to read)</p>
<p>Java, thankfully, does not do this. The naming conventions in Java describe ways to avoid this kind of scenario by outlining method names like &#8220;toString&#8221; &#8220;getVariable&#8221; and &#8220;isValid&#8221; which are self-explanatory. But this does not mean that Java is innocent of sin. Consider this scenario: You have a class MyClass and you need to write two constructors for it. Each constructor gets a JFrame and a String, and based on which ones it gets, it will show different information in the frame.</p>
<p>Now, since these are constructors, you can&#8217;t give them different names. And since they both have the same number and types of variables, you can&#8217;t distinguish them that way. So what you end up doing is distinguishing between them based on the variable order: One constructor is going to be MyClass (String, JFrame) and the other will be MyClass(JFrame, String). All perfectly legal in Java and aren&#8217;t you smart.</p>
<p>But now you face the same problem that I faced earlier in PHP: your method calls are non-descriptive and you can&#8217;t, based on the method name and signature, tell which constructor your actually using. Sure, you remember which is which now, but what about in six months when you have to get back to it and you&#8217;ve forgotten it all, or worse, someone has to maintain your code?</p>
<p>There are several solutions to avoid this kind of problem. My personal favorite is the one suggested by Joshua   Bloch in his book &#8220;<a href="http://www.sun.com/books/catalog/effective_java.xml">Effective Java</a>&#8221; where he recommends using static factory methods instead of constructors.  Consider the two constructors above: If you made them private and instead added static methods with distinct names <span style="color:#3366ff;">static getNewMyClassA <span style="color:#000000;">and <span style="color:#3366ff;">static getNewMyClassB <span style="color:#000000;">you would eliminate the confusion and make it unambiguously clear as to which method does what. Furthermore, you&#8217;d gain much greater control over your Object creation, allowing your class to offer objects out of a pool, for example, rather than creating a new object every time. You also have a polymorphic </span></span></span></span>advantage: a static method can return an object of any subclass of its return type, which can be handy.</p>
<p>Debugging and maintaining code are some of the most challenging tasks that a programmer can face. Sometimes, making the code more readable can be the only thing between you and a life as a walking sheepdog. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>B.E.</p>
<br />Posted in General, Java, PHP, Programming Tagged: Code Readability, coding pitfalls, Coding Style, Java, PHP <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/82/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/82/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/82/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=82&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/07/15/just-because-its-not-an-error-doesnt-mean-its-right/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>Google ChromeOS  &#8211; a non-event</title>
		<link>http://bigendian.wordpress.com/2009/07/09/google-chromeos-a-non-event/</link>
		<comments>http://bigendian.wordpress.com/2009/07/09/google-chromeos-a-non-event/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 13:58:43 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Future of Computing]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[operating systems]]></category>
		<category><![CDATA[Search Engines]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=79</guid>
		<description><![CDATA[ChromeOS is poised to change the world for a very small number of people.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=79&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>*** Posted on<a href="http://bigendian.wordpress.com"> <span>http://bigendian.wordpress.com</span></a>. All rights reserved. ***</p>
<p>The net is abound with buzz nowadays about the a<a href="http://googleblog.blogspot.com/2009/07/introducing-google-chrome-os.html">announcement of a Google &#8220;Operating System&#8221;</a> due to come out the second quarter of 2010. Yawn..</p>
<p>Beyond the discussion of what qualifies this as an Operating System, for which I will direct you to two excellent articles by <a href="http://www.techcrunch.com/2009/07/08/google-chrome-redefining-the-operating-system/">TechCrunch </a>and<a href="http://www.theregister.co.uk/2009/07/09/dzuiba_google_chrome_redux/"> The Register</a> (Caution: colorful language), there is also the question of what the product actually is. According to Google, the Chrome OS is &#8220;<em>Google Chrome running within a new windowing system on top of a Linux kernel.</em>&#8221; In other words: Install Linux, Install Chrome, take away anything that isn&#8217;t Chrome, and expect who ever is using this to only use tools that run in Chrome. Seems to me this should take about a week for a competent System guy to do, assuming he has to write his own scripts.</p>
<p>So what&#8217;s the big deal here? The &#8220;new Windowing system&#8221;? Gnome, KDE, and the rest aren&#8217;t good enough for you, you need something that will launch Chrome automatically without showing a Desktop first? I mean seriously, what are they going to be spending a year on?</p>
<p>The answer is as simple as it is sad: they are going to spend the next year on trying to make Chrome do things the way a real OS does, and on trying to make Web-apps function like real apps. With all kinds of hocus pocus like HTML 5, <a href="http://gears.google.com/">Google Gears</a>, and G-D knows what else, they&#8217;re going to try and develop a comparable platform for running the programs you need inside a browser.   I doubt they&#8217;ll succeed, and I seriously doubt that they can do it in a year.</p>
<p>And that&#8217;s the bottom line. No one really cares is the OS they use come from Microsoft, Mac, Linux, or Ed&#8217;s computer shopp and live tackle, they simply want to install their applications (that they&#8217;ve been using for years) and have them work. Period. This is the reason that after a great valiant run at Linux, I came back to Windows. It let me do the things I wanted, and have been doing for over a decade, without having to re-learn and re do everything. Trying to get everyone to shift paradigms and move to Google Docs is one thing (and a daunting task at that). The fact that Google Docs <strong>can&#8217;t</strong> do everything that office can is completely different. In the larger scheme of the corporate world, a $200 saving on a computer with a free OS is nothing compered to the amount of time, and hence money, wasted on trying to relearn years of established ways to do things.</p>
<p>There&#8217;s even more to is than that. As the <a href="http://www.theregister.co.uk/2009/07/09/dzuiba_google_chrome_redux/">Register </a>points out:</p>
<p><em>But it&#8217;s not just Office that will keep Microsoft&#8217;s hold on the PC market. Can  you replace Active Directory with a web app? Is there a site I can visit to  connect to my office&#8217;s shared printer? What do you mean World of Warcraft  doesn&#8217;t run in the browser? How do I play a DVD in Google Chrome?</em></p>
<p>And he&#8217;s absolutly right: The greatness of a true OS is that it can run ANYTHING, not just thing that are written in the limited context of the Internet. And if a program is installed on my hard drive it will run with or without a network connection, and can access and modify the files on my drive without the fear that sudden server congestion will break it. Until ChromeOS can claim even a little of that, it is not Operating System, it&#8217;s a non-event.</p>
<p>Good Weekend,</p>
<p>B.E.</p>
<br />Posted in Browsers, Future of Computing, Internet, Technology Tagged: Chrome, Google, operating systems, Search Engines <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/79/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=79&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/07/09/google-chromeos-a-non-event/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>A rose by any other name&#8230; Object serilization and the Java JVM</title>
		<link>http://bigendian.wordpress.com/2009/07/06/a-rose-by-any-other-name-object-serilization-and-the-java-jvm/</link>
		<comments>http://bigendian.wordpress.com/2009/07/06/a-rose-by-any-other-name-object-serilization-and-the-java-jvm/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 20:23:45 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[coding pitfalls]]></category>
		<category><![CDATA[Coding Style]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=71</guid>
		<description><![CDATA[Java serialization can be a very powerful tool, but you have to do it the way it want to be done.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=71&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom:0;">***This post belongs to <a href="http://bigendian.wordpress.com">http://bigendian.wordpress.com</a>. All rights reserved ***</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Consider the two classes <a href="http://bigendian.wordpress.com/sample-code/serialization-example/">here</a>. They&#8217;re identical in every meaningful way. The one on top belongs to a server application of some sort, whereas the one on the bottom belongs to the client to the same server. Both classes have the exact same members, methods, and constructors. Both have the same name. And both implement the serializable interface, which designates them as being able to be written out and read as complete objects. If you are not familiar with the wonderful world of Java serialization, look <a href="http://java.sun.com/developer/technicalArticles/Programming/serialization/">here</a></p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Now lets say that I have a server program that looks something like this:</p>
<p style="margin-bottom:0;">
<pre style="margin-bottom:0;padding-left:30px;">ServerSocket sSocket = new ServerSocket(12345);</pre>
<pre style="margin-bottom:0;padding-left:30px;">Socket iSocket = sSocket.accept();</pre>
<pre style="margin-bottom:0;padding-left:30px;">ObjetOutputStream OOS = new ObjectOutputStream(iSocket.getOutputStream());</pre>
<pre style="margin-bottom:0;padding-left:30px;">OOS.writeObject(new MyClass(10));</pre>
<pre style="margin-bottom:0;padding-left:30px;">ObjectInputStream OIS = new ObjectInputStream(iSocket.getInputStream()):</pre>
<pre style="margin-bottom:0;padding-left:30px;">MyClass aMyClass = (MyClass)OIS.readObject();</pre>
<pre style="margin-bottom:0;padding-left:30px;">System.out.println(aMyClass.getT());</pre>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">We also have a client class that looks like this:</p>
<p style="margin-bottom:0;">
<pre style="margin-bottom:0;padding-left:30px;">Socket cSocket = new Socket(IP_CONSTANT, 12345);</pre>
<pre style="margin-bottom:0;padding-left:30px;">ObjectInputStream cOIS = new ObjectInputStream(cSocket.getInputStream());</pre>
<pre style="margin-bottom:0;padding-left:30px;">MyClass cMyClass = (MyClass) cOIS.readObject();</pre>
<pre style="margin-bottom:0;padding-left:30px;">ObjectOutputStream cOOS = new ObjectOutputStream(cSocket.getOutputStream());</pre>
<pre style="margin-bottom:0;padding-left:30px;">cOOS.writeObject(new MyClass(10+cMyClass.getT());</pre>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">If you&#8217;re not sure about the flow here, it goes like this:</p>
<p style="margin-bottom:0;">Server runs, and blocks on accept();</p>
<p style="margin-bottom:0;">client runs, connects to server, and blocks on readObject</p>
<p style="margin-bottom:0;">server unblocks at accept, transmits a MyClass object on the stream and blocks on readObject()</p>
<p style="margin-bottom:0;">client unblocks on read, gets the Object object, casts it to a MyClass object (since readObject() returns an object of type Object), manipulates it, and sends it back to the server.</p>
<p style="margin-bottom:0;">server unblocks on read, gets the Object object, casts it to a MyClass object, gets the value from it and prints it out</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Now here&#8217;s a trick question: What the final output of the server program?</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Well as it turns out the output is an exception that looks something like this:</p>
<pre style="margin-bottom:0;"><span>java.io.EOFException
 at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
 at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
 at java.io.ObjectInputStream.&lt;init&gt;(ObjectInputStream.java:280)</span></pre>
<p style="margin-bottom:0;"><span>Furthermore, the client program will throw it&#8217;s own exception:</span></p>
<pre style="margin-bottom:0;"><span>java.lang.ClassNotFoundException: com.mycomp.myprod.server.common.MyClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
</span></pre>
<p>What happened?  We serialized an object, sent it over a stream, deserialized it, cast it back and then did it again the other way. This is exactly what serialization is designed for. Yet it seems to fail even at this humble level.</p>
<p>The critical error is the ClassNotFound exception for MyClass.  The JVM can&#8217;t find an object that fits this discription, so it throws an error. This causes the receiver to not run at all; which in turn causes the sender to shutdown with an End Of File. Although both the server and the client have a copy of MyClass, and as we&#8217;ve shown in the beginning of the post, they are identical, the JVM isn&#8217;t happy. It doesn&#8217;t just want an identical class, it wants the <strong>same</strong> class. client.MyClass and server.MyClass may be identical, but they&#8217;re not the same.</p>
<p>If you think about it, this makes a lot of sense. The JVM has no way of knowing that client.MyClass and server.MyClass are the same. As far as it knows there are also a foo.MyClass, a bar.MyClass, and an iphonesarebad.MyClass, each with different purposes and construction. But when the JVM reads the object head from the stream, it is told to look for a server.MyClass, and that&#8217;s exactly what it does. No class, no dice.</p>
<p>Note that this is not a ClasssCastFailed exception. The JVM never gets that far, and never gets to try and cast the object into the local form of MyClass. It simply looks for a class on the output side of the stream that matches the class that was present on the input side of the stream which means looking in the the directory specified by the class name (/<span>com/mycomp/myprod/server/common) for the file specifed by the class name (MyClass.java).</span></p>
<p><span>How do you get around this? Simple: Make sure that in both client and server the class you are serializing resides in the same relative path. This way, when the JVM looks in the path to find the class definition, it actually finds it, and everyone is happy. If you are really slick, you can put all of the code that&#8217;s common between the client and the server in its own JAR, but&#8217;s that&#8217;s a discussion for a different day. </span></p>
<p><span>B.E.<br />
</span></p>
<br />Posted in Java, Programming Tagged: coding pitfalls, Coding Style, Java <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=71&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/07/06/a-rose-by-any-other-name-object-serilization-and-the-java-jvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>IPhone fun, yet again</title>
		<link>http://bigendian.wordpress.com/2009/07/05/iphone-fun-yet-again/</link>
		<comments>http://bigendian.wordpress.com/2009/07/05/iphone-fun-yet-again/#comments</comments>
		<pubDate>Sun, 05 Jul 2009 09:26:12 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[cell phones]]></category>
		<category><![CDATA[Iphone]]></category>
		<category><![CDATA[Mobile computing]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=68</guid>
		<description><![CDATA[The Iphone 3Gs is broken. It's also jailbroken.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=68&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For anyone who&#8217;s missed this:</p>
<p><a href="http://www.newsfactor.com/story.xhtml?story_id=010000KUKNB6"><span><strong>Teen Releases First Jailbreak App for iPhone 3GS</strong></span></a></p>
<p>You&#8217;d figure Apple would learn eventually and stop trying to lock down it&#8217;s products&#8230; Oh, wait.</p>
<p>B.E.</p>
<br />Posted in Mobile, Technology Tagged: cell phones, Iphone, Mobile computing <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=68&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/07/05/iphone-fun-yet-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>The epitome of gimmick</title>
		<link>http://bigendian.wordpress.com/2009/07/01/the-epitome-of-gimmick/</link>
		<comments>http://bigendian.wordpress.com/2009/07/01/the-epitome-of-gimmick/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 13:46:01 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Found online]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[Iphone]]></category>
		<category><![CDATA[Search Engines]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=63</guid>
		<description><![CDATA[Here today, gone tomorrow. <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=63&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>*** The original address for this post is <a href="http://bigendian.wordpress.com">http://bigendian.wordpress.com</a>. If you read this post anywhere else, it means: A. It&#8217;s stolen.  and B. You read some mighty boring sites (That would steal THIS). <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   ***</p>
<p>I haven&#8217;t had much time to update in the past couple of days (lots of fun Java work) but I wanted to share a small site which I think is a serious contender to the &#8220;Epitome of Gimmick&#8221; award:<a href="http://blackle.com/"> http://blackle.com/</a></p>
<p>The concept is simple: Darkness takes less energy than light, therefore, if we make our screen entirely black, it will take less energy than if it were white (like Google).</p>
<p>It&#8217;s a gimmick for two reasons.</p>
<p>A. Depending on your screen, <a href="http://www.scientificamerican.com/article.cfm?id=fact-or-fiction-black-is">black may actually take more energy than white</a>, and</p>
<p>B. If you had said this five years ago, people would have looked at you like you&#8217;re nuts and asked you if you didn&#8217;t have anything better to do. If you say it five years from now, people would look at you like you&#8217;re nuts and ask we don&#8217;t you invest your energy in some REAL energy saving solutions.  But now, right now, people are already concerned enough about the environment to listen to things like this, and clueless enough to actually follow them. This leads to a site which has no distinction other than its color scheme becoming a major destination on the Net.</p>
<p>Something that isn&#8217;t special, but has something that looks special enough to attract your attention. Yup, that a gimmick alright. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Personaly, I&#8217;m waiting for the <a href="http://www.who-sucks.com/tech/15-reasons-why-apples-iphone-sucks">IPhone </a>app that would blacken the touch screen&#8230;</p>
<p>Ok, Back to JavaLand.</p>
<p>B.E.</p>
<br />Posted in Found online, Internet, Mobile, Technology Tagged: environment, Iphone, Search Engines <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/63/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/63/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/63/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=63&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/07/01/the-epitome-of-gimmick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>
	</item>
		<item>
		<title>Asking questions that mean something.</title>
		<link>http://bigendian.wordpress.com/2009/06/28/asking-questions-that-mean-something/</link>
		<comments>http://bigendian.wordpress.com/2009/06/28/asking-questions-that-mean-something/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 10:36:50 +0000</pubDate>
		<dc:creator>bigendian</dc:creator>
				<category><![CDATA[Future of Computing]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Search Engines]]></category>

		<guid isPermaLink="false">http://bigendian.wordpress.com/?p=61</guid>
		<description><![CDATA[Search Engines can help you look, if you know what you're looking for.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=61&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a trivia question for all the minutia lovers out there: <strong>what former US surgeon general looks like colonel sanders and has a name that has something to do with chickens?</strong></p>
<p>Go ahead. Type that into <a href="http://www.google.com">Google</a>, <a href="http://www.bing.com/">bing</a>, or <a href="http://www00.wolframalpha.com/">Wolfarm alpha</a>, and see what you get. Chances are it&#8217;ll be a long laundry list having to do with <a href="http://thecaucus.blogs.nytimes.com/2009/01/06/cnn-medical-correspondent-as-surgeon-general/?hp">Obama picking his surgeon general</a>, <a href="http://www.kentuckyfriedchicken.com/">KFC</a>, or <a href="http://www.clown-forum.com/political-jokes/3511-why-did-chicken-cross-road.html">chicken jokes</a>. In fact, you will get a whole load of matches to your query, but you will not one simple thing: an answer.</p>
<p>This is, of course, because search engines don&#8217;t understand questions. They simply scan your search terms for keywords and try to give you relevant pages. They do some rudimentary grammar analysis to try and determine the subject of the query (IE the thing you are actually looking for) but more often than not, they get it wrong (which is why you get more entries about chicken then the surgeon general). Search engines have a hard time with descriptions, too. A &#8216;man who looks like a thing&#8217; is the sort of thing that a search engine simply can&#8217;t handle. And finally, search engines can get easily confused in determining what pages to return that might contain an answer (Consider this post, for example, it has links to search engines, chicken jokes, and observations about grammar. If you had to quantify it by keywords, you&#8217;d end up with some mighty odd matches)</p>
<p>I say this because there has been a trend recently of creating &#8220;answer engines&#8221; &#8211; search engines that can understand your question and miraculously supply you with the answer. It started a few years ago with &#8220;ask Jeeves&#8221; (now part of <a href="http://ask.com">ask.com</a>) and had its latest arrivals in the much publicized Wolfarm Alpha and the bing &#8220;decision engine&#8221;. Sadly it seems that hype aside, there really is no noticable difference between a search engine and a answer engine, with the possible exception of Wolfarm &#8211; the first engine that has the desency to tell you when it doesn&#8217;t understand what you want.</p>
<p>I&#8217;m not faulting search engines developers, mind you. Understanding plain-English questions is a hugh and daunting task, and the field is really only init&#8217;s infancy. Search engines have gotten a lot better over the past few years, and will continue to improve (and users will continue to get better in searching, which is a different topic for a different day.) But we&#8217;re still far far away from the day when all the knowledge of the Internet is at our fingertips. Search engines can fill in many details, but they&#8217;re no replacment for a structured approche to learning,  no replacement for simple thirst for knowledge, and no good in trivia. At least, not yet.</p>
<p>Big Endian.</p>
<p>P.S.</p>
<p>For anyone who&#8217;s wondering, the answer is</p>
<div class="wp-caption alignnone" style="width: 235px"><a href="http://en.wikipedia.org/wiki/C._Everett_Koop"><img title="C. Everett Koop" src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/36/C_Everett_Koop.jpg/225px-C_Everett_Koop.jpg" alt="C. Everett Koop" width="225" height="284" /></a><p class="wp-caption-text">C. Everett Koop</p></div>
<p>a great name, if I ever heard one.</p>
<br />Posted in Future of Computing, Internet, Technology Tagged: Search Engines <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bigendian.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bigendian.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bigendian.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bigendian.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bigendian.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bigendian.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bigendian.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bigendian.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bigendian.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bigendian.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bigendian.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bigendian.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bigendian.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bigendian.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bigendian.wordpress.com&amp;blog=8017559&amp;post=61&amp;subd=bigendian&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bigendian.wordpress.com/2009/06/28/asking-questions-that-mean-something/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/11efe03816030e1872bbe591c658bca4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bigendian</media:title>
		</media:content>

		<media:content url="http://upload.wikimedia.org/wikipedia/commons/thumb/3/36/C_Everett_Koop.jpg/225px-C_Everett_Koop.jpg" medium="image">
			<media:title type="html">C. Everett Koop</media:title>
		</media:content>
	</item>
	</channel>
</rss>
