<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Revisiting J2ME Object Serialization</title>
	<link>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/</link>
	<description>Java ME Tutorials and Tips by Eric Giguere</description>
	<pubDate>Thu, 28 Aug 2008 20:54:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Eric Giguere, J2ME expert and author</title>
		<link>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/#comment-34</link>
		<dc:creator>Eric Giguere, J2ME expert and author</dc:creator>
		<pubDate>Wed, 26 Jul 2006 22:02:16 +0000</pubDate>
		<guid>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/#comment-34</guid>
		<description>When I emailed the reader with my suggestion, I didn't actually provide any code, just a description of what to do.... so for this post I added a bit of code and I tried to make it simple. But there you go proving my point about how you need to keep optimizing! :-)</description>
		<content:encoded><![CDATA[<p>When I emailed the reader with my suggestion, I didn&#8217;t actually provide any code, just a description of what to do&#8230;. so for this post I added a bit of code and I tried to make it simple. But there you go proving my point about how you need to keep optimizing! <img src='http://j2me.synclastic.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stefan haustein</title>
		<link>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/#comment-33</link>
		<dc:creator>stefan haustein</dc:creator>
		<pubDate>Wed, 26 Jul 2006 20:50:48 +0000</pubDate>
		<guid>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/#comment-33</guid>
		<description>Well, if you do not have a static list of classes, the 'cname.equals( "com.mypackage.Employee" )' approach does not work out, so I took that for granted :)</description>
		<content:encoded><![CDATA[<p>Well, if you do not have a static list of classes, the &#8216;cname.equals( &#8220;com.mypackage.Employee&#8221; )&#8217; approach does not work out, so I took that for granted <img src='http://j2me.synclastic.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Giguere, J2ME expert and author</title>
		<link>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/#comment-32</link>
		<dc:creator>Eric Giguere, J2ME expert and author</dc:creator>
		<pubDate>Wed, 26 Jul 2006 20:43:12 +0000</pubDate>
		<guid>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/#comment-32</guid>
		<description>Hi Stefan, thanks for your comments. Yes, a hash table is another possible way to handle the problem if it's the class lookup that's slow. If the instantiation view newInstance is slow that's another problem. The reader didn't test both cases so I don't know what the specific problem was, though I suspect it was the class lookup.

As for your other comments:

1. You have to remember that with the J2ME Tech Tips I write code that is both compact and generic as much as possible. So that's why I stored classnames in the stream. Yes, if you had a static list of classes to work from then what you suggest is a good thing to do.

2. Agreed, and that's in fact what I've done in my own programs.

3. Again yes, though properly serializing subclasses is tricky and requires a good deal of thought.

Eric</description>
		<content:encoded><![CDATA[<p>Hi Stefan, thanks for your comments. Yes, a hash table is another possible way to handle the problem if it&#8217;s the class lookup that&#8217;s slow. If the instantiation view newInstance is slow that&#8217;s another problem. The reader didn&#8217;t test both cases so I don&#8217;t know what the specific problem was, though I suspect it was the class lookup.</p>
<p>As for your other comments:</p>
<p>1. You have to remember that with the J2ME Tech Tips I write code that is both compact and generic as much as possible. So that&#8217;s why I stored classnames in the stream. Yes, if you had a static list of classes to work from then what you suggest is a good thing to do.</p>
<p>2. Agreed, and that&#8217;s in fact what I&#8217;ve done in my own programs.</p>
<p>3. Again yes, though properly serializing subclasses is tricky and requires a good deal of thought.</p>
<p>Eric</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: stefan haustein</title>
		<link>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/#comment-31</link>
		<dc:creator>stefan haustein</dc:creator>
		<pubDate>Wed, 26 Jul 2006 20:37:21 +0000</pubDate>
		<guid>http://j2me.synclastic.com/2006/07/25/revisiting-j2me-object-serialization/#comment-31</guid>
		<description>Hi Eric,

did you try to use a hashtable to cache the mapping from class names to Class objects? 

BTW:

1. Why not use a static final int constants for all the classes (including those implementing persistent, not only primitive types), and then have a single large switch block? This will make the serialized data more compact and avoid string creation overhead while reading from the file. Make sure the code compiles to a jump table by chosing constants carefully. 

2. Use resurect(DataInputStream dis) to avoid (possibly nested) byte array and stream creation overhead.

3. If you implement "public static Object resurrect(DataInputStream dis)", you can re-use this method it in the resurrect method of classes implementing Persistent, supporting polimorphism when reading members.

Best regards,
Stefan</description>
		<content:encoded><![CDATA[<p>Hi Eric,</p>
<p>did you try to use a hashtable to cache the mapping from class names to Class objects? </p>
<p>BTW:</p>
<p>1. Why not use a static final int constants for all the classes (including those implementing persistent, not only primitive types), and then have a single large switch block? This will make the serialized data more compact and avoid string creation overhead while reading from the file. Make sure the code compiles to a jump table by chosing constants carefully. </p>
<p>2. Use resurect(DataInputStream dis) to avoid (possibly nested) byte array and stream creation overhead.</p>
<p>3. If you implement &#8220;public static Object resurrect(DataInputStream dis)&#8221;, you can re-use this method it in the resurrect method of classes implementing Persistent, supporting polimorphism when reading members.</p>
<p>Best regards,<br />
Stefan</p>
]]></content:encoded>
	</item>
</channel>
</rss>
