<?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>Making the Complex Simple &#187; Java</title>
	<atom:link href="http://simpleprogrammer.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://simpleprogrammer.com</link>
	<description>Software Development from John Sonmez&#039;s Perspective</description>
	<lastBuildDate>Tue, 07 Feb 2012 17:47:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='simpleprogrammer.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Making the Complex Simple &#187; Java</title>
		<link>http://simpleprogrammer.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://simpleprogrammer.com/osd.xml" title="Making the Complex Simple" />
	<atom:link rel='hub' href='http://simpleprogrammer.com/?pushpress=hub'/>
		<item>
		<title>OAuth and REST in Android: Part 2</title>
		<link>http://simpleprogrammer.com/2011/06/04/oauth-and-rest-in-android-part-2/</link>
		<comments>http://simpleprogrammer.com/2011/06/04/oauth-and-rest-in-android-part-2/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 20:49:34 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Web Services]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/2011/06/04/oauth-and-rest-in-android-part-2/</guid>
		<description><![CDATA[In my last post we went over OAuth in general and we looked at how to use a Java library called Leeloo to authenticate with a service providing an OAuth 2 implementation. Now that we are able to authenticate a service with OAuth, we need to be able to actually use that service to do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1346&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://simpleprogrammer.com/2011/05/25/oauth-and-rest-in-android-part-1/">last post</a> we went over OAuth in general and we looked at how to use a Java library called Leeloo to authenticate with a service providing an OAuth 2 implementation.</p>
<p>Now that we are able to authenticate a service with OAuth, we need to be able to actually use that service to do something useful.</p>
<p>Many popular web service APIs like Facebook and Twitter provide a REST based implementation.</p>
<p>In this post I’ll show you how to easily connect to one of these web services from Android and parse any responses you get back.</p>
<p><a href="http://complextosimple.files.wordpress.com/2011/06/androidrest.png"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;" title="AndroidREst" border="0" alt="AndroidREst" src="http://complextosimple.files.wordpress.com/2011/06/androidrest_thumb.png?w=422&#038;h=366" width="422" height="366" /></a></p>
<h2></h2>
<h2>Should I use a REST library?</h2>
<p>This is a valid question we should address before getting into the details.</p>
<p>My answer to this question is basically “no.”</p>
<p>I first tried the approach of using a REST library to make it easier to communicate to a REST based web service, but quickly found the overhead of the library was more than the benefit it provided.</p>
<p>If you come from a background of calling XML and SOAP based web services, you might be surprised by this answer.&#160; With SOAP based web services it was a huge benefit to use a library to generate a proxy for you to call the web service and let you not have to worry about parsing XML and SOAP headers.</p>
<p>With REST it is completely different.&#160; The whole point of moving to REST based web services is to simplify the process of calling web services.</p>
<p>Most REST based web service interfaces are extremely simple to use.&#160; The idea is that the URL itself contains as much of the data as possible and additional data is included in the POST body.</p>
<p>By adding the complexity of learning a REST library and implementing the proper interfaces required to make it work seamlessly, we can easily add more complexity and overhead than just creating a HTTP request ourselves and parsing the responses.</p>
<p>For this approach I am going to show you how to do just that.</p>
<h2></h2>
<h2>Calling the REST service</h2>
<p>In order to call a REST service in Android we are going to first have to discover and understand the REST API provided to us, then make the appropriate calls with the OAuth token we got from authenticating.&#160; Finally, we will parse the result of the call and get back our response.</p>
<p><strong>Discovering the API</strong></p>
<p>Because REST is not really a standard, but rather an ideal, there is not a standard way REST APIs are implemented.</p>
<p>You’ll have to take a look at the documentation for the REST API you want to call to figure out exactly what a call should look like.</p>
<p>In general though a REST API will involve making some kind of HTTP GET, POST, PUT or DELETE request and passing data through the URL or in the request body.</p>
<p>Here is an example of the Dailymile.com API which I have been recently integrating my app to use.</p>
<p>You can see the full <a href="http://www.dailymile.com/api/documentation">API documentation here.</a></p>
<p>For this API, I am going to show you how I am creating a workout entry using a post.</p>
<p><strong>Making the REST call</strong></p>
<p>In order to make a REST call in Android, we are going to use a <em>HttpClient</em> object and the appropriate http request class.</p>
<p>In this example we are going to use the JSONObject class to create some data in JSON format that we can pass to the REST call by embedding it in the post.</p>
<p>I looked at the API for posting a workout entry to Dailymile, and the format of the request should look like this:</p>
<p><a title="https://api.dailymile.com/entries.json?oauth_token=" href="https://api.dailymile.com/entries.json?oauth_token">https://api.dailymile.com/entries.json?oauth_token=</a>&lt;token&gt;</p>
<p>The API also indicates that it expects the post body to contain some JSON and gives us a list of required and optional entries that need to be in that JSON object.</p>
<p>Let’s take a look at how I am making this call and then we’ll break it down some.</p>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:f8610da6-d295-47dd-9ae4-a02b7d443e4f" class="wlWriterEditableSmartContent">
<pre style="white-space:normal;">
<pre class="brush: java; pad-line-numbers: true;">
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
	&quot;https://api.dailymile.com/entries.json?oauth_token=&quot; 
    + token);

httpPost.setHeader(&quot;content-type&quot;, &quot;application/json&quot;);
JSONObject data = new JSONObject();

data.put(&quot;message&quot;, dailyMilePost.getMessage());
JSONObject workoutData = new JSONObject();
data.put(&quot;workout&quot;, workoutData);
workoutData.put(&quot;activity_type&quot;, dailyMilePost.getActivityType());
workoutData.put(&quot;completed_at&quot;, dailyMilePost.getCompletedAt());
JSONObject distanceData = new JSONObject();
workoutData.put(&quot;distance&quot;, distanceData);
distanceData.put(&quot;value&quot;, dailyMilePost.getDistanceValue());
distanceData.put(&quot;units&quot;, dailyMilePost.getDistanceUnits());
workoutData.put(&quot;duration&quot;, dailyMilePost.getDurationInSeconds());
workoutData.put(&quot;title&quot;, dailyMilePost.getTitle());
workoutData.put(&quot;felt&quot;, dailyMilePost.getFelt());

StringEntity entity = new StringEntity(data.toString());
httpPost.setEntity(entity);

HttpResponse response = httpClient.execute(httpPost);
</pre>
</pre>
</div>
<p>&#160;</p>
<p>You can see that I am first creating an <em>HttpClient</em> object and an <em>HttpPost</em> object.&#160; The <em>HttpPost </em>has its URL set to the URL for the API call and I am adding a query string parameter to provide the OAuth token we got when when authenticated in my <a href="http://simpleprogrammer.com/2011/05/25/oauth-and-rest-in-android-part-1/">previous post</a>.</p>
<p>I set the content type to be JSON so that we can get back a JSON object from the API call and so it knows that we are passing JSON data.</p>
<p>Then I construct a JSON object in the format specified by the API.&#160; The way to construct the JSON object is to basically create a set of keys and values that are specified by the API you are calling.&#160; In this instance I have a “message” key which I put the message data into.&#160; </p>
<p>The only tricky part is that JSON objects can be nested.&#160; So if you look at the key “workout” in the example above, I am creating a brand new JSON object to use as the value for that key which has its own subkeys which could contain more JSON objects.</p>
<p>Doing it this way is much more simple than trying to construct the string yourself.&#160; The string we end up constructing will look something like this:</p>
<blockquote>
<pre>{&quot;message&quot;:&quot;fun!&quot;,&quot;workout&quot;:{&quot;distance&quot;:{&quot;value&quot;:5,&quot;units&quot;:&quot;miles&quot;},</pre>
<pre>&quot;activity_type&quot;:&quot;running&quot;}}</pre>
</blockquote>
<pre><font face="Verdana"></font>&#160;</pre>
<div>
<pre><font face="Verdana">Finally, I put the JSON data into a <em>StringEntity</em> class and set it as the entity on the HTTP Post.  Then we can call execute on the <em>HttpClient</em> to execute the HTTP POST.</font></pre>
</div>
<div>
<pre><font face="Verdana"></font>&#160;</pre>
</div>
<div>
<pre><font face="Verdana"><strong>Handling the response</strong></font></pre>
<pre><strong><font face="Verdana"></font></strong></pre>
</div>
<div>
<pre><strong><font face="Verdana"></font></strong></pre>
</div>
<div>Now that we have actually made the call to the REST service method we can handle the response by creating another JSONObject from the HttpResponse that is returned.</div>
<div>&#160;</div>
<div>Let’s look at that code and then we can go over what is happening.</div>
<div>&#160;</div>
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:6c90c3b6-702d-4830-b348-12d2efb89b0a" class="wlWriterEditableSmartContent">
<pre style="white-space:normal;">
<pre class="brush: java;">
HttpResponse response = httpClient.execute(httpPost);
String responseString = EntityUtils.toString(response.getEntity());
JSONObject responseJSON = new JSONObject(responseString);
int workoutId = responseJSON.getInt(&quot;id&quot;);
</pre>
</pre>
</div>
<p>All we are doing in this case is getting the response from the execute call on the <em>HttpClient</em> object, then using <em>EntityUtils.toString</em> to convert the response’s entity to a string representation.&#160; Finally, we construct a new <em>JSONObject</em> from that string.</p>
<p>We can then easily extract any data out of the JSON object by using the methods on that JSON object that let us get typed values out of it.&#160; For this example, I know that I am getting back some JSON that has a key “id” which is the id of the workout I created with my POST.</p>
<h2>It is really that simple</h2>
<p>The example I am showing you here is one of the more complex examples of calling a REST based API, because we are having to POST and parse JSON data.</p>
<p>In many API calls, you can just use an HTTP GET or a POST without any data to accomplish what you need to in the API.</p>
<p>Some REST based APIs will allow or require data to be passed in a different format, but most of them use JSON notation, which I find the easiest to work with.</p>
<p>Hopefully with these series of posts you can now authenticate against an OAuth 2 based service and make calls to the API to get and manipulate data in Android.</p>
<p>If you have any questions, feel free to drop me a line or post in the comments below.</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.&#160; Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.&#160; Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1346/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1346&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2011/06/04/oauth-and-rest-in-android-part-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2011/06/androidrest_thumb.png" medium="image">
			<media:title type="html">AndroidREst</media:title>
		</media:content>
	</item>
		<item>
		<title>Android Presenter To Activity Using Guice</title>
		<link>http://simpleprogrammer.com/2010/08/19/android-presenter-to-activity-using-guice/</link>
		<comments>http://simpleprogrammer.com/2010/08/19/android-presenter-to-activity-using-guice/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 14:12:47 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1058</guid>
		<description><![CDATA[In a prior post I talked about how to unit test android applications.  I made some references to wiring up an Activity with a presenter, but I didn’t really show how I was doing that. I got some requests to show some sample code, so I thought I would explain what I was doing here [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1058&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In a prior post I talked about how to <a href="http://simpleprogrammer.com/2010/07/29/the-best-way-to-unit-test-in-android-part-2/">unit test android applications</a>.  I made some references to wiring up an Activity with a presenter, but I didn’t really show how I was doing that.</p>
<p>I got some requests to show some sample code, so I thought I would explain what I was doing here and see if anyone had better suggestions.</p>
<h2>Roboguice</h2>
<p>To make it easier to unit test and to decouple my system as much as possible, I am using a dependency injection framework called <a href="http://code.google.com/p/roboguice/">Roboguice</a>.  It is basically the Google Guice framework that is ported to Android and adds some Android specific functionality.</p>
<p>One challenge you will most likely first encounter when working with Roboguice is that a presenter is going to need a reference to the Activity class that is going to represent its view.  Since the Activity class has to create the presenter, this presents a dependency injection challenge.</p>
<p>We can’t just ask for a presenter from our container and have it auto-resolve the dependency on the Activity.  (That is we can’t rely on constructor injection in this case.)</p>
<h2>Setter injection to the rescue</h2>
<p>One thing we can do, is use setter injection instead of constructor injection to inject the other references our presenter will need.</p>
<p>Guice provides us with an easy way to perform setter injection after we have created the object.  I use this technique to make sure that I can pass my activity into the presenter and still have the benefits of having the other dependencies injected into the presenter.</p>
<p>Here is some code showing my OnCreate method inside my activity.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:645a8872-29d7-40ea-8885-908045ec5e99" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: java; pad-line-numbers: true;">
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    setContentView(R.layout.pacemaker);

    this.presenter = new MainPresenter(this);
    Injector injector = Guice.createInjector(new PaceMakerModule());
    injector.injectMembers(presenter);
}
</pre></p>
</div>
<p>This code is creating an instance of my presenter which holds a reference to the Activity, or view, it is manipulating.  Then Guice injects dependencies using the module I created into any properties that are annotated with @Inject.</p>
<p>Here is what some of those presenter set methods look like:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:47584bf9-8a03-4a4b-8ce9-29770c06b6bb" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: java;">
@Inject
public void setSystemClock(ISystemClock systemClock)
{
     this.systemClock = systemClock;
}

@Inject
public void setRunSerializer(IRunSerializer serializer)
{
     this.runSerializer = serializer;
}
</pre></p>
</div>
<p>You can see that they are declared in the module like so:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:3cb551b5-a302-4613-adf5-4217e27bba75" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: java;">
public class PaceMakerModule extends AbstractAndroidModule
{
   @Override
   protected void configure()
   {
	bind(ISystemClock.class).to(SystemClockWrapper.class);
	bind(IRunSerializer.class).to(GPXRunSerializer.class);
    }

}
</pre></p>
</div>
<p>It’s not exactly pretty, but Android applications are really a loosely coupled sets of Activities which are the entry point into your code.  It makes it very difficult to create a MVP type of framework that we might be used to.</p>
<p>If you know of a better way than what I am doing please let me know, and if you have any questions or suggestion, I’m always glad to hear them or help if I can.</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.  Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1058/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1058/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1058/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1058&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/08/19/android-presenter-to-activity-using-guice/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>
	</item>
		<item>
		<title>The Best Way to Unit Test in Android: Part 2</title>
		<link>http://simpleprogrammer.com/2010/07/29/the-best-way-to-unit-test-in-android-part-2/</link>
		<comments>http://simpleprogrammer.com/2010/07/29/the-best-way-to-unit-test-in-android-part-2/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 14:34:35 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1027</guid>
		<description><![CDATA[In my last post I presented two choices for unit testing in Android. Unit test on the real device or emulator using the real android framework Unit test on our PC using the JVM Each choice has some pros and cons, but for me it came down to the speed and flexibility allowed by running [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1027&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my last post I presented two choices for unit testing in Android.</p>
<ul>
<li>Unit test on the real device or emulator using the real android framework</li>
<li>Unit test on our PC using the JVM</li>
</ul>
<p>Each choice has some pros and cons, but for me it came down to the speed and flexibility allowed by running in a real JVM.  I actually tried to create an Android unit testing project using the scaffolding provided by Google but it turned out to be very restrictive, especially since I couldn’t use JMock.</p>
<p>There is also something to be said for being able to execute the unit tests extremely quickly.  If you have to wait for an emulator to come up, or try to run them on a real device, it is less likely the unit tests will be run.</p>
<h2>How to do it</h2>
<p>The basic idea of this approach is fairly simple.</p>
<p>We are going to try and abstract away any Android specific calls from our application and then unit test the plain Java logic in the application just like we would any other Java project.</p>
<h4>Step 1:  Create a JUnit project</h4>
<p><strong></strong>Create a new JUnit project just like you would for unit testing any Java application.</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/07/newjavaproject.png"><img style="display:inline;border-width:0;" title="NewJavaProject" src="http://complextosimple.files.wordpress.com/2010/07/newjavaproject_thumb.png?w=498&#038;h=477" border="0" alt="NewJavaProject" width="498" height="477" /></a></p>
<p>Make sure you chose <strong>Java Project</strong> rather than <strong>Android Test Project.</strong></p>
<p>From here you can add your JUnit references to your build path.  <em>I would also recommend adding </em><a href="http://code.google.com/p/instinct/"><em>Instinct</em></a><em> for doing BDD style testing.  Instinct uses JMock internally to create mocks for you using a declarative approach.</em></p>
<p>The only other thing you will want to do with this project is to add the android.jar to the build path.  The android.jar can be found in your Android SDK directory under the platform directory that corresponds to the API version you are targeting with your application.</p>
<p>For example, on my machine, I am targeting Android 1.6, so my android.jar is at:  C:\Android\android-sdk-windows\platforms\android-4.</p>
<p>Now remember, you are including the android.jar in the project only so your classes can understand what types exist in the Android framework.  <strong>If you even try to call a constructor on a class in android.jar, you will get an exception.</strong></p>
<h4>Step 2: Pull all the code you can out of the Activity.</h4>
<p>The next thing we need to do is clean up our Activity class to make sure that it has the smallest amount of logic in it as possible.</p>
<p>Since we can’t actually instantiate any types that exist in the Android framework, we are not going to be able to create an instance of our Activity in the test project.  So we are not going to be able to unit test our Activity.  This isn’t a problem if most of the logic we care about testing exists in other layers in our system.</p>
<p>You can design the lower layers however you want.  I am still not quite sure the best approach here, but what I did was put a presentation layer directly below the Activity.  I have a Presenter class directly below the Activity that tells my activity what to do.  The Activity passes on any interesting events or information to the Presenter.</p>
<p>You should leave the Activity with the responsibility of setting the text on its own view objects, but create methods for your lower layers to tell the Activity what text to set the objects to and so forth.  Activity is going to act as an adapter to a large portion of the Android framework for your application.</p>
<p>Because the entrance point into your application is going to be the Activity, you will need to wire up the rest of your layers from the Activity.  This is a little strange, but it works.  In my application, I create a new Presenter and pass <em>this </em>into it on the constructor.</p>
<p>When you are done, your Activity should look pretty thin.  It should delegate all its event handler logic down to the lower layers and act as a pass through for manipulating the view.</p>
<h4>Step 3: Wrap remaining Android object calls.</h4>
<p>You&#8217;re going to find that some of the remaining Android API will need to be called from lower down than the Activity.  This is not as big of a problem as it seems.</p>
<p>In my application I needed to make some calls to android.os.SystemClock.  I needed to make those calls lower down than the activity because it is part of the heart of the logic of my application.</p>
<p>I created a simple SystemClockWrapper class that wraps system clock and delegates any calls to the real SystemClock class.  Then I extracted an interface from that class called ISystemClock (hey, I like the C# convention for interfaces.)</p>
<p>Finally, in my application logic, I allowed the ISystemClock reference to be passed in or “injected” through the constructor of the class that used it.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:e333f287-e382-4a5e-8493-b182750f180f" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: java; pad-line-numbers: true;">
public class SystemClockWrapper implements ISystemClock
{
     public long getElapsedRealTime()
     {
          return SystemClock.elapsedRealtime();
     }

}

public interface ISystemClock
{
     public abstract long getElapsedRealTime();

}

</pre></p>
</div>
<p>In my unit test I just pass in a mock version of the ISystemClock interface.</p>
<p>One hint here is to use the refactor tool in your IDE to extract an interface.  This can save you some time of trying to manually create interfaces for large pieces of functionality you are wrapping.</p>
<h2>Putting it all together</h2>
<p>Now you should be able to create your unit tests against most of your application logic and run them just like any other unit test project.</p>
<p>The only thing you won’t be able to do is unit test the logic in your Activity classes.  This shouldn’t be much of a problem if you have made them into views, because they should only contain view logic.</p>
<p>If you really want to be able to write some tests for the Activity though, you can create another actual <em>Android Test Project </em>and use Google’s framework to write unit tests from there.</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.  Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1027/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1027/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1027/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1027&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/07/29/the-best-way-to-unit-test-in-android-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/07/newjavaproject_thumb.png" medium="image">
			<media:title type="html">NewJavaProject</media:title>
		</media:content>
	</item>
		<item>
		<title>The Best Way to Unit Test in Android: Part 1</title>
		<link>http://simpleprogrammer.com/2010/07/27/the-best-way-to-unit-test-in-android/</link>
		<comments>http://simpleprogrammer.com/2010/07/27/the-best-way-to-unit-test-in-android/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 14:58:14 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Unit Testing]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=1018</guid>
		<description><![CDATA[I’ve been doing some development in Android lately on a top secret project, one that hopefully will change the way you run with your phone. In the course of building this app, in a previous post I mentioned that I wanted to find the right, or perfect way, to build an Android application. I haven’t [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1018&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I’ve been doing some development in Android lately on a top secret project, one that hopefully will change the way you run with your phone.</p>
<p>In the course of building this app, in <a href="http://simpleprogrammer.com/2010/07/20/the-hardest-thing-i-struggle-with/">a previous post</a> I mentioned that I wanted to find the right, or perfect way, to build an Android application.</p>
<p>I haven’t found the best way to build an Android application into a nice clean design pattern, but have found a way that seems to work, and makes the application testable and easy to maintain.</p>
<p>I do believe though, that I have found the optimal way to do unit testing in Android right now.  Yes, a bold statement, but I have looked high and low for a better solution, and can’t find one.</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/07/htcandroid.png"><img style="display:inline;border:0;" title="HTC-Android" src="http://complextosimple.files.wordpress.com/2010/07/htcandroid_thumb.png?w=455&#038;h=342" border="0" alt="HTC-Android" width="455" height="342" /></a></p>
<h2>The problems</h2>
<p>So first a little bit of background on the problem with unit testing in Android.  Take what I say with a grain of salt here, because I am not an Android platform expert, and feel free to correct me if I misstate something.</p>
<h4>Android.jar</h4>
<p>If you download the Android SDK from google, you will find that the android.jar you get with the SDK is much like a C++ header file; it doesn’t actually contain any working code.  As a matter of fact, all the methods are stubbed out to throw an exception with the message “Stub!” when you call them.  How cute.</p>
<p>The real android.jar implementations live on the emulator, or your real Android device.  So, if you want to actually run any code that is going to call any methods or try to construct real Android framework classes, <strong>you must run that code inside the emulator or a real device.</strong></p>
<h4><strong>Dalvik VM</strong></h4>
<p>When you&#8217;re working with Android, it sure feels like you are writing regular old standard Java SE code, <strong>but you are not. </strong>You probably won’t notice the difference, as almost everything that you need is there in the Dalvik VM implementation of Java.</p>
<p>Dalvik is not even a Java Virtual Machine at all.  That is right, it runs on cross-complied .class files which are converted to a .dex format.  <strong>Yes, is does not use java byte code.</strong></p>
<p>Why do I mention all this?  Because you might want to use something like JMock to mock your dependencies when writing your unit tests.</p>
<p>Well, you can’t.  It just isn’t going to work, because the Dalvik VM doesn’t use java byte code, so the reflective coolness that mocking frameworks like JMock use doesn’t work the same.</p>
<p>Be aware that any external library you try to use in your Android project may not work because Android does not support the full Java SE implementation.  It actually is a subset of the <a href="http://en.wikipedia.org/wiki/Apache_Harmony">Apache Harmony</a> Java implementation.</p>
<h4>There is no main()</h4>
<p>Where does an Android application start running?  From the activity.  Which is basically the view.  (Some people will argue this is the controller or presenter.  And yes, I agree in respect to the Android framework it is, but in regard to your application framework it is the view.)</p>
<p>Android applications define a starting activity and launch from there.  Activities can even be launched from other applications.</p>
<p>This tends to disrupt most of our MVC, MVP, MVVP pattern architectures, as the view is going to be the entry point and will have to be responsible for initializing the rest of the application.  (That is not entirely true, as there is an android.app.Application class that gets called the first time your app is run, to launch the main activity, but for the most part you can’t do much here.)</p>
<p>Essentially though, you have to build your architecture based on each Activity being its own separate little application, with the entry point being in the activity.  This puts some serious constraints on unit testing.</p>
<h2>Putting it all together</h2>
<p>So if I can sum up the problems briefly, I would say:</p>
<ul>
<li>Android framework code has to run in the emulator or on a device.</li>
<li>Dalvik VM doesn’t allow us to use our standard mocking frameworks.</li>
<li>Entry points for our applications are in the views.</li>
</ul>
<p>The first problem, combined with the second, lead us to an interesting choice.  Should we run our unit tests on an actual emulator or device using the Dalvik VM, or should we run them in a JVM?</p>
<p>It is probably not an obvious question, but let me explain why it is the most relevant.</p>
<p>In writing an application, we are going to have application logic that has nothing specifically to do with the Android platform, and we are going to have Android platform specific logic (drawing views, handling Android OS events, interacting with Android APIs etc.)</p>
<p>If we want to write true unit tests, we need to isolate our classes and test them individually.  We should be able to do this for our application logic, without relying on the Android framework.  If we don’t rely on the Android framework, we don’t need to run on a real or emulated device, thus we are not constrained to the Dalvik VM.</p>
<p><strong>If we choose to run our unit test code on a real or emulated device:</strong></p>
<ul>
<li>We will be able to use the Android framework APIs in our testing efforts.  For example, we can create new location objects instead of mocking them up.</li>
<li>We will be completely true to the real execution of our code.  Since we will be using the real VM the code will run on.</li>
<li>Since we are running our tests on a device or emulator, they will run much slower.</li>
<li>We won’t be able to use <a href="http://www.jmock.org/">JMock</a>, EasyMock, or Mockito, we’ll either have to roll our own mocks or use a fledgling Android mocking framework.</li>
</ul>
<p><strong>If we chose to run our unit test code in a JVM on our PC:</strong></p>
<ul>
<li>We will have the full power of the JVM available to our test code, so we can use mocking frameworks like JMock, and BDD frameworks like <a href="http://code.google.com/p/instinct/">Instinct</a>.</li>
<li>We will run our unit tests much faster, since they will be using our PC instead of a device.</li>
<li>We can use standard unit testing practices and not have to inherit from special Android classes, or use special Android test runners.</li>
<li>We will have to wrap any calls to the actual Android framework if we need to use any Android classes or services deeper down in our application.</li>
<li>We have a small risk of having different behavior between running the tests and the real application, because we will be running the code on different VMs.</li>
</ul>
<p>In my next post, I’ll detail which option I chose and why and also give some detailed steps of how to get setup and running.</p>
<h6>As always, you can subscribe to this <a href="http://feeds.feedburner.com/MakingTheComplexSimple">RSS feed</a> to follow my posts on Making the Complex Simple.  Feel free to check out <a href="http://elegantcode.com/">ElegantCode.com</a> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter <a href="http://twitter.com/jsonmez">here</a>.</h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/1018/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/1018/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/1018/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/1018/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/1018/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/1018/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/1018/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/1018/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/1018/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/1018/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/1018/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/1018/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/1018/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/1018/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=1018&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/07/27/the-best-way-to-unit-test-in-android/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/07/htcandroid_thumb.png" medium="image">
			<media:title type="html">HTC-Android</media:title>
		</media:content>
	</item>
		<item>
		<title>Do We Need If Blocks?</title>
		<link>http://simpleprogrammer.com/2010/06/28/do-we-need-if-blocks/</link>
		<comments>http://simpleprogrammer.com/2010/06/28/do-we-need-if-blocks/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 16:37:30 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Language]]></category>

		<guid isPermaLink="false">https://complextosimple.wordpress.com/?p=972</guid>
		<description><![CDATA[I&#8217;ve been contemplating this for a while now.  I thought I would finally write on the subject and see what other people thought. Do you really need blocks after if statements? It has always been a best practice, in my opinion, to put opening and closing brackets after an if statement.  Even if it has [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=972&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been contemplating this for a while now.  I thought I would finally write on the subject and see what other people thought.</p>
<p>Do you really need blocks after <em>if</em> statements?</p>
<p>It has always been a best practice, in my opinion, to put opening and closing brackets after an <em>if</em> statement.  Even if it has only one statement following.</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:8c01e598-9ded-48da-82c7-d78cd410726b" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp; pad-line-numbers: true;">
if(theSkyIsBlue)
{
   DanceALittleDance();
}
</pre></p>
</div>
<p>The reasoning behind this best practice goes something like this: If someone later modifies this code and adds a line inside the <em>if</em>, having the block will prevent them from doing something like this:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:47c5c653-7298-459f-a3f0-a684a66f0f6b" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
if(theSkyIsBlue)
   DanceALittleDance();
   MakeALittleLove();
</pre></p>
</div>
<p>Which, of course, will result in way too much love making, even on stormy days when the sky is mostly gray.</p>
<h2>All those { } add up to a lot of overhead</h2>
<p>I’m not sure it is worth it anymore.</p>
<p>Most of the code I write now has one statement after an <em>if</em> block.</p>
<p>If I have some code like:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:777acc1a-ef7d-451e-aa1d-1da0fef3847f" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
if(theSkyIsBlue)
{
   PutYourRightFootIn();
   TakeYourRightFootOut();
   DoTheHokeyPokey();
   SpinYourselfAbout();
}

</pre></p>
</div>
<p>It is pretty much always going to get refactored to:</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:2e4eb6ff-992f-46ef-b5f6-c9f657bd5e6e" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
if(theSkyIsBlue)
{
   DanceALittleDance();
}
</pre></p>
</div>
<p>So what is the real value of the { } here?  If someone modifies this code, they are most likely going to modify the method DanceALittleDance, they really shouldn’t be adding anything to the <em>if</em> block.  Even if they do, I think I’m paying a pretty high curly bracket tax all over my code to prevent someone from doing something stupid later on.</p>
<p>Is this really that bad?</p>
<div id="scid:C89E2BDB-ADD3-4f7a-9810-1B7EACF446C1:cd7f40b3-ffd1-472b-aa1e-a97ae1e1c0f1" class="wlWriterEditableSmartContent" style="display:inline;float:none;margin:0;padding:0;"><pre class="brush: csharp;">
if(theSkyIsBlue)
   DanceALittleDance();
</pre></p>
</div>
<h2>Perhaps there is a better best practice?</h2>
<p>How about if we forgo all the extra curly braces and instead say:</p>
<blockquote><p><strong>Whenever possible replace an if block with a single statement.</strong></p></blockquote>
<p>Hmm, I think I like that better.  We won’t run the risk anymore of accidentally adding a statement after the if block, if we are used to thinking of an if block itself as a code smell.</p>
<p>Almost always you can describe what is being done in an if block with a better name and encapsulate it in a method.</p>
<p>Of course there are exceptions here.  In a method with a void return type when you early return in an if block, you can’t really replace that with a single statement.  (Although sometimes you can avoid the early return by using an if else statement instead.)</p>
<p>We can apply the same thinking to anything that has a block statement.</p>
<p>Strangely though, try and catch require block statements to follow.  You cannot have a single statement following a try.</p>
<p>Anyway, at this point I am pretty well convinced that including the { } just because is a pretty archaic practice and is unnecessarily cluttering up our code.  If I am wrong, tell me why I am wrong, but as far as I can tell, if we prefer to extract statement blocks into methods, we can avoid the curly bracket tax everywhere.</p>
<p><strong>As always, you can subscribe to this </strong><a href="http://feeds.feedburner.com/MakingTheComplexSimple"><strong>RSS feed</strong></a><strong> to follow my posts on Making the Complex Simple.  Feel free to check out </strong><a href="http://elegantcode.com/"><strong>ElegantCode.com</strong></a><strong> where I post about the topic of writing elegant code about once a week.  Also, you can follow me on twitter </strong><a href="http://twitter.com/jsonmez"><strong>here</strong></a><strong>.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/972/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/972/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/972/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/972/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/972/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/972/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/972/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/972/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/972/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/972/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/972/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/972/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/972/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/972/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=972&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/06/28/do-we-need-if-blocks/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>
	</item>
		<item>
		<title>So You Want to Become a Better Programmer? (TopCoder)</title>
		<link>http://simpleprogrammer.com/2010/04/02/so-you-want-to-become-a-better-programmer-topcoder/</link>
		<comments>http://simpleprogrammer.com/2010/04/02/so-you-want-to-become-a-better-programmer-topcoder/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 18:59:57 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Interview]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Language]]></category>
		<category><![CDATA[Self Improvement]]></category>

		<guid isPermaLink="false">http://simpleprogrammer.com/?p=590</guid>
		<description><![CDATA[Let me ask you a question. If you drive your car every day, do you think you are becoming a better driver? Now, let me ask you another question. If you competed in races with your car, frequently, do you think you would be becoming a better driver? Let&#8217;s reflect that paradigm at programming.  Many of us, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=590&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Let me ask you a question.</p>
<p>If you drive your car every day, do you think you are becoming a better driver?</p>
<p>Now, let me ask you another question.</p>
<p>If you competed in races with your car, frequently, do you think you would be becoming a better driver?</p>
<p>Let&#8217;s reflect that paradigm at programming.  Many of us, if we are fortunate, get to write code every day.  Unfortunately, a large amount of the code we write is fairly mundane.  We are rarely writing code in any form of competition.  When you are first starting out , writing code makes you better at writing code.  After time, when you have been writing code for a while, just like driving, you stop making gains.</p>
<p>You may have heard someone say <strong>there is a difference between a programmer with 10 years of experience and a programmer with 1 year of experience 10 times</strong>.</p>
<h2>How to start making gains again</h2>
<p>What I want to talk about today is just one of the ways you can start making gains again in your programming skills.  There are many others, and I have talked about some of them <a href="http://simpleprogrammer.com/2009/12/08/great-developers-are-librarians/">before</a>.  But, today I want to talk about a very specific way I have found to break through the barriers and really improve your programming skills.  Specifically, I want to talk to you about a programming competition that I really enjoy called <a href="http://www.topcoder.com/">TopCoder</a>.</p>
<p>TopCoder is a website that has a nice little competition arena that allows you to compete against other programmers solving some pretty difficult problems.  They have built a web launcher that opens up an IDE where you can view a programming problem and write your code to solve it.  You can solve the problem in any one of their supported languages and get immediate feedback through their system tests.  You can also view other people&#8217;s solutions to the problem and challenge their solutions with your own input.</p>
<p>There are other kinds of competitions on the site, but for what I am talking about you&#8217;ll want to go to the <a href="http://topcoder.com">site</a>, then click on develop, then click on algorithm, and launch arena.</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_08-00-03.png"><img class="alignnone size-full wp-image-591" title="SS-2010-04-02_08.00.03" src="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_08-00-03.png?w=500" alt=""   /></a></p>
<p>Once you are in the competition arena, you are brought to a chat lobby, where you can switch to a competition room (if one is currently underway), or to a practice room, where you can practice some of the past competitions.</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_07-39-47.png"><img class="alignnone size-full wp-image-592" title="SS-2010-04-02_07.39.47" src="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_07-39-47.png?w=500&#038;h=342" alt="" width="500" height="342" /></a></p>
<p>Once you are in one of the rooms that has problems, you can select a problem to launch the IDE.</p>
<p><a href="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_07-40-18.png"><img class="alignnone size-full wp-image-593" title="SS-2010-04-02_07.40.18" src="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_07-40-18.png?w=500&#038;h=371" alt="" width="500" height="371" /></a></p>
<p>There you can type your solution to the problem right there and compile or test your code.  I&#8217;m not going to go into all of the details of how the competition and scoring works here, because I want to focus more one why TopCoder, and other types of training like this are so beneficial.</p>
<h2>Why will this make me a better programmer?</h2>
<p>It is kind of hard to explain why this works so well.  I think one of the major reasons is because we are challenged to solve much more difficult problems than what we usually solve in our day jobs.  When you start solving those problems, the easier problems you encounter on a day-to-day basis seem to get a lot easier.</p>
<p>One thing that really helped me was the ability to see other people&#8217;s solutions to the problem.  When I would finish coding my problem, and look at the other solutions to the problem, I would always find new ways of using some of the base language or library features that had never occurred to me.</p>
<p>When you try to challenge someone else&#8217;s problem, you are forced to read some code that can be very obscure and quickly understand it.</p>
<p>You can also use some plugins to code in your favorite IDE and then have the code mirrored in the TopCoder IDE, but there is a nice gain in mastery of the language that can be had if you choose to use the TopCoder IDE which does not have auto-complete.  (Especially if you ever have to write code on a white-board during an interview.  It can be pretty embarrassing when you are unable to produce the syntax for a simple statement because you are so used to relying on auto-complete.)</p>
<p>You don&#8217;t have to do the competition, you can just do the practice rooms on the site, but I encourage you to try a competition or two.  There is just something about competition that seems to make us better.</p>
<p>Post me some comments if you try this and it helps you or <a href="http://twitter.com/jsonmez">hit me up on twitter</a> @jsonmez.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/590/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/590/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/590/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=590&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/04/02/so-you-want-to-become-a-better-programmer-topcoder/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_08-00-03.png" medium="image">
			<media:title type="html">SS-2010-04-02_08.00.03</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_07-39-47.png" medium="image">
			<media:title type="html">SS-2010-04-02_07.39.47</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/04/ss-2010-04-02_07-40-18.png" medium="image">
			<media:title type="html">SS-2010-04-02_07.40.18</media:title>
		</media:content>
	</item>
		<item>
		<title>Book Review: Implementation Patterns</title>
		<link>http://simpleprogrammer.com/2010/03/01/book-review-implementation-patterns/</link>
		<comments>http://simpleprogrammer.com/2010/03/01/book-review-implementation-patterns/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 15:43:45 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Self Improvement]]></category>

		<guid isPermaLink="false">http://simpleprogrammer.com/?p=455</guid>
		<description><![CDATA[I finally finished &#8220;Implementation Patterns&#8221; by Kent Beck and I have to be honest.  I am a little disappointed.  Let me preface this by saying my review of this book is not a reflection of my view of Kent Beck.  Kent Beck is a programming hero.  He pioneered the adoption of Test Driven Development, invented Extreme [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=455&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://complextosimple.files.wordpress.com/2010/03/implementationpatterns.jpg"><img class="alignnone size-full wp-image-456" title="implementationpatterns" src="http://complextosimple.files.wordpress.com/2010/03/implementationpatterns.jpg?w=500" alt=""   /></a></p>
<p>I finally finished &#8220;<a href="0px !important;&quot; /&gt;">Implementation Patterns</a>&#8221; by Kent Beck and I have to be honest.  I am a little disappointed.  Let me preface this by saying my review of this book is not a reflection of my view of <a href="http://en.wikipedia.org/wiki/Kent_Beck">Kent Beck</a>.  Kent Beck is a programming hero.  He pioneered the adoption of Test Driven Development, invented Extreme Programming and was one of the creators of JUnit.  With that said, I will be honest about the book.</p>
<p>This book is about the low level construction of software and algorithms.  Implementation Patterns looks at the patterns which are applied to programming when creating even the simplest of designs.</p>
<p>The book covers patterns relating to classes, state, behavior, methods and collections.</p>
<p><strong>Good:</strong></p>
<ul>
<li>Excellent introduction on implementation patterns</li>
<li>Good reference for knowing how to call the thing you know is right, but can&#8217;t explain.</li>
<li>Section on collections is very good for understanding trade-offs between collection types.</li>
</ul>
<p><strong>Bad:</strong></p>
<ul>
<li>Doesn&#8217;t read much like a book.  It is a bunch of little pieces on each topic, but they don&#8217;t really tie together smoothly.</li>
<li>Some of the patterns I disagree with, especially the ones involving using inheritance over a different solution.  (<a href="http://simpleprogrammer.com/2010/01/15/inheritance-is-inherently-evil/">I am not a fan of concrete inheritance.</a>)</li>
<li>The book feels like it was not fun to write, like it was a labor of filling up pages.</li>
<li>The treatment of collections perhaps belongs in a different book.  The appendix which talks about performance measurement definitely does.  A large amount of the book are these two topics.</li>
<li>The framework section seemed a little strange in this book and it didn&#8217;t really have enough information to be useful.</li>
</ul>
<p><strong>What I learned:</strong></p>
<p>There is always something still to learn, and I did learn one very important concept from this book.  Kent talks about Values and Principles in the 3rd chapter of the book.  This concept has been something that I haven&#8217;t been able to put into words, but I have known it is there.  Kent very clearly describes the differences between values of programming and principles, and how principles are built on top of values.  Often, I have a hard time in my mind accepting the need for making trade-offs between one or more principles.  He very clearly addresses this issue, leading back to the values for ultimately making the decision.</p>
<p>I learned many names for things I was doing, but without knowing what to call them.</p>
<p>I also learned quite a bit about Java collections which I did not know before.  I found out some good considerations when writing code to determine performance, which I would probably have not considered until reading this book.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/455/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/455/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/455/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=455&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/03/01/book-review-implementation-patterns/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>

		<media:content url="http://complextosimple.files.wordpress.com/2010/03/implementationpatterns.jpg" medium="image">
			<media:title type="html">implementationpatterns</media:title>
		</media:content>
	</item>
		<item>
		<title>C# vs Java Part 4: The Tools (Final)</title>
		<link>http://simpleprogrammer.com/2010/02/19/c-vs-java-part-4-the-tools-final/</link>
		<comments>http://simpleprogrammer.com/2010/02/19/c-vs-java-part-4-the-tools-final/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 21:59:05 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://simpleprogrammer.com/?p=401</guid>
		<description><![CDATA[This is my final installment of the C# vs Java series, but I think this is one of the most important.  Tools make or break a development environment.  Good tools can make a hard job seem easy and bad tools can make an easy job seem hard.  My definition of a tool is: anything that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=401&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is my final installment of the C# vs Java series, but I think this is one of the most important.  Tools make or break a development environment.  Good tools can make a hard job seem easy and bad tools can make an easy job seem hard.  My definition of a tool is: anything that helps you work.  This could include IDEs, external libraries, frameworks, testing tools, etc.</p>
<p><strong>IDEs</strong></p>
<p>A good place to start looking at tools is IDEs.  You have heard it said that you should buy a good mattress because you spend 1/3rd of your life in bed.  If you are a programmer, you spend 1/3rd of your life in an IDE.  (If you are a bad programmer you spend 1/3rd of your life in the debugger in the IDE, but that is another story.)  For that reason, an IDE is very important, perhaps one of the most critical choices when choosing a programming environment.  Fortunately, both Java and C# have good choices here.</p>
<p>As far as IDEs go, C# basically has Visual Studio.  There are some open source and other strange things out there claiming to be a C# IDE, but as far as I have seen, they are not serious considerations.  (Correct me if I am wrong here.)  Being the only game in town means that Visual Studio had better be really good.  It is good; there are many things it does automatically for you.  For the most part Visual Studio does everything you would want it to do, but it is missing some things that the Java world has.</p>
<p>In Visual Studio, classes are not auto imported when you start to type.  This is kind of hard to explain, but in Eclipse, I can start typing the name of some class and the IDE will search all the code I am linked to and try to find any matches for it.  If I select that class, Eclipse will automatically import that namespace for me.  Visual Studio requires you to know the namespace of the thing you are looking to use.  Not a huge deal, but if you start using Eclipse and then switch back to Visual Studio, you will certainly feel the pain in that area.  Now, most of the ails of Visual Studio can all be remedied by the use of a plug-in that I highly recommend, <a href="http://www.jetbrains.com/resharper/">Resharper</a>.  Resharper makes Visual Studio awesome.  It is not free, but it is money well spent.  It adds many automatic refactoring options and many of the features that are available in Java IDEs that are missing from Visual Studio.</p>
<p>In the Java world, there are 3 major choices: <a href="http://www.eclipse.org/">Eclipse</a>, <a href="http://www.jetbrains.com/idea/">IntelliJ </a>and <a href="http://netbeans.org/">Netbeans</a>.  I have mainly used Eclipse, so I do not have as much of an idea about the others.  I have heard many good things about IntelliJ, and considering it is made by the same company that makes ReSharper, it is probably pretty good.  The reason I like Eclipse though is because of all the plug-ins.  It is also the reason I don&#8217;t like Eclipse.  The Eclipse community is thriving with plug-ins; as a result there isn&#8217;t much you can&#8217;t do from that IDE.  There are so many plug-ins for Eclipse that entire companies exist just to bundle them together.  Think about that for a minute.  This is both good and bad.  It is good because you can do just about anything you want to do in Eclipse.  It is bad because too many choices are confusing and you always wonder if you are doing the right thing since there is no clear-cut answer.  Visual Studio doesn&#8217;t have very many plug-ins at all, but Eclipse thrives on them.  Eclipse is also very good at searching code.  There are many hot keys in Eclipse which will allow for searching for classes or files and finding methods in classes.</p>
<p>The IDEs in both environment are similar, offering much of the same basic functionality, but overall Eclipse is more powerful than Visual Studio.  One the flip side though, Visual Studio is much easier to use.</p>
<p><strong>The Rest</strong></p>
<p>There are far too many other tools to handle in direct comparison.  Instead, I can make some generalizations about the tools available in general.  A large amount of the tools available to C# are direct ports of the same tools which were first created in Java.  In this respect C# and Java have a pretty equivalent tool set for unit testing, logging, builds, and dependency injection.  This is very helpful in transitioning from one language to the other, as knowing one of the tools in one language gives a benefit of knowing how to use the tool in the other language.</p>
<p>The big difference I see here though is open source versus commercial software and tools.  In the C# world, there are plenty of open source tools, but a good majority are tools that are not free.  Contrast this to the Java world, where most of the tools are open source.  This aspect can be quite deceiving.  It seems like free tools are good, and they can be, but often the cost of free tools is overlooked.  There are several companies that do nothing but sell support contracts for free software.  Often the support contracts are more expensive than equivalent commercial software on the C# side.</p>
<p>Another common issue I face when working in the Java world and trying to get or find tools is the road of dead software.  There are tons of open source projects which no one has been actively working on for several years.  Often, I find it extremely difficult to figure out which tool is being used and actively worked on the most.  Even when I am able to sort through the hundreds of options, only some of which are still alive, it is often very difficult to find information about how to use the tool or framework.  On the C# and .NET side, there are much fewer projects and much fewer dead projects.  I find it much easier to find the tool most people are using and to get it up and running quickly.</p>
<p><strong>Conclusion</strong></p>
<p>In general, I feel like I can find a tool for a job much more quickly in the .NET/C# world than I can in the Java world.  I can also quickly find out how to use a tool instead of hunting through documentation.  I would say it is just more simple.  On the other hand, Java has a much larger selection of tools that can typically do more, at a cost of increased complexity and difficulty in finding the right tool.  My personal preference is C# and .NET tools because I don&#8217;t like to waste a large amount of time trying to figure out what to use and how to use it.</p>
<p>Well, that is it for my coverage of C# vs. Java for now.  I am actually getting kind of tired comparing the two.  Hopefully I have done a good job of presenting a fair picture from the perspective of a developer currently using both technologies.  Now&#8230; on to more exciting stuff!</p>
<p><a href="http://simpleprogrammer.com/2010/02/01/c-vs-java-part-1-the-languages/">C# vs Java Part 1: Language</a></p>
<p><a href="http://simpleprogrammer.com/2010/02/04/c-vs-java-part-2-the-platforms-web/">C# vs Java Part 2: Platforms</a></p>
<p><a href="http://simpleprogrammer.com/2010/02/09/c-vs-java-part-3-the-frameworks-io-db-concurrency-collections/">C# vs Java Part 3: Frameworks</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/401/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/401/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/401/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=401&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/02/19/c-vs-java-part-4-the-tools-final/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>
	</item>
		<item>
		<title>C# vs Java Part 3: The Frameworks (Network, Reflection, Security, Text)</title>
		<link>http://simpleprogrammer.com/2010/02/12/c-vs-java-part-3-the-frameworks-network-reflection-security-text/</link>
		<comments>http://simpleprogrammer.com/2010/02/12/c-vs-java-part-3-the-frameworks-network-reflection-security-text/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 19:08:43 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Lambda]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://simpleprogrammer.com/?p=368</guid>
		<description><![CDATA[Network Programming Both C# and Java provide framework libraries for reading and writing data to a network.  Java is again hindered by the same kind of problems it has with file IO.  It is difficult to do network programming in Java.  Let&#8217;s compare downloading a web page in both languages. Java: C# In this area, the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=368&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Network Programming</strong></p>
<p>Both C# and Java provide framework libraries for reading and writing data to a network.  Java is again hindered by the same kind of problems it has with file IO.  It is difficult to do network programming in Java.  Let&#8217;s compare downloading a web page in both languages.</p>
<p>Java:</p>
<p><pre class="brush: java;">

URL url = new URL(&quot;http://google.com&quot;);
InputStreamReader streamReader = new InputStreamReader(url.openStream);
BufferedReader bufferedReader = new BufferedReader(streamReader);
String line = bufferedReader.readLine();

while (line != null)
{
    System.out.println(line);
    line = reader.readLine();
}

</pre></p>
<p>C#</p>
<p><pre class="brush: csharp;">

WebClient client = new WebClient();
String webPage = client.DownloadString( url );
Console.out.writeLine(webPage);

</pre></p>
<p>In this area, the .NET base library is much larger than Java.  I didn&#8217;t really expect this would be the case, but when I compare <em>java.net</em> and <em>java.nio</em> to <em>system.net</em>, it is pretty clear that <em>system.net</em> has a much larger range of functionality.  Without drilling down too detailed, here are some of the things that are missing or obscured from Java base classes, which are available in C#/.NET:</p>
<ul>
<li>FTP support</li>
<li>A base mail package, that doesn&#8217;t have to be added separately.</li>
<li>TCP and UDP clients instead of using raw sockets</li>
<li>Ping</li>
<li>Peer to Peer</li>
</ul>
<p>If we start to talk about Windows Communication Foundation (<a href="http://msdn.microsoft.com/en-us/library/ms731082.aspx">WCF</a>), the divide grows much further.  WCF is much more than just a web services framework.  It is an adaptable distributed computing framework allowing a large range or protocols all abstracted from the business logic.  The clear winner in my opinion is C# and .NET here.</p>
<p><strong>Reflection</strong></p>
<p>I have to admit, I am not that big of a fan of reflection.  I know it is &#8220;neato&#8221; and can do lots of cool things.  But I have seen too much &#8220;cool&#8221; reflection code that breaks when I use the refactor tool.  Sometimes though, even I have to admit, it is the only tool that will do the job.  When that is the case, you expect it to be easier than rocket science.  At least I do.</p>
<p>Java and C# both provide similar capabilities in reflection through the standard framework libraries.  With either language you can easily get a class, find out what methods are on that class and dynamically call them.  There is, however, one important difference which C# is able to provide through the use of Lamba Expressions.</p>
<p>I don&#8217;t want to go into the technical details here, because they are pretty complicated, but C# will basically allow strongly typed reflection through the use of LINQ to create an expression tree that will provide the information to strongly type the reflected information.  This is pretty cool, although I still don&#8217;t like reflection.</p>
<p>One more point here, the <em>dynamic</em> keyword in .NET 4.0 probably belongs here because it is reflection-like.  It will allow for very easy COM interoperability and allow certain parts of C# code to be dynamically typed instead of static.</p>
<p><strong>Security</strong></p>
<p>Both C# and Java frameworks are vast in areas of security.  Unfortunately, both are fairly complex and difficult to use or understand.  Couple this complexity with the changing demands of security and theories about security, spread across multiple platforms and deployment situations, and you get a mess.</p>
<p>Both choices have similar functionality in cryptography.  Both use provider models for authentication and support a wide variety of authentication services, including user defined services.  Both allow for role based security through a provider model.</p>
<p>The differences are what you would expect considering the language and framework targets.  C# and .NET are better equipped in a Windows environment and allow very easy use of windows authentication schemes and active directory.  Java is more flexible, allowing easier interoperability with multiple operating systems and authentication methods, but at the cost of a slightly more complex and burdensome API.  C# and .NET allow the usage of Code Access Security (CAS), which is a very complex concept that basically allows individual level rights to be applied to sections of code controlled from the machine configuration.  Unfortunately, this turned out to be overly complex and something that almost no one used correctly.  For that reason Microsoft is getting rid of the concept of CAS in .NET framework 4.0.</p>
<p>I really d0n&#8217;t like either choice for Security at this point.  Both are confusing, and there is no clear-cut best practices for applying security to the application.  I think both frameworks have a way to go to make security something that is very easy to implement and understand.  We will probably see a large amount of churn in this area, because of the changing needs of security, as we transition from a primarily web based application model to this mixed model, using applications that are able to run outside of the browser but start their life inside, and hybrid systems utilizing both.</p>
<p><strong>Text Manipulation</strong></p>
<p>At some point in time every developer faces this challenge.  For this reason, I consider it an important part of any framework.  Some of the most common problems involve parsing files, splitting strings, and searching for patterns.  While regular expressions is part of the equation, it is not the only tool for the job, and as frequently said</p>
<blockquote><p><strong>Some people, when confronted with a problem, think<br />
“I know, I&#8217;ll use regular expressions.”   Now they have two problems.</strong></p></blockquote>
<p>Lets take a look at String.  Very similar in Java and C#, but some subtle differences.  My first beef is that in Java I cannot do &#8220;string1&#8243; == &#8220;string2&#8243;.  In C#, this is fine because it ends up just calling the .equals.  Having done a large amount of string comparisons in Java, after having been able to do them with == in C#, I can say this is really annoying.  I have to say though, I do like the substring better in Java than C#.  In C#, substring takes the beginning index and the number of characters to grab.  In Java, substring takes the beginning index and the ending index.  Much more often I have found that I know a beginning and ending index rather than a length.  Often in C# you will have to write confusing code like</p>
<p><pre class="brush: csharp;">

String myString = &quot;123FindMe456&quot;;

String newString = myString.Substring(myString.IndexOf(&quot;123&quot;), myString.Length - myString.IndexOf(&quot;456&quot;));

</pre></p>
<p>Which is pretty confusing, and I am always wondering if I am off by 1.  C# provides a method String.IsNullOrEmpty, which is very useful.  4.0 will provide IsNullOrWhitespace, which will be even more useful.  In Java, you have to check for null and empty separately, or write your own and then curse everyone for not using it.  String.Format is also nicer in C# vs Java.  I like being able to do String.Format(&#8220;The number {0} plus {1} is equal to {2}&#8221;, &#8220;one&#8221;, 3, &#8220;four&#8221;) vs in Java using String.Format(&#8220;The number %s plus %d is equal to %s&#8221;, &#8220;one&#8221;, 3, &#8220;four&#8221;);</p>
<p>Both languages have string builders.  In C#, I tend to use string.split, because it is easy and in Java I tend to use StringTokenizer, because I am always afraid I am going to insert an accidental regular expression in the Java String.split method.  Regular expressions are supported in both frameworks, although I think it is slightly easier to use the regular expressions in Java, while C# regular expressions are more powerful.  I couldn&#8217;t find a way to do a named capture in Java regular expressions.</p>
<p><strong>Final words</strong></p>
<p>In my mind, the C#&#8217;s .NET framework is a little larger and easier to use than the standard Java framework.  I don&#8217;t think they are very far apart in functionality or ease-of-use in most areas, but there are some notable areas where .NET stands out.  I don&#8217;t have the time or knowledge to cover all the various aspects of the two languages across all possible comparison avenues, but I have tried to focus on what I think is important as a developer.  I am currently developing mostly in Java, but not too long ago I was developing mostly in C#, so I feel I can make some good judgments between the two.  In my final part of this series I will talk about the tooling support for Java and C#, then I will move onto more interesting things.  (I am starting to get sick of talking about Java vs C#.)</p>
<p><a href="http://simpleprogrammer.com/2010/02/01/c-vs-java-part-1-the-languages/">C# vs Java Part 1: Language</a></p>
<p><a href="http://simpleprogrammer.com/2010/02/04/c-vs-java-part-2-the-platforms-web/">C# vs Java Part 2: Platforms</a></p>
<p><a href="http://simpleprogrammer.com/2010/02/09/c-vs-java-part-3-the-frameworks-io-db-concurrency-collections/">C# vs Java Part 3: Frameworks</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/368/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/368/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/368/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=368&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/02/12/c-vs-java-part-3-the-frameworks-network-reflection-security-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>
	</item>
		<item>
		<title>C# vs Java Part 3: The Frameworks (IO, DB, Concurrency, Collections)</title>
		<link>http://simpleprogrammer.com/2010/02/09/c-vs-java-part-3-the-frameworks-io-db-concurrency-collections/</link>
		<comments>http://simpleprogrammer.com/2010/02/09/c-vs-java-part-3-the-frameworks-io-db-concurrency-collections/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 16:03:53 +0000</pubDate>
		<dc:creator>jsonmez</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Language]]></category>

		<guid isPermaLink="false">http://simpleprogrammer.com/?p=353</guid>
		<description><![CDATA[The part of development you interact with most, besides the language itself, is the standard framework. It is very important to have a good framework to do the basic operations that are needed when writing code. I want to take a look at a very high level comparison of C# and Java and the corresponding [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=353&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The part of development you interact with most, besides the language itself, is the standard framework. It is very important to have a good framework to do the basic operations that are needed when writing code. I want to take a look at a very high level comparison of C# and Java and the corresponding base libraries of frameworks that are available to a programmer choosing either technology and language. I am aiming at a high level overview, trying to look at things that are important to me as a developer, such as: ease of use; flexibility; power. It is important to consider closely the framework usages for things that will be commonly used. The ability to easily read or write to a file, send a message over the network, or parse some text is very important because of how commonly these operations are needed in developing an application today.</p>
<p><strong>File IO</strong></p>
<p>File IO is something most of us have to do at one time or another and we expect it to be fairly painless. &nbsp;It amazes me sometimes how painful this simple operation is. &nbsp;How many times have I written an algorithm to read a number of bytes into a buffer, then loop until there are no more bytes to read, and finally put it together in a format I can use, hoping to not make a mistake. &nbsp;How many times have I made a mistake in that code, and spent wasted time debugging it. &nbsp;As a developer, I expect the framework to handle this for me. &nbsp;I don&#8217;t want to pack around my special utility classes from project to project, like a 1990s C++ with his &#8216;floppy disk of wonder&#8217;.</p>
<p>If you google or bing (if you prefer) for reading a file into a string in C#, you will find plenty of hits on code like this:</p>
<p><pre class="brush: csharp;">
string s = System.IO.File.ReadAllText( path );
</pre></p>
<p>I know this will be a topic of debate, but do the same kind of search for Java. &nbsp;You will see some mess like what I described above using a buffer in a loop, or you will see some reference to another library like Apache commons. &nbsp;FAIL. &nbsp;Every single time I have to write file IO code in Java, from back when I was learning it in college to today as a professional programmer, I have to look it up. &nbsp;Perhaps I am just dumb. &nbsp;Perhaps I have run out of brain buffer, but I can&#8217;t remember it. &nbsp;I think I shouldn&#8217;t have to. &nbsp;I know the C# example above is probably very inefficient, but when you just need to read the text of a short file into a string, it should be that easy. &nbsp;When you need to read a file in some other way, it should be pretty close to that easy. &nbsp;Bottom line for me is, it is pretty much that easy in C#&nbsp;but in Java file IO is painful and error prone.</p>
<p><strong>Collections</strong></p>
<p>Both Java and C# are pretty close to equal here if you don&#8217;t count concurrency, which I will cover in the concurrency section. The names are slightly different, but between the two languages, I would say that both provide easy-to-use and understandable implementations of most of the standards collections, with one exception, which I know will be remedied in C# 4.0&#8230; &nbsp;The<a href="http://en.wikipedia.org/wiki/Tuple"> tuple</a>. &nbsp;I like the tuple; when you need the tuple, only the tuple will do. &nbsp;Every time I reach out to grab a tuple, it is never there. &nbsp;I frown, spend 10 minutes debating between creating my own custom object, or using a list or map, or writing my own tuple class, and then finally rewrite the method so that it doesn&#8217;t beg for a tuple solution. &nbsp;(Alas, I digress). &nbsp;Anyway, both are pretty similar. &nbsp;Java had a better collection framework, but now they are pretty close. &nbsp;I have used both quite often, and have felt like both are fairly straightforward and do what you would expect.</p>
<p><strong>Concurrency</strong></p>
<p>If you don&#8217;t want to read this section because the idea of thread safe code scares you, I won&#8217;t blame you. &nbsp;If you don&#8217;t have any problem reading this section because your not afraid of concurrency issues, I don&#8217;t believe you. &nbsp;If you don&#8217;t like reading this section because it scares you, but you know you must do it, I respect you.</p>
<p>I&#8217;ll be honest. I try to avoid dealing with concurrency as much as possible. &nbsp;It has been a good strategy up till now, but it is becoming less and less possible to do so with the changing computing environments. &nbsp;Almost everyone has a multi-core cpu on their desktop nowadays.</p>
<p>I&#8217;ve heard a large amount of discussion back and forth that C# concurrency in the framework is inferior to Java, but I&#8217;m not entirely convinced of this. &nbsp;As far as I can tell, the main advantage Java has in this area is concurrency safe collections and atomic data types. &nbsp;Most of the other features exist in some form in .NET, just under a different name. &nbsp;.NET framework provides asynchronous support for web service proxies and other parts of the framework that allow a thread to be created that triggers a callback method when it is finished. &nbsp;.NET 4.0 is going to add concurrent collections, which will help even the playing field in this area.</p>
<p>Overall, until .NET 4.0 is released, Java will have the advantage here, but neither really handles concurrency at a level where a developer doesn&#8217;t have to be an expert in concurrency. &nbsp;.NET 4.0 will also contain <a href="http://en.wikipedia.org/wiki/Parallel_Extensions">Parallel Extensions</a>, which will automatically handle some of the concurrency issues commonly dealt with. &nbsp;<a href="http://en.wikipedia.org/wiki/Axum_(programming_language)">Axum</a> is also a promising technology under incubation, which seeks to design a domain specific concurrent programming language.</p>
<p><strong>Databases</strong></p>
<p>One of the most common things applications do today is interact with some from of database. &nbsp;It is very important to be able to easily work with a database in any development environment.</p>
<p>Both languages have made major leaps here in terms of framework. &nbsp;I won&#8217;t even compare JDBC and standard ADO anymore, since those are relics of the past. &nbsp;Instead I want to look at <a href="http://msdn.microsoft.com/en-us/library/bb425822.aspx">LINQ to SQL</a>, <a href="http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx">Entity Framework</a> and <a href="http://java.sun.com/developer/technicalArticles/J2EE/jpa/">JPA</a>.</p>
<p>On the .NET side there are two technologies that are jointly developed by Microsoft; LINQ to SQL and Entity Framework. &nbsp;In my mind the major difference between the two is that LINQ to SQL is a lightweight one-to-one mapping <a href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM </a>for a database while Entity Framework is for more complex mappings where you are transforming a relational schema to a domain object. &nbsp;Either way you go here, the main advantage is the ease-of-use which comes from the LINQ side of it. &nbsp;The language integrated features and the framework for using them are pretty tightly coupled here. &nbsp;It is very easy to set up and get going, especially with LINQ to SQL.</p>
<p>For Java JPA is also a very nice and easy to use framework that abstracts the database nicely. &nbsp;There isn&#8217;t much setup required and it uses annotations instead of implementing a large number of interfaces. &nbsp;(Which is a major change from EJB 2.1, which was much more painful). &nbsp;You can use Plain Old Java Objects (POJOs) which are annotated with JPA specific classes that tell the framework how to persist the entities. &nbsp;Everything is done within a transaction, and the developer doesn&#8217;t have to think much about database interaction.</p>
<p>Overall the two languages provide very similar functionality built into the frameworks for interacting with databases. &nbsp;C#&#8217;s use of LINQ does make C# a winner in my mind, because of how easy it is to move complex database operations down to the code level.</p>
<p><strong>To be continued &#8230; </strong></p>
<p>In my next post I&#8217;ll finish up frameworks, taking a look at Networking, Reflection, Security and Text Manipulation.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/complextosimple.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/complextosimple.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/complextosimple.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/complextosimple.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/complextosimple.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/complextosimple.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/complextosimple.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/complextosimple.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/complextosimple.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/complextosimple.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/complextosimple.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/complextosimple.wordpress.com/353/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/complextosimple.wordpress.com/353/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/complextosimple.wordpress.com/353/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=simpleprogrammer.com&amp;blog=10597120&amp;post=353&amp;subd=complextosimple&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://simpleprogrammer.com/2010/02/09/c-vs-java-part-3-the-frameworks-io-db-concurrency-collections/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/695e2a956b2dcb5ac45a7095b6ee338a?s=96&#38;d=retro&#38;r=PG" medium="image">
			<media:title type="html">jsonmez</media:title>
		</media:content>
	</item>
	</channel>
</rss>
