<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>./cmsimike &#187; code</title>
	<atom:link href="http://www.cmsimike.com/blog/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cmsimike.com/blog</link>
	<description>thoughts from a computer scientist</description>
	<lastBuildDate>Sun, 08 Jan 2012 22:20:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>On the Subjects of object == null and collection.size() == 0</title>
		<link>http://www.cmsimike.com/blog/2009/07/28/on-the-subject-of-object-is-null-and-collection-size-equals-0/</link>
		<comments>http://www.cmsimike.com/blog/2009/07/28/on-the-subject-of-object-is-null-and-collection-size-equals-0/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 20:38:12 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[education]]></category>
		<category><![CDATA[mistake]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[software engineering]]></category>

		<guid isPermaLink="false">http://www.cmsimike.com/blog/?p=161</guid>
		<description><![CDATA[Let&#8217;s just get one thing straight here people, an object that is null does not mean the same thing as a collection/array of length zero. I&#8217;m sort of seeing this more and more as I continue my existence on this planet and I say we put a stop to this now. Take this example method [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s just get one thing straight here people, an object that is null does not mean the same thing as a collection/array of length zero. I&#8217;m sort of seeing this more and more as I continue my existence on this planet and I say we put a stop to this now. Take this example method declaration (written in Java):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> Collection<span style="color: #339933;">&lt;</span>SearchResult<span style="color: #339933;">&gt;</span> getSearchResults<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> searchTerm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Straight forward enough, I would hope. This method takes in a searchTerm String, magic happens (ah abstraction), and a Collection of type SearchResult is returned. Now here is the kicker: what happens if the search query resulted in no results? What should be returned? And why?</p>
<p><span id="more-161"></span></p>
<p>At this point, we essentially have two options if we want to successfully return from this method without using exceptions: return null or return a Collection of type SearchResult of size n | n >= 0;</p>
<p>When returning a Collection, the size indicates how many SearchResults there were. If someone were to search for &#8220;cows&#8221; and the Collection contained 23 SearchResult objects, then we should say that the search had 23 results. Contrary to that, if there are 0 SearchResult objects then we can say that the search had no results.</p>
<p>When null is returned instead of a Collection, that can only mean that something has gone wrong. For instance, the search could not be completed for any reason. This should be the only reason a null should be returned. </p>
<p>By returning a null if a search has been successfully completed, even if there are no results, tells the caller that there may have been an error, which is not what you want to communicate. Returning null should be the worst case scenario in a circumstance like this. It is the duty of the implementer of the getSearchResults method to fully communicate the actual status of things by returning what is the most correct in any situation. </p>
<p>Please do not return null lightly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsimike.com/blog/2009/07/28/on-the-subject-of-object-is-null-and-collection-size-equals-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why Use Free and Open Source Software?</title>
		<link>http://www.cmsimike.com/blog/2009/04/09/why-use-free-and-open-source-software/</link>
		<comments>http://www.cmsimike.com/blog/2009/04/09/why-use-free-and-open-source-software/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 20:00:01 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apt]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.cmsimike.com/blog/?p=114</guid>
		<description><![CDATA[This entry was written with the developer in mind. Though none of this information is developer-specific, I don&#8217;t know of any non-developers who like to go through source code. I do look forward to the day where everyone reads code for the love of it.
Why use free open source software? There are many reasons why [...]]]></description>
			<content:encoded><![CDATA[<p><em>This entry was written with the developer in mind. Though none of this information is developer-specific, I don&#8217;t know of any non-developers who like to go through source code. I do look forward to the day where everyone reads code for the love of it.</em></p>
<p>Why use free open source software? There are many reasons why you should use it, a lot of which have been covered all over the internet ad nauseum, for instance <a href="http://www.dwheeler.com/oss_fs_why.html" target="_blank">Why Open Source Software</a> by <a href="http://www.dwheeler.com/" target="_blank">David A. Wheeler</a>. I am sure they are all great references as to why anyone should consider  <a href="http://en.wikipedia.org/wiki/Free_and_open_source_software" target="_blank">free and open source software</a> (FOSS) as a software solution. I am here to talk about why I think you should use FOSS and for me, one of the most important reasons to use FOSS is to give you the ability to figure out why things are going wrong on your computer.</p>
<p><span id="more-114"></span>While was looking into what source.list.d directory was about, I stumbled across <a href="http://ubuntuforums.org/showthread.php?t=116400" target="_blank">this thread</a> regarding sources.list.d. It didn&#8217;t really cover anything that I was looking for, though it did finally put into words why I love open source software. The question was asked as to why the source list files were not being picked up from within that directory. No one gave him a real answer. So the original poster decided to answer the question for himself by looking at the apt source code.</p>
<blockquote><p>Ok I solved the problem after looking at apt source. Files in the sources.list.d should end with .list. I changed and it works</p></blockquote>
<p>And like that, everything just made sense to me. As developers, we really don&#8217;t need to ask many questions. Worse comes to worse, we can always dive into the code and answer the questions for ourselves. That may not always be the most efficient way to go about getting an answer, but I really haven&#8217;t met a dedicated developer who does not like diving into code for themselves.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsimike.com/blog/2009/04/09/why-use-free-and-open-source-software/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learn to Code with Google Code University</title>
		<link>http://www.cmsimike.com/blog/2008/03/19/learn-to-code-with-google-code-university/</link>
		<comments>http://www.cmsimike.com/blog/2008/03/19/learn-to-code-with-google-code-university/#comments</comments>
		<pubDate>Wed, 19 Mar 2008 20:12:17 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[courses]]></category>
		<category><![CDATA[education]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[opencourseware]]></category>

		<guid isPermaLink="false">http://www.xekm.com/blog/?p=13</guid>
		<description><![CDATA[One thing that I have yet to commented much on, at least in this blog, is my love of education. If I had the resources available to me right now, I would have already begun my Masters in Computer Science coursework, then promptly start my Ph.D. However at this point in my life that cannot [...]]]></description>
			<content:encoded><![CDATA[<p>One thing that I have yet to commented much on, at least in this blog, is my love of education. If I had the resources available to me right now, I would have already begun my Masters in Computer Science coursework, then promptly start my Ph.D. However at this point in my life that cannot be [easily] done. How ever, thanks to free courses online, I never feel like I am missing out on further educating myself.</p>
<p><span id="more-13"></span></p>
<p>I was first turned on to this kind of online education with <a href="http://ocw.mit.edu/OcwWeb/web/home/home/index.htm" title="M.I.T. OpenCourseWare" target="_blank">M.I.T OpenCoruseware</a>. It provided a multitude of information at the right price, free. Although you do not end up with a degree at the end of taking these courses, it provides a great facility for anyone to spend time and learn. And really, what good is daily life if one doesn&#8217;t learn anything new? Well M.I.T. provides a great University perspective on this, but I always felt there needed to be another perspective available.</p>
<p>Today I came across <a href="http://code.google.com/edu/" title="Google Code University" target="_blank">Google Code University</a>. It is a series of online courses, much like M.I.T. is offering, however Google&#8217;s main focus is current technologies. From the website:</p>
<blockquote><p> This website provides tutorials and sample course content so CS students and educators can learn more about current computing technologies and paradigms. In particular, this content is Creative Commons licensed which makes it easy for CS educators to use in their own classes.</p></blockquote>
<p>It looks like Google is trying to expose people to more of the &#8220;real world&#8221; of computer science, which I am all for. Many are the students that graduate from computer science programs only to find out that what they have learned is not reflective of real world applications. With Google&#8217;s new course, it seems like they are trying to push for further education beyond the typical university level for individuals, as well as making it easier for universities to integrate Google&#8217;s courses into the actual university curriculum.</p>
<p>I have yet to sit down with Google&#8217;s online offering, but I do believe we already have a winner. Slow adaptation and integration of current technologies only leads to prolonged exposure to antiquated methodologies. Not to say that everyone should move to the latest and the greatest, because rarely is the latest ever the greatest, however through Google&#8217;s offering one is able to get a taste of current technologies and make an educated guess if the technology would work for a certain circumstance rather than blindly starting out and only finding out after 1/4 of the project time is over that the technology being used is completely wrong.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsimike.com/blog/2008/03/19/learn-to-code-with-google-code-university/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Celldoku &#8211; The J2ME Sudoku Experience</title>
		<link>http://www.cmsimike.com/blog/2008/03/10/celldoku-the-j2me-sudoku-experience/</link>
		<comments>http://www.cmsimike.com/blog/2008/03/10/celldoku-the-j2me-sudoku-experience/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 04:20:42 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[celldoku]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://www.xekm.com/blog/?p=7</guid>
		<description><![CDATA[Today&#8217;s post is going to be about my independent senior project at Loyola Marymount, Celldoku. I graduated in May of 2006, however only got around to uploading it into Sourcefoge a few weeks ago. I did plan on continuing development on it, however that plan was put on the back burner when I decided that [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal">Today&#8217;s post is going to be about my independent senior project at Loyola Marymount, <a title="Celldoku" href="http://celldoku.googlecode.com" target="_blank">Celldoku</a>. I graduated in May of 2006, however only got around to uploading it into Sourcefoge a few weeks ago. I did plan on continuing development on it, however that plan was put on the back burner when I decided that I would go the iPhone route when ever/if-ever they release a 3G version of the phone. Those plans went back onto the front burner when the rumor mill on the interwebs said that Sun is planning on porting a Java runtime environment to the iPhone (thanks to the recent announcement of the SDK). However I may end up recreating the project as a native iPhone application. We will see.</p>
<p class="MsoNormal"><span id="more-9"></span>Celldoku is a Java 2 <a title="J2ME" href="http://java.sun.com/javame/index.jsp" target="_blank">Micro Edition</a> implementation of a basic Sudoku game. There are 4 different difficulties to choose from. Due to the extremely complicated nature of generating a valid <a title="Sudoku" href="http://en.wikipedia.org/wiki/Sudoku" target="_blank">Sudoku</a> game, I did not even attempt to implement that aspect of it. The cell phone I was using at the time was far to slow for it to be a plausible route to pursue. Instead I have four static boards preloaded into the game, one for each difficulty. However, thanks to the idea of <a title="Caskey" href="http://www.technocage.com/~caskey/" target="_blank">Caskey Dickson</a>, one of the brightest people I&#8217;ve met, and educator in the computer science department of Loyola Marymount, I was able to implement a series of transformations that make it seem like you are playing a different Sudoku each time (for instance, moving rows around, but restrict it only to the 3&#215;3 sub-grid which that row is in. Then do the same with columns. Inverting the board and moving entire 3&#215;3 sub-grids around). Also by changing numbers around (for instance, all 4s become 3, all 3s become 7s, etc) you also get a feeling of randomization.</p>
<p class="MsoNormal">A solution I had to this problem was setting up a web server that would serve up Sudoku games to my Celldoku in a form it knows. That way if the user ever gets bored of the current board, a new game board could be downloaded from my web server and cached locally on the phone. That way not only do you get a board that has been randomized, but you can get a totally different starting board as well. Caching can be used if the user had no cell phone service, to still give quite the randomized experience during play as then the boards would be pulled from the local cache of boards. Alas, I never got around to implementing that for the final version turned in for class credit. That is on the list of things to do.</p>
<p class="MsoNormal">Now here is what sucks about it. Everything about that game is pretty much hard coded. If you have one of the original Motorola Razr V3 phones, then the game will operate, more or less, flawlessly. The screen dimensions are hard coded, as is the cursor movement. Although I would have loved to get all that code cleaned up prior to releasing it, I just never got around to it.</p>
<p class="MsoNormal">Future plans for the game include a dynamically built board to allow for play, as well as maximum enjoyment, on all types of different sizes of screens. I wanted to give the user the ability to put in numbers on the sides of boxes, much like how a typical user plays a Sudoku with a pencil and paper. The game gets extremely hard to play if the user cannot take notes. And don&#8217;t forget, the ability to contact my web server for more boards.</p>
<p class="MsoNormal">The project was built using <a title="Sun Java Wireless Toolkit 2.2" href="http://java.sun.com/products/sjwtoolkit/download-2_2.html" target="_blank">WTK 2.2</a> from <a title="Sun" href="http://www.sun.com" target="_blank">Sun</a>, <a title="Eclipse" href="http://www.eclipse.org/" target="_blank">Eclipse</a> and the <a title="EclipseME" href="http://www.eclipseme.org/" target="_blank">EclipseME</a> plug in. Using the <a title="EclipseME Tutorial" href="http://eclipseme.org/docs/installation.html" target="_blank">tutorial on EclipseME&#8217;s site</a>, there should be no problem getting everything setup and configured correctly. Then just build the JAR/JAD files and deploy to the device. Please contact me if you have any questions regarding this game.</p>
<p class="MsoNormal">*Edit*<br />
I guess it might be a good idea to provide an actual link, just to be sure:<br />
<a title="Celldoku" href="http://celldoku.googlecode.com" target="_blank"> http://celldoku.googlecode.com</a></p>
<p class="MsoNormal">*Edit 2*<br />
I have decided to start hosting my projects on <a title="Google Code" href="http://code.google.com/" target="_blank">Google Code</a>. And as such, I have moved all source files there. The current SourceForge version has been orphaned and will not be updated.<a title="Celldoku" href="http://celldoku.googlecode.com" target="_blank"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsimike.com/blog/2008/03/10/celldoku-the-j2me-sudoku-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

