<?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>[self setTitle:nil]; &#187; Code</title>
	<atom:link href="http://cole.nitroy.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://cole.nitroy.com</link>
	<description>A diary of bad decisions.</description>
	<lastBuildDate>Tue, 03 Nov 2009 19:23:39 +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>Changing Gears</title>
		<link>http://cole.nitroy.com/2009/10/changing-gears/</link>
		<comments>http://cole.nitroy.com/2009/10/changing-gears/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 16:58:33 +0000</pubDate>
		<dc:creator>Coleman</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://cole.nitroy.com/?p=176</guid>
		<description><![CDATA[I have been working day and night on one project. I have a few ideas for other projects, some good, some not so good, but no matter what I keep telling myself to hold off on them until the main project is finished.
After giving it some thought I think holding off is the wrong approach. [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working day and night on <a href="http://cole.nitroy.com/2009/10/sneak-peak/">one project</a>. I have a few ideas for other projects, some good, some not so good, but no matter what I keep telling myself to hold off on them until the main project is finished.</p>
<p>After giving it some thought I think holding off is the wrong approach. I should allocate some resources to a side project. It will slow down the main project speed a little bit, but I think that this approach will increase the quality of the main project. </p>
<p>When doing web applications it was not uncommon to switch back and forth between projects on a bi-weekly basis. In doing so I would be disgusted with the &#8220;old&#8221; code when switching back to a project. I would then merge in changes and updates to shared code, modify things a bit to fit the &#8220;new&#8221; way of thinking. Basically all the ideas and knowledge I had acquired since working on this project would be merged back.</p>
<p>My brain never stops learning and growing so why should my projects stop as well? I am taking on a minor project that I will force myself to work on for a full day once a week. I am hoping that in doing so I will dig myself out of the hole one can do when spending too much time on one thing.</p>
<p>Sneak peak screenshots of the upcoming side project to be posted soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://cole.nitroy.com/2009/10/changing-gears/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sneak Peak</title>
		<link>http://cole.nitroy.com/2009/10/sneak-peak/</link>
		<comments>http://cole.nitroy.com/2009/10/sneak-peak/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 21:32:27 +0000</pubDate>
		<dc:creator>Coleman</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://cole.nitroy.com/?p=172</guid>
		<description><![CDATA[No updates as of late due to intense stretches of coding.
Here is a sneak peak at what is coming up.
]]></description>
			<content:encoded><![CDATA[<p>No updates as of late due to intense stretches of coding.</p>
<p>Here is a sneak peak at what is coming up.</p>
<div id="attachment_173" class="wp-caption aligncenter" style="width: 424px"><img src="http://cole.nitroy.com/wp-content/uploads/2009/10/Screen-shot-2009-10-02-at-4.31.37-PM.png" alt="Turkeys?" title="Turkeys?" width="414" height="770" class="size-full wp-image-173" /><p class="wp-caption-text">Turkeys?</p></div>
]]></content:encoded>
			<wfw:commentRss>http://cole.nitroy.com/2009/10/sneak-peak/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>To Settings.app or not to Settings.app</title>
		<link>http://cole.nitroy.com/2009/08/to-settings-app-or-not-to-settings-app/</link>
		<comments>http://cole.nitroy.com/2009/08/to-settings-app-or-not-to-settings-app/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 18:56:49 +0000</pubDate>
		<dc:creator>Coleman</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://cole.nitroy.com/?p=122</guid>
		<description><![CDATA[I have recently been looking into best practices for iPhone applications. I have two applications in the pipeline, both require settings but are very different in their type. After looking into the options I&#8217;ve decided Apple&#8217;s settings application could use some fixing.
According to Apple&#8217;s developer documentation, the Settings application should be used in &#8220;productivity-style applications&#8221;.
Adding [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been looking into best practices for iPhone applications. I have two applications in the pipeline, both require settings but are very different in their type. After looking into the options I&#8217;ve decided Apple&#8217;s settings application could use some fixing.</p>
<p>According to Apple&#8217;s developer documentation, the Settings application should be used in &#8220;productivity-style applications&#8221;.</p>
<blockquote><p>Adding your application preferences to the settings application is most appropriate for productivity-style applications and in situations where you have preference values that are typically configured once and then rarely changed.</p></blockquote>
<p>The documentation goes on to say that applications should not duplicate the functionality of the settings application, nor should they be used in utility style applications or applications with few preferences.</p>
<p>I think this is the wrong approach all together. This breaks application flow, and in many cases, preferences despite proper verbage, will not always be 100% clear. In some cases a user may want to switch a preference, see how the application&#8217;s functionality has changed then switch again.</p>
<p>There are also preferences that fall under the &#8220;set once&#8221; category and some that fall under the &#8220;depends on my mood&#8221; category. My favorite IM application Beejive IM suffers from this problem, preference schizophrenia. Take Beejive IM&#8217;s &#8220;More&#8221; tab.</p>
<div id="attachment_129" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-129" title="Beejive IM more tab" src="http://cole.nitroy.com/wp-content/uploads/2009/08/Settings3.PNG" alt="Beejive IM more tab" width="320" height="480" /><p class="wp-caption-text">Beejive IM </p></div>
<p>There are no settings in this tab, although, you can set the application&#8217;s wallpaper here. This is a good example of a setting that a user will try out quickly, but schizophrenia lurks around the corner. Clicking the Support tab brings up an FAQ. There is a question in the FAQ &#8220;Where are my settings?&#8221; that points the user to the settings application.</p>
<p>The settings application has a bit of a lag when loading in 3rd party applications, and because of this, coupled with it not being natural to change application settings outside of an application, I rarely notice these. When directed here looking for Beejive IMs settings I found settings to applications I was unaware had settings. Either I had checked here after installing it, and they were added in a later update or I just missed them altogether. </p>
<div id="attachment_127" class="wp-caption aligncenter" style="width: 330px"><img class="size-full wp-image-127" title="Application Settings" src="http://cole.nitroy.com/wp-content/uploads/2009/08/Settings1.PNG" alt="Application Settings" width="320" height="480" /><p class="wp-caption-text">Application Settings</p></div>
<p>Inside the Beejive IM settings pages there are a ton of settings, some of which are closely related to the wallpaper setting that is located inside the application. Changing the wallpaper could make text unreadable, and require me to quit the application, change the color scheme from settings and relaunch Beejive IM and hope I do not have to repeat. &#8220;Status Icons&#8221; and &#8220;Table Divider&#8221; are both settings which I need more instant visual feedback to make a decision. When preferences are outside the application and I am not 100% certain how they work, I am less apt to play around with them.</p>
<div id="attachment_128" class="wp-caption aligncenter" style="width: 330px"><img src="http://cole.nitroy.com/wp-content/uploads/2009/08/Settings2.PNG" alt="Beejive IM Settings" title="Beejive IM Settings" width="320" height="480" class="size-full wp-image-128" /><p class="wp-caption-text">Beejive IM Settings</p></div>
<p>Now do not get me wrong. From a developer stand point the SDK provides a really easy way to create preferences. The new file dialog has a &#8220;settings bundle&#8221; which creates a easy to edit and understand XML file. From there accessing the preference values is as simple as two lines of code (replacing &#8220;typeForKey&#8221; with the proper type int, bool, etc&#8230;)</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #400080;">NSUserDefaults</span> <span style="color: #002200;">*</span>userDefaults <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSUserDefaults</span> standardUserDefaults<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>userDefaults typeForKey<span style="color: #002200;">:</span>preference_key<span style="color: #002200;">&#93;</span>;</pre></div></div>

<p>It is obvious that Apple is trying to solve the issue of preference interfaces being horrendously designed as well as trying to keep everything in one neat and tidy location. Fixing the the issue of the user not being aware of preferences could be solved with a badge icon for updated settings bundles at application install time. This would notify the user of settings needing to be set, and get some of the first time settings out of the way. Apple&#8217;s own documentation says this area is for settings that will be touched once. The setting buttons for 3rd party applications should launch the settings pages in the application in question so as to alleviate the issue with switching back and forth and trying out settings.</p>
<p><strong>TL;DR version</strong><br />
Disadvantages</p>
<ul>
<li>Breaks application workflow.</li>
<li>Confusing to users used to desktop style settings.</li>
<li>Hard to &#8220;try out&#8221; preferences quickly</li>
</ul>
<p>Advantages</p>
<ul>
<li>Very easy for developers to implement.</li>
<li>Attempts to keep bad settings UI design away from the user</li>
</ul>
<p>Possible Solutions</p>
<ul>
<li>Badge notifications for updated / added 3rd party preferences when an application is installed or updated</li>
<li>Settings part of the SDK allows for creation of a settings page collection that is viewed and accessed inside the application itself.</li>
<li>Clicking the application from the settings application opens the settings pages inside the 3rd party application.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://cole.nitroy.com/2009/08/to-settings-app-or-not-to-settings-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How Dumb I Was or Lessons From the Past</title>
		<link>http://cole.nitroy.com/2009/07/how-dumb-i-was-or-lessons-from-the-past/</link>
		<comments>http://cole.nitroy.com/2009/07/how-dumb-i-was-or-lessons-from-the-past/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 02:20:27 +0000</pubDate>
		<dc:creator>Coleman</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://cole.nitroy.com/?p=75</guid>
		<description><![CDATA[Starting a new project usually calls upon looking thru previously written code. I fired up a previous class I wrote 5 years ago to load a texture into OpenGL. Right away just reading the definition I recoiled in horror:

13
14
15
16
17
18
19
20
21
22
23
@interface WFTexture : NSObject &#123;
    // Bitmap data
    NSBitmapImageRep *bitmap;
&#160;
  [...]]]></description>
			<content:encoded><![CDATA[<p>Starting a new project usually calls upon looking thru previously written code. I fired up a previous class I wrote 5 years ago to load a texture into OpenGL. Right away just reading the definition I recoiled in horror:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #a61390;">@interface</span> WFTexture <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span> <span style="color: #002200;">&#123;</span>
    <span style="color: #11740a; font-style: italic;">// Bitmap data</span>
    <span style="color: #400080;">NSBitmapImageRep</span> <span style="color: #002200;">*</span>bitmap;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Bitmap information</span>
    <span style="color: #a61390;">double</span> width, height;
    GLenum pixfmt, bpp, datatype;
&nbsp;
    <span style="color: #11740a; font-style: italic;">// Texture ID</span>
    GLuint textureID;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>After reading thru this code a pattern emerged. I was creating objects for the sake of creating objects, instead of using objects to solve a specific problem. For example, why would I need to keep around the original bitmap data after it has already been offloaded to the GPU? To a lesser extent why would I need to keep around the bpp or pixel format of the data offloaded aside from out right wasting system resources.</p>
<p>I then started to look at the implementation which I will snip for brevity:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSBitmapImageRep</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> bitmap <span style="color: #002200;">&#123;</span> <span style="color: #a61390;">return</span> bitmap; <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setBitmap<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSBitmapImageRep</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span> newBitmap
<span style="color: #002200;">&#123;</span>
    <span style="color: #002200;">&#91;</span>newBitmap retain<span style="color: #002200;">&#93;</span>;
    <span style="color: #002200;">&#91;</span>bitmap release<span style="color: #002200;">&#93;</span>;
    bitmap <span style="color: #002200;">=</span> newBitmap;
<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span><span style="color: #002200;">&#41;</span> width <span style="color: #002200;">&#123;</span> <span style="color: #a61390;">return</span> width; <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span><span style="color: #002200;">&#41;</span> height <span style="color: #002200;">&#123;</span> <span style="color: #a61390;">return</span> height; <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>GLenum<span style="color: #002200;">&#41;</span> bpp <span style="color: #002200;">&#123;</span> <span style="color: #a61390;">return</span> bpp; <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>GLenum<span style="color: #002200;">&#41;</span> datatype <span style="color: #002200;">&#123;</span> <span style="color: #a61390;">return</span> datatype; <span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span>GLuint<span style="color: #002200;">&#41;</span> textureID <span style="color: #002200;">&#123;</span> <span style="color: #a61390;">return</span> textureID; <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> setTextureID<span style="color: #002200;">:</span> <span style="color: #002200;">&#40;</span>GLuint<span style="color: #002200;">&#41;</span> texid
<span style="color: #002200;">&#123;</span>
    textureID <span style="color: #002200;">=</span> texid;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>The implementation makes me certain I was thinking too much about the object and not enough about the problem it is used to solve. Aside from being able to access various bits of information about the original image data (bpp, width, height, datatype) I created set and get methods for both the bitmap data and the OpenGL texture ID. </p>
<p>If this was supposed to be a reusable object giving access to setting the texture ID would have be atrocious. Instead of changing the ID, a whole new texture object should be created. Also take note that once the bitmap was set to something new, no OpenGL texture data was uploaded. If I was really bent on storing the bitmap data in memory as well in VRAM, then bent on allowing the changing of this bitmap data, the set method should at least re-upload the new bitmap data to the graphics card. But I digress. </p>
<p>The only bit of code I thought about snagging from this entire object was this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> on
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> width <span style="color: #002200;">!=</span> height <span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	glEnable<span style="color: #002200;">&#40;</span>GL_TEXTURE_RECTANGLE_EXT<span style="color: #002200;">&#41;</span>;
	glBindTexture<span style="color: #002200;">&#40;</span>GL_TEXTURE_RECTANGLE_EXT, textureID<span style="color: #002200;">&#41;</span>;
    <span style="color: #002200;">&#125;</span>
    <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
	glEnable<span style="color: #002200;">&#40;</span>GL_TEXTURE_2D<span style="color: #002200;">&#41;</span>;
	glBindTexture<span style="color: #002200;">&#40;</span>GL_TEXTURE_2D, textureID<span style="color: #002200;">&#41;</span>;
    <span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span> off
<span style="color: #002200;">&#123;</span>
    <span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span> width <span style="color: #002200;">!=</span> height <span style="color: #002200;">&#41;</span>
	glDisable<span style="color: #002200;">&#40;</span>GL_TEXTURE_RECTANGLE_EXT<span style="color: #002200;">&#41;</span>;
    <span style="color: #a61390;">else</span> 
	glDisable<span style="color: #002200;">&#40;</span>GL_TEXTURE_2D<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<p>But I thought otherwise when I realized this code makes way to many state changes. Objective-C is very object intensive and you are rewarded for creating proper objects, but it makes it very easy to waste resources. Going over old code I wrote was a great learning exercise for me, and it drove home the point that I need to only write methods and properties as I use them.</p>
]]></content:encoded>
			<wfw:commentRss>http://cole.nitroy.com/2009/07/how-dumb-i-was-or-lessons-from-the-past/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5</title>
		<link>http://cole.nitroy.com/2009/07/html5/</link>
		<comments>http://cole.nitroy.com/2009/07/html5/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 23:08:02 +0000</pubDate>
		<dc:creator>Coleman</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://cole.nitroy.com/?p=67</guid>
		<description><![CDATA[HTML5 can be great for the web. I for one would love to see mass adoption of HTML5 in all browsers and many sites. A non-flash youtube would make me incredibly happy. But alas the battle for open source continues.
Open source is great, but at the point where the licensing and patenting arguments get in [...]]]></description>
			<content:encoded><![CDATA[<p>HTML5 can be great for the web. I for one would love to see mass adoption of HTML5 in all browsers and many sites. A non-flash youtube would make me incredibly happy. But alas the battle for open source continues.</p>
<p>Open source is great, but at the point where the licensing and patenting arguments get in the way of furthering computing I say screw it. Enough.</p>
<p>Basically it boils down to this: H.264 is the superior technical choice and logistical choice, while Ogg/Theora is the idealistic choice. Yes you can send me mail all day long about Theora can be just as grand looking as H.264 but out of the box support for H.264 is far higher. It is built into hardware and most modern operating systems ship with it.</p>
<p>To all those Stallmanites complaining that Apple has some devious plans: <em>You are wrong</em>. If you sold hardware that had built in support for a specific format, would you not stick with that format? Would it not provide the better experience to your users? </p>
<p>Ultimately it is about furthering computing, not waging some ideals war.</p>
]]></content:encoded>
			<wfw:commentRss>http://cole.nitroy.com/2009/07/html5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
