<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" gd:etag="W/&quot;C0cAQXY9cSp7ImA9WhdTEEU.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254</id><updated>2011-07-07T16:24:00.869-07:00</updated><category term="ruby" /><category term="rest" /><category term="math" /><category term="javascript jquery" /><category term="design patterns" /><category term="nitpicking" /><category term="programming-languages" /><category term="shenanigans" /><category term="java" /><category term="workaround" /><category term="gamedev" /><category term="web" /><category term="books" /><category term="bug" /><category term="antlr" /><category term="apple" /><category term="programming" /><category term="games" /><category term="xna" /><category term="fail" /><category term="gui" /><category term="&quot;die perl die&quot;" /><title>Read Eval Bacon Loop</title><subtitle type="html">Where the bacon hits the non-deterministic fan.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/AndrewMchargsBlog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="andrewmchargsblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;D04ASXo4cCp7ImA9WxJbEUw.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-7153957742256899313</id><published>2009-07-20T11:03:00.000-07:00</published><updated>2009-07-20T11:52:28.438-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-20T11:52:28.438-07:00</app:edited><title>My take on Design Patterns</title><content type="html">In case you haven't filled your quota for reading sarcastic poorly written hyperbole about software construction I present my take on Design Patterns. Now with example python code.

&lt;h3&gt;Chapter 0: The singleton&lt;/h3&gt;

Since the invention of the stack and data structure programmers have been hounded by people telling them not to use globals. The singleton exists to confuse people until they give up criticizing your code for the use of global variables. Use them constantly.

&lt;h3&gt;Chapter 1: Constructin stuff is hard.&lt;/h3&gt;

Often times you want things but getting them is hard and fraught with complication. For example we might have a car object &amp;amp; constructor: Car(bankAccount). However we might want to abstract the nasty details of its construction since creating a car object should be easy:

&lt;code syle='clear: both;'&gt;
class CarFactory:
  def __init__(self,bankAccount):
     self.bankAccount = bankAccount
 
  # We could make this __call__ or even use a closure but
  # this confuses java &amp;amp; c++ programmers who are easily
  # frightened with out many lines of boilerplate code.
  def createCar(self):
      return Car(self.bankAccount)

creditCardForCar = CarFactory(lifeSavings)

# now elsewhere the nasty "details" are abstracted away
myNewCarIcantAfford = creditCardForCar.createCar()
&lt;/code&gt;

As you can see this is an ingenious pattern that is clearly better than using closures or currying of constructor arguments because now I have 2x as many objects.

&lt;h3&gt;Chapter II: Square pegs can go in round holes&lt;/h3&gt;

Say you are using a poorly designed library or even better several poorly designed libraries that must interact together prehaps a result of the &lt;a href="http://xkcd.com/323/"&gt;Ballmer peak&lt;/a&gt;. You will often have things like OMGBestLibraryEveryString and WTFBBQLibraryString. They are both strings that do that same thing but their authors seeing the clear deficiencies of using a standard string class have chosen to write a completely new one (because new is better).

Its times like these you need one of two things: a bottle of wiskey or a design pattern. Put down that single malt its time to create some facades and proxy. There are two names because it would be boring to call something a wrapper pattern. Also people might think you were saying rapper pattern which would lead to profound confusion and eventual disappointment.

in this case we do the following:

&lt;code&gt;
class FacadeWrapperProxyOfOMGBestLibraryEveryString:
   def __init__(self,bbqstring):
       self.bbqstring = bbqstring

   # no reimplement all 50 of bbqstring's methods 
   # and overloads minding painful edge cases and 
   # bugs! (you can get the wiskey out again)
&lt;/code&gt;

Now everything is wonderful again.

&lt;h3&gt;3: Messages and misc stuff&lt;/h3&gt;

Turns out even though OOP is modeled after passing messages to objects methods are not suitable for publish subscribe or message passing systems. This is very fortunate because now you can write extra objects to facilitate this lack of foresight.

&lt;h3&gt;Chapter iv: This chapter is missing because of a race condition in the chapter singleton manager factory.&lt;/h3&gt;

&lt;h3&gt;Chapter 5: Take back that CS theory&lt;/h3&gt;

Its really annoying when you are trying to engineer software and some "computer scientist" starts talking about algorithms and uses confusing words like state machine and language translation. Fear no more! They are now patterns! If someone suggests they are not just look perturbed and hand them a copy of design patterns.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-7153957742256899313?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/7153957742256899313/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=7153957742256899313" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/7153957742256899313?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/7153957742256899313?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2009/07/my-take-on-design-patterns.html" title="My take on Design Patterns" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;DEEMR3c9eSp7ImA9WxJWFE4.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-7985561988755370784</id><published>2009-06-19T11:32:00.000-07:00</published><updated>2009-06-19T11:38:06.961-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-19T11:38:06.961-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="nitpicking" /><category scheme="http://www.blogger.com/atom/ns#" term="gamedev" /><category scheme="http://www.blogger.com/atom/ns#" term="fail" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Canceling Xna</title><content type="html">&lt;p&gt;After a year of not using XNA creator's club and being generally morally opposed to the whole concept I decided to cancel it. Long story short this requires contacting xbox support (weeee). The only truly annoying part is how hard it is to find out this is what you must do and what the phone number is you must call.&lt;/p&gt;
&lt;p&gt;It seems borderline unethical to not have a mechanism for canceling your account that is as easy as signing up.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-7985561988755370784?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/7985561988755370784/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=7985561988755370784" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/7985561988755370784?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/7985561988755370784?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2009/06/canceling-xna.html" title="Canceling Xna" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;Dk8CQXY_eyp7ImA9WxJWE0s.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-3841480411550541058</id><published>2009-06-18T15:32:00.000-07:00</published><updated>2009-06-18T15:41:00.843-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-18T15:41:00.843-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gui" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="javascript jquery" /><category scheme="http://www.blogger.com/atom/ns#" term="web" /><title>jQuery bounding region plugin</title><content type="html">While working on some javascript network visualization software I am coding for work I came up with a jQuery plugin function that calculates the bounding box around the query using offset() and width() and height() returning an object that has left,top,bottom, and right members.
&lt;pre&gt;&lt;code&gt;(function() {
   jQuery.fn['bounds'] = function () {
     var bounds = {  left: Number.POSITIVE_INFINITY, 
                      top: Number.POSITIVE_INFINITY,
                    right: Number.NEGATIVE_INFINITY, 
                   bottom: Number.NEGATIVE_INFINITY};

     this.each(function (i,el) {
                 var elQ = $(el);
                 var off = elQ.offset();
                 off.right = off.left + $(elQ).width();
                 off.bottom = off.top + $(elQ).height();

                 if (off.left &lt; bounds.left)
                   bounds.left = off.left;

                 if (off.top &lt; bounds.top)
                   bounds.top = off.top;

                 if (off.right &gt; bounds.right)
                   bounds.right = off.right;

                 if (off.bottom &gt; bounds.bottom)
                   bounds.bottom = off.bottom;

               });
     return bounds;
   }
 })();
&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-3841480411550541058?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/3841480411550541058/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=3841480411550541058" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/3841480411550541058?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/3841480411550541058?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2009/06/jquery-bounding-region-plugin.html" title="jQuery bounding region plugin" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;A08GRns8fSp7ImA9WxVUFUo.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-1127291707335121401</id><published>2009-03-20T11:38:00.000-07:00</published><updated>2009-03-20T13:10:27.575-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-20T13:10:27.575-07:00</app:edited><title>Network Visualization in the Browser</title><content type="html">&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_11fyzU8B-jE/ScPjVOi31MI/AAAAAAAAAAw/j4CwFvFW6WE/s1600-h/example+layout.png"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_11fyzU8B-jE/ScPjVOi31MI/AAAAAAAAAAw/j4CwFvFW6WE/s320/example+layout.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5315341939048436930" /&gt;&lt;/a&gt;
&lt;p&gt;I am working on doing network visualization in javascript using &lt;a href='http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#the-canvas-element'&gt;html canvas&lt;/a&gt; via John Resig's excellent &lt;a href='http://ejohn.org/blog/processingjs/'&gt;processing.js&lt;/a&gt;. Right now it uses a force directed layout system where each edge in the graph has a spring and all nodes repulsed from each other. I noticed the results seem to be work best in firefox but not safari which makes me wonder if some of the Math object functions differently between the two? Once I separate out the connected components and remove the artificial walls around the simulation it should provide better results since the repulsion system wont cause the graph to expand indefinitely.&lt;/p&gt;
&lt;p&gt;This will be part of a large visualization system which I intend to open source if I can. The other part being a diagram tool more suitable for point to point circuits.&lt;/p&gt;
&lt;p&gt;Here is a link to my current &lt;a href="http://nmt-webdev.cac.washington.edu/.netviz/static/index.html"&gt;prototype visualizer&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-1127291707335121401?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/1127291707335121401/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=1127291707335121401" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/1127291707335121401?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/1127291707335121401?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2009/03/network-visualization-in-browser.html" title="Network Visualization in the Browser" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/_11fyzU8B-jE/ScPjVOi31MI/AAAAAAAAAAw/j4CwFvFW6WE/s72-c/example+layout.png" height="72" width="72" /><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;CkAARHk8eip7ImA9WxVQEEQ.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-5389688544723922474</id><published>2009-01-27T11:17:00.000-08:00</published><updated>2009-01-27T13:12:25.772-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-27T13:12:25.772-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="rest" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="web" /><title>Building internal webapps</title><content type="html">&lt;p&gt;I couple months ago I picked up Enterprise Integration Patterns. It was a lot better then I thought it would be considering it contained the word enterprise in the title. The premise of the book is that using message queues/buses allows for easier integration of applications even spanning organizational boundaries.
&lt;/p&gt;&lt;p&gt;
This got me thinking about web services exposed through REST/http. One of the nice benefits of http is that it has clients in almost every language and environment. While exposing services and tools with a http interface can solve more than the immediate problem of feeding your ajax app it can also allow a larger set of people to leverage your service.
&lt;/p&gt;&lt;p&gt;
It seems like the smartest thing any organization that has lots of internal services could do would be to make a directory of such services maybe even use RDF. Of course the problem is the reliability of these services may vary depending on the needs of the original author and the maintainer. Requiring the author of every web service to make sure their service is up 24/7 might not be appropriate.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-5389688544723922474?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/5389688544723922474/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=5389688544723922474" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/5389688544723922474?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/5389688544723922474?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2009/01/building-internal-webapps.html" title="Building internal webapps" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A08HQ348eSp7ImA9WxRaFE0.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-5050296279732938692</id><published>2008-12-15T22:28:00.000-08:00</published><updated>2008-12-15T22:43:52.071-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-15T22:43:52.071-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="nitpicking" /><category scheme="http://www.blogger.com/atom/ns#" term="gamedev" /><category scheme="http://www.blogger.com/atom/ns#" term="bug" /><category scheme="http://www.blogger.com/atom/ns#" term="workaround" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="math" /><title>Rotations and lame network cards</title><content type="html">&lt;p&gt;It occurred to me while debugging my 3d camera that rotations are far to rotatey. R^T = R^-1 = R(-a) which means if you have a bug it can be confusing and potentially work to some degree even though really your code is completely crazy. In this case I was uploading rotations into opengl that were row major when it is in fact column major. Another amusing thing is if your rotation is several rotations such as R = r(a)r(b)r(c) then R^-1 = r(c)^-1 * r(b)^-1 * r(a)^-1 which means your rotations are now going to be done in a different order in the opposite directions.
&lt;/p&gt;&lt;p&gt;
I would also like to thank my marvell yukon network card for failing at life. It was trying to offload checksum calcs in vista but doing a &lt;b&gt;worse&lt;/b&gt; job than my CPU. So much so that it was causing team fortess 2 to be inoperable. Luckily these things can be adjusted.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-5050296279732938692?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/5050296279732938692/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=5050296279732938692" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/5050296279732938692?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/5050296279732938692?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/12/rotations-and-lame-network-cards.html" title="Rotations and lame network cards" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;A04NQnk-eip7ImA9WxRXF0k.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-3466525147559237706</id><published>2008-10-23T01:16:00.000-07:00</published><updated>2008-10-23T01:19:53.752-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-23T01:19:53.752-07:00</app:edited><title>Fan!</title><content type="html">&lt;p&gt;Interesting new language named &lt;a href="http://fandev.org/"&gt;fan&lt;/a&gt;? Seemed nifty. However their stance of generics seems a bit odd. Generics suck so lets build a couple cases into the language... Hmmmmmm
&lt;/p&gt;&lt;p&gt;
Hmmmmmmmmmmm......
&lt;/p&gt;&lt;p&gt;
Discus!
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-3466525147559237706?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/3466525147559237706/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=3466525147559237706" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/3466525147559237706?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/3466525147559237706?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/10/fan.html" title="Fan!" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;CkQCRH48eCp7ImA9WxRXFks.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-579984183131547817</id><published>2008-10-21T23:56:00.001-07:00</published><updated>2008-10-22T00:26:05.070-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-22T00:26:05.070-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="nitpicking" /><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="programming-languages" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="antlr" /><title>Programming languages! Programming languages!</title><content type="html">&lt;p&gt;&lt;a href="http://www.antlr.org/works/index.html"&gt;ANTLRWorks&lt;/a&gt; is like crack. I am trying to build a bastard child of ml and ruby and maybe a little scheme mixed back in for good measure. One of my favorite features from haskell is the pattern matching which seems like a no brainer for adding to a scripting language.
&lt;/p&gt;&lt;p&gt;
I have also been picking up ruby lately and its surprising how good it is. Some people compare it to being similar to python. This is not the case--it has a lot more delicious features. Succulent indeed.
&lt;/p&gt;&lt;p&gt;
Then there is groovy which is subtly disappointing but sure as shit beats writing actual java but not by enough. At least java makes sense in its own crippled and ridiculous way.
&lt;/p&gt;&lt;p&gt;
Try passing a function as a value in groovy from inside it self. Sure it has whatever hack is needed for recursion but apparently it is only half-baked. Very disappointing. How am I supposed to use recursion in conjunction with higher order functions? I may post something somewhere so it can some how get fixed. Its kind of embarrassing to bring up so it seems more sensible just to make my own language (yup I am crazy).
&lt;/p&gt;&lt;p&gt;
Wont someone please think of the functions!
&lt;/p&gt;&lt;p&gt;
Anyways ANTLR is awesome and I am sleepy. I will probably post more of whatever language I cook up if it ever amounts to anything.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-579984183131547817?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/579984183131547817/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=579984183131547817" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/579984183131547817?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/579984183131547817?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/10/programing-languages-programming.html" title="Programming languages! Programming languages!" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DE4BQXc5cCp7ImA9WxRQFEs.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-6531084265153380339</id><published>2008-10-08T03:57:00.000-07:00</published><updated>2008-10-08T04:55:50.928-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-08T04:55:50.928-07:00</app:edited><title>The annoying thing about everything programming...</title><content type="html">&lt;p&gt;Java is like a mysterious creature. The language itself has no grandeur or mystery with its decrepit non-unsigned-integer body but as a technology it is at the very least a nice way to get a garbage collector that doesn't suck too much out of things. It's also amusing seeing just how hard people are willing to work to get the language into a state that is actually usable.
&lt;/p&gt;&lt;p&gt;
This stems from a long line of tradition most likely (I am entirely making this up) of taking boring language X and tarting it up. Some languages have stream lined this process by adding macros, templates, dsls and all manners of delicious treats to tantalize programmers with their deviously delicious syntactical and semantic confectionery but at the core of most of the language is a dull and powerless language.
&lt;/p&gt;&lt;p&gt;
What is interesting is the lengths we go to pave over the obvious problems. Your agile OOP programming language not as agile as you wished? Integration getting you down? Have no fear inversion of control--IOC is here to randomly give you a chain saw and a stirring spoon so you can recombine your classes like some kind of Frankenstein soup.
&lt;/p&gt;&lt;p&gt;
Its actually not an entirely terrible idea. This is because while programming in a language whose name shall be protected to well protect things I ended up pretty much coding one. A bad one mind you but now that I started learning spring I realized it. But like most random-chainsaw enhanced Frankenstein soups they must be used with caution.
&lt;/p&gt;&lt;p&gt;
I also more or less discovered a really bad version of lisp this way (thanks C++). The problem with programming languages is perspective. A person wearing their java goggles only sees insanity in the C and dynamically typed/interpreter camps. Same goes for languages. Functional programmers can only think of how stupid C++ is etc...
&lt;/p&gt;&lt;p&gt;
At the heart of the problem is that every programmer is secretly and silently searching for "the solution". Its hardwired in our brains like some kind of brain damaged salmon. We can not escape getting lost up the metaphorical drain pipe of language zealotry. The fact that something so important could mired in duplicity is like some inefficiency: to be compressed, optimized and ultimately erased.
&lt;/p&gt;&lt;p&gt;
This doesn't mean java is a steaming pile of poorly design dog poo as a programming language its more profound than that. We maybe mired one collective dog poo of non-orthogonality. However it does not help things when people are seemingly willfully ignorant.
&lt;/p&gt;&lt;p&gt;
Some of it is good old fashion good nature idiocy that we maintain at some level pretty much as soon as we are capable of having an opinion. Part of the problem is that computer science gets distilled as technology and through this process of decanting becomes a form of canon. Relations go in a relational database. Lisp is for crazy guys who write AI. C is a good idea--along with the Von Neumann architecture. The practical reasons for these decisions forever lost to most people as forests whose trees will never emerge again.
&lt;/p&gt;&lt;p&gt;
We use these familiar tools as crutches to form our ideas on how to solve problems never stopping to wonder in greater detail or perhaps fearful of dizzying height technology has built upon itself.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-6531084265153380339?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/6531084265153380339/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=6531084265153380339" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/6531084265153380339?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/6531084265153380339?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/10/annoying-thing-about-everything.html" title="The annoying thing about everything programming..." /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>2</thr:total></entry><entry gd:etag="W/&quot;DEEAQHs7fCp7ImA9WxRRGU4.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-6147442954765544713</id><published>2008-10-02T01:02:00.000-07:00</published><updated>2008-10-02T01:37:21.504-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-10-02T01:37:21.504-07:00</app:edited><title>Diffing and journaling xml documents</title><content type="html">&lt;p&gt;I am somewhat sleepy but I think its time I ill advisedly hurled some thoughts into my blog.
&lt;/p&gt;
&lt;p&gt;I inherited a project recently that I got around to finally working on involving synchronizing network device data in a db using diffing/journaling using xml documents.
&lt;/p&gt;
&lt;p&gt;The problem with finding the difference between two xml documents or anything for that matter is deciding on a set of operations that will be used to transform one to the other. Then real problem though in the case of my problem is given two xml documents what is the optimal set edits that transform one to the other.
&lt;/p&gt;
&lt;p&gt;Traditionally utilities like diff find the LCS to minimize the number of edits. In this case I wanted the edits to be as granular and as simple as possible. With a one to one correspondence it makes updating things like a database with the change set an easy task.
&lt;/p&gt;
&lt;p&gt;The method for actually determining what is different in an xml document is the interesting part however. In the case of structured data like xml you often have collections of entities such as network interfaces which all have some defining characteristic such as a name or id code. This can be used as a key to compare the nodes in the xml tree so that even if they are out of order they can still be properly compared.
&lt;/p&gt;
&lt;p&gt;The reason for wanting to be able to handle unordered collections of things (sets some might call them) stems from the initial problem it self mainly lack of information. If for some reason the interface is discovered in a different order you really don't want adds and deletes generated simply because it moved.
&lt;/p&gt;
&lt;p&gt;The way this all ends up being computes is using xpath expressions. One expression expression to determine a node set in each document that is potentially comparable and another to which is applied to each individual node in each document which returns the key used for determining if the nodes have the same name/identity.
&lt;/p&gt;
&lt;p&gt;Sometimes problems are only as simple as you allow them to be. In this case a fully generic diff or comparison on a pair of xml documents hardly makes sense. Without some information about the meaning of the documents the data that would have a high potential for being unwieldy and useless.
&lt;/p&gt;
&lt;p&gt;Of course I have thought about abandoning the diff/journaling model all together but unfortunately having a list of exact changes that have taken place is too useful.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-6147442954765544713?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/6147442954765544713/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=6147442954765544713" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/6147442954765544713?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/6147442954765544713?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/10/diffing-and-journaling-xml-documents.html" title="Diffing and journaling xml documents" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkEHSHw9fCp7ImA9WxZbF0Q.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-5120119558685559619</id><published>2008-04-20T22:13:00.000-07:00</published><updated>2008-04-21T10:23:59.264-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-21T10:23:59.264-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gamedev" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="xna" /><title>Embedding IronPython</title><content type="html">&lt;p&gt;I am trying my luck with embedded IronPython 2 using the DLR so I thought I would share some of the steps to make that happen.&lt;/p&gt;

&lt;p&gt;Prereqs:
&lt;ul&gt;
&lt;li&gt;Microsoft.Scripting.dll&lt;/li&gt;
&lt;li&gt;IronPython.dll&lt;/li&gt;
&lt;li&gt;IronPython.Modules.dll&lt;/li&gt;
&lt;/ul&gt;&lt;/p&gt;

&lt;p&gt;These all come from the &lt;a href="http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=10266"&gt;IronPython2 beta 1&lt;/a&gt; release--and yes you need all of them. Failing to add IronPython.Modules.dll as a reference results in strange errors when trying to get the scripting engine which can be confusing.&lt;/p&gt;

&lt;p&gt;The interface to IronPython and presumably other DLR languages is through the Microsoft.Scripting.Hosting.ScriptEngine class. There seems to be about a billion ways to get the engine here is what worked for me:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
ScriptEngine engine;

engine = PythonEngine.CurrentEngine;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This gets/creates the ScriptEngine for IronPython. Next we create a Microsoft.Scripting.Hosting.ScriptScope which allows for variables to be bound on the embedder's end before the script is run. It also can be inspected after the script is run.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
ScriptScope scope = engine.CreateScope();
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now all that is left is to load the script &lt;b&gt;woooo&lt;/b&gt;. Doing this creates a Microsoft.Scripting.Hosting.ScriptSource object which can have fun things done to it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
ScriptSource source = engine.CreateScriptSourceFromFile("myScript.py");
source.Execute(scope);
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This loads a script and then executes it using the scope that was created. The contents of the scope can be examined afterwards like I said which can be useful if you want to create factories that return an extended C#/CLR class that can then be used like normal.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
TacticsGame game = scope.GetVariable&lt;TacticsGame&gt;("game");
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This gets the global "game" form the script. In order for this to work right you need to add the assembly references to your script. This can be done in two ways. First you can do it the normal way from inside the script:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
import clr
clr.AddReference("MyAssembly.dll")
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This works but its kind of annoying if MyAssembly.dll is actually the same assembly that the script is being hosted in or some other assembly that is known. Another way is to call engine.Runtime.LoadAssembly and feed it assemblies it should know about. See &lt;a href="http://msdn2.microsoft.com/en-us/library/system.reflection.assembly_members.aspx"&gt;System.Reflection.Assembly&lt;/a&gt; for some ways of getting these assemblies.&lt;/p&gt;

&lt;p&gt;Hopefully this works a bit better than boo did!&lt;/p&gt;

&lt;p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;a href="http://www.voidspace.org.uk/ironpython/dlr_hosting.shtml"&gt;Embedding example&lt;/a&gt;&lt;/dt&gt;
&lt;dd&gt;An informative but trying on the eyes tutorial.&lt;/dd&gt;
&lt;dt&gt;&lt;a href="http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython"&gt;IronPython Website&lt;/a&gt;&lt;/dt&gt;
&lt;dd&gt;In all of its official and incompletely documented glory.&lt;/dd&gt;
&lt;/dl&gt;
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-5120119558685559619?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/5120119558685559619/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=5120119558685559619" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/5120119558685559619?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/5120119558685559619?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/04/embedding-ironpython.html" title="Embedding IronPython" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D0UFRHw-cSp7ImA9WxZbF0k.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-3775339548440484170</id><published>2008-04-20T13:46:00.000-07:00</published><updated>2008-04-20T19:33:35.259-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-20T19:33:35.259-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gamedev" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="xna" /><title>XNA ContentManager.RootDirectory Considered Annoying as Hell ( XCCAH)</title><content type="html">&lt;p&gt;Beware of older XNA code using code created by the new project templates! The newer code sets the root directory of Content to "Content/" which breaks all my old code and was very confusing. Which leaves me wondering if they are going to include that as the default why not change it in the class! Blargg. Now any "game libraries" which have content that gets loaded have to worry about what the RootDirectory setting is at unless they use their own ContentManager.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/microsoft.xna.framework.content.contentmanager.rootdirectory.aspx"&gt;ContentManager.RootDirectory Property&lt;/a&gt; &lt;-- boo&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-3775339548440484170?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/3775339548440484170/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=3775339548440484170" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/3775339548440484170?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/3775339548440484170?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/04/xna-contentmanagerrootdirectory.html" title="XNA ContentManager.RootDirectory Considered Annoying as Hell ( XCCAH)" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;D0QCSXs8cSp7ImA9WxZbFU4.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-7881836619820447477</id><published>2008-04-16T17:52:00.000-07:00</published><updated>2008-04-18T09:16:08.579-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-18T09:16:08.579-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="nitpicking" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="&quot;die perl die&quot;" /><title>Time to put patches down.</title><content type="html">&lt;p&gt;When you are coding what we might call language X and you ever think "yay it actually lets me do this non-stupid thing" such as map, filter or anything really a sane person might need when constructing software then you know you have a problem.&lt;/p&gt;
&lt;p&gt;I am looking at you perl 5.&lt;/p&gt;

&lt;p&gt;*glare*&lt;/p&gt;
&lt;p&gt;Ruby,anything from ml,python,scheme,lisp... I can't count the number of better languages suited for most jobs perl gets used for still. I normally not a language zealot but jebus! If I see another perl hash with elements whose values are "1" because perl has not set data type I am going to vomit.&lt;/p&gt;
&lt;p&gt;Perl is not regression in programming languages as much as it is a scripting language that is on life support. Its an old man clinging to life after a long and fulfilling life. Its time to pull the plug and let gramps die in peace.&lt;/p&gt;

&lt;p&gt;OK I lied it probably was but lets just let it die in dignity. Perl was one of my  first scripting languages so well I hate it slightly less than I should but still...&lt;/p&gt;

&lt;p&gt;You know its bad when you would rather be writing java than perl. Actually its not too bad with anonymous classes. Why the hell they don't add anonymous functions I don't know. I guess they don't want to ruin the master piece that is java.&lt;/p&gt;

&lt;p&gt;mmm rant tastic. I need to record my insane ramblings so that whatever future society goes through my blog (cause you know they will) gets the record straight. I am one of those scary computer scientist Larry Wall warns you about in programming perl--and I hate sunshine puppies and probably a lot other things. Especially kittens. I also eat metal scraps and speak in binary. In fact I often eat kittens for desert while speaking in binary.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-7881836619820447477?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/7881836619820447477/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=7881836619820447477" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/7881836619820447477?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/7881836619820447477?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/04/time-to-put-patches-down.html" title="Time to put patches down." /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CE8CQHcyfyp7ImA9WxZUEUw.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-5330705621832607306</id><published>2008-04-01T22:04:00.000-07:00</published><updated>2008-04-01T22:07:41.997-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-01T22:07:41.997-07:00</app:edited><title>Wendorb</title><content type="html">Mmmm cafe!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-5330705621832607306?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/5330705621832607306/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=5330705621832607306" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/5330705621832607306?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/5330705621832607306?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/04/wendorb.html" title="Wendorb" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUcGQXo_eSp7ImA9WxZUEUw.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-2612844943403608063</id><published>2008-01-30T16:17:00.000-08:00</published><updated>2008-04-01T22:10:20.441-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-01T22:10:20.441-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Java Restlet api rocks</title><content type="html">&lt;p&gt;I have been using the java &lt;a href="http://www.restlet.org/"&gt;Restlet&lt;/a&gt; api for network topology stuff and it is quite nice. Seldom do you come across cleanly designed APIs these days it seems. It avoids a lot of the common pit falls java apis seem to enjoy:

&lt;dl&gt;
   &lt;dt&gt;Factory diarrhea == teh sux&lt;/dt&gt;
   &lt;dd&gt;Everyone who has used java has probably experienced this. If you are writing api realize that most people don't give a crap about a configurable factory. Give people concrete instances of things that default to a particular implementation. Configurablity is good but I should not need to enter a deep philosophical debate with my compiler just to determine how it should parse XML.&lt;/dd&gt;
   &lt;dt&gt;Fixed verbosity&lt;/dt&gt;
   &lt;dd&gt;Most libraries have a fixed way something must be done. More than likely the level of verbosity required to do it inappropriate for what the user is doing. Design your classes so they can function with out extra functions calls and other pointless boiler plate code if you can. When the user needs more control they can specify it when needed. People can learn your library faster and programming with it will be much more pleasurable.&lt;/dd&gt;
   &lt;dt&gt;Documentation&lt;/dt&gt;
   &lt;dd&gt;People seem to have strange ideas about what appropriate levels of documentation is. Hint: you need more than just javadocs/doxygen output. Your software should be the sum of its parts. Documenting the individual pieces in isolation with out providing more detail makes learning how to use your code orders of magnitude more difficult.&lt;/dd&gt;
   &lt;dt&gt;Use standard abstractions&lt;/dt&gt;
   &lt;dd&gt;If the language provides a standard library with things like iterators and structures &lt;b&gt;use them&lt;/b&gt;! If programs are essentially language recognition and translation (which they are) then using common concepts is essential. If you don't do this you are failing at communicating with the people reading your code and also doing a poor job communicating with the machine which you are instructing.&lt;/dd&gt;
&lt;/dl&gt;

There is a billion more tips but these are the major ones.

&lt;ul&gt;
 &lt;li&gt;&lt;a href="http://www.acmqueue.com/modules.php?name=Content&amp;pa=showpage&amp;pid=488"&gt;API: Design Matters&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href="http://www.acmqueue.org/modules.php?name=Content&amp;pa=showpage&amp;pid=317"&gt;Programmers are People, Too&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-2612844943403608063?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/2612844943403608063/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=2612844943403608063" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/2612844943403608063?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/2612844943403608063?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/01/java-restlet-api-rocks.html" title="Java Restlet api rocks" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;C0ANRnc6cSp7ImA9WxZSFk4.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-9169820971594729914</id><published>2008-01-28T13:31:00.000-08:00</published><updated>2008-01-29T10:36:37.919-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-29T10:36:37.919-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gamedev" /><category scheme="http://www.blogger.com/atom/ns#" term="gui" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="xna" /><title>Rolling your own CSS</title><content type="html">&lt;p&gt;Having an easily data driven method for customizing style information can be invaluable for building nice user interfaces. For special purpose user interfaces like games it is even more important. Designers need to be able to easily skin and customize different UI elements with out having to alter source code.&lt;/p&gt;
&lt;h3&gt;UI Elements as Properties&lt;/h3&gt;
To control the look of user interface elements a simple flat set of properties can be used such as "background-color" or "font".

A style sheet is simply a class that you can get and set properties from:
&lt;code&gt;
class Style {
  public object GetValue(IStyleable target,
                         string propertyName);

  public void SetValue(StyleSelecter selecter,
                       string propertyName, object value);
}
&lt;/code&gt;
Just like in CSS a common way to refer to elements is needed. I used StyleID, a set of Classes and a Type to replicate the familiar id,class,elementType trio. This is formulated in a simple interface:
&lt;code&gt;
interface IStyleable {
  string StyleID { get; }
  ICollection&amp;lt;string&amp;gt; { get; }
  string StyleType { get; }
}
&lt;/code&gt;
A predicate for if a certain property definition applies is needed:
&lt;code&gt;
abstract class StyleSelector {
  public abstract bool Matches(IStyleable target);
}&lt;/code&gt;
&lt;h3&gt;Finding a Property&lt;/h3&gt;
&lt;p&gt;Every selector must at the very least support the ability to find a property by an O(n) search--this is what the Matches method is all about. Finding a property consists of a search over a list property definitions (StyleSelector,name,value). If a definition's name matches and StyleSelector.Matches is true then the search is terminated and value is returned as the value for that property.&lt;/p&gt;&lt;p&gt;In order for the cascading part to make any sense an ordering of property definitions needs to be defined. CSS solves this problem with the notion of &lt;a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#specificity"&gt;specificity&lt;/a&gt;. Properties with more stringent criteria for being applied are allowed to float to the top and are used over the more generic definitions.
&lt;/p&gt;
&lt;p&gt;For my purposes I organize things simply by id &amp;gt; classes &amp;gt; type &amp;gt; *. So selectors that specify the id of its target are examined first. This conveniently allows for property searches to be culled to smaller sets that must be visited. Hashtables for each of these categories can be constructed to speed up search times so that for example (id,name) is indexed. This reduces linear searching only to custom and other miscellaneous selectors.
&lt;/p&gt;
&lt;h3&gt;Combining Selectors&lt;/h3&gt;
&lt;p&gt;Aggregated selectors can be formulated based the AND logical operator. Since AND is commutative the selector can be rummaged through for any sub-selectors that are indexable. This can then be used as criteria for which index the aggregation should be inserted into. For example #myButton:hover can be inserted into the id indexing table since it contains an id selector.
&lt;/p&gt;&lt;p&gt;
I will probably post the code to this and the rest of my GUI toolkit when I am done / bored with it.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-9169820971594729914?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/9169820971594729914/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=9169820971594729914" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/9169820971594729914?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/9169820971594729914?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/01/rolling-your-own-css.html" title="Rolling your own CSS" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkYEQnY-eyp7ImA9WB9aGUQ.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-8110454358888505216</id><published>2008-01-10T11:54:00.000-08:00</published><updated>2008-01-10T12:48:23.853-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-10T12:48:23.853-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gamedev" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Game Rules 1</title><content type="html">&lt;p&gt;I mentioned I would talk about a domain specific language for game rules so I will but first a rant on why the term DSL is silly and some discussion on what a game rule itself will be.&lt;/p&gt;&lt;h3&gt;The term DSL is kind of stupid&lt;/h3&gt;&lt;p&gt;Like any good acronym one day you wake up and it is as if while you were sleeping everyone got together and decided to surprise you the next day. Suddenly people realized they could make their own languages to solve specific problems and that this was now the neatest thing since sliced bread and other suitably neat cliches.&lt;/p&gt;&lt;p&gt;It is not that I am opposed to them. I just find it appallingly annoying how computer science and the software industry is often reduced to fads. It is as if all the people who slept through their compilers courses (really when else are you going to get a nap?) suddenly realized that this information was actually useful. DSLs don't solve all of your problems--but being smart and knowing the theory behind them will transform them into useful tools. I suggest picking up the dragon book and books on automata and language theory.&lt;/p&gt;&lt;h3&gt;What is a game rule?&lt;/h3&gt;&lt;p&gt;When playing games generally there is a set of rules to play by. These usually follow as consequences for some action the player does. These rules can also be the consequences of actions by other rules. Such as a player moves his piece on a board game and receives 5 points. He already has 10 and it only takes 15 to win lets say. The rule for winning was based off an action from another rule (gaining 5 points).&lt;/p&gt;&lt;p&gt;A game rule is action and then a consequence or more formally a predicate and some function that changes the course of game play somehow. R = (P(s),F(s)) So to apply a rule P(s) must be satisfied. Then s := F(s). Of course fashioning this into an actual usable system will require more work which I will save for next time.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-8110454358888505216?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/8110454358888505216/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=8110454358888505216" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/8110454358888505216?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/8110454358888505216?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/01/game-rules-1.html" title="Game Rules 1" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CUAGQXk-fCp7ImA9WB9aFE4.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-6111272793586681755</id><published>2008-01-03T23:43:00.001-08:00</published><updated>2008-01-04T00:02:00.754-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-04T00:02:00.754-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gamedev" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Game rule DSL maybe?</title><content type="html">I am cooking up an idea for a game rule DSL and will probably post more when I actually start working on it. I am also kind of sleepy right now but think of something db triggers except not awful and crazy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-6111272793586681755?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/6111272793586681755/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=6111272793586681755" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/6111272793586681755?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/6111272793586681755?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/01/game-rule-dsl-maybe.html" title="Game rule DSL maybe?" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CEIBQ384fCp7ImA9WB9aFE4.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-7755046610739777871</id><published>2008-01-03T23:38:00.000-08:00</published><updated>2008-01-03T23:42:32.134-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-03T23:42:32.134-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="books" /><title>Reading Wizards First Rule</title><content type="html">Started reading the Wizards First Rule by Terry Goodkind after a friend recommended it. Seems pretty entertaining so far! Time to go read more.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-7755046610739777871?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/7755046610739777871/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=7755046610739777871" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/7755046610739777871?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/7755046610739777871?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2008/01/reading-wizards-first-rule.html" title="Reading Wizards First Rule" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkEHRXY7cSp7ImA9WB9UE04.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-8346571318693189878</id><published>2007-12-10T17:52:00.000-08:00</published><updated>2007-12-10T18:03:54.809-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-10T18:03:54.809-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="bug" /><category scheme="http://www.blogger.com/atom/ns#" term="workaround" /><category scheme="http://www.blogger.com/atom/ns#" term="apple" /><title>Leopard Keyboard Freeze Workaround</title><content type="html">Sometimes my keyboard freezes in in leopard apparently this is a known &lt;a href="http://www.appletell.com/apple/comment/leopard-bringing-macbook-macbook-pro-keyboard-freezes/"&gt;issue&lt;/a&gt;.

You can fix it if you plug-in a usb keyboard! At least it worked with some dell keyboard that was floating around my desk. That would be a fun bug to track down. It triggers rarely and seems to be related to spaces usage.

I thought about submitting the bug to apple but I couldn't find their bug tracker! I guess big companies don't need or care about user submitted bugs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-8346571318693189878?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/8346571318693189878/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=8346571318693189878" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/8346571318693189878?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/8346571318693189878?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2007/12/leopard-keyboard-freeze-workaround.html" title="Leopard Keyboard Freeze Workaround" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>3</thr:total></entry><entry gd:etag="W/&quot;CkYMRXo6cCp7ImA9WB9VE0U.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-4139827785517265129</id><published>2007-11-29T14:24:00.000-08:00</published><updated>2007-11-29T15:49:44.418-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-29T15:49:44.418-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gamedev" /><category scheme="http://www.blogger.com/atom/ns#" term="design patterns" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>Design Pattern Soup</title><content type="html">&lt;p&gt;While designing the class that manages my game objects the other night on a project I came across an interesting pattern. Using the visitor pattern with a mediator to add objects.&lt;/p&gt;
&lt;code&gt;interface IRenderable {
  public void DrawMe();
}

class Renderer {
  public void Add(IRenderable renderable);
  public void Remove(IRenderable renderable);
}
&lt;/code&gt;
&lt;p&gt;This is normal looking code for most applications. The power of being able to add random things that can be drawn is very useful. There are several problems with this first it can be important what order things are rendered when drawing 2d and 3d graphics. Also for the purposes of batching it may be very important to group like objects together.&lt;/p&gt;&lt;p&gt;These two problems can make things somewhat messy. Its possible to overcome them naturally. For instance we could include an integer that describes the order which renderables are to be drawn and sort them that way. For batching each renderable could queue it self up for rendering and then after a certain number of objects are in the queue or if it needs to be flushed for example if we are done rendering. Of course the batcher would have to somehow register it self with the renderer also since presumably only the renderer knows when its done drawing and any retained style buffers need to be flushed.&lt;/p&gt;&lt;p&gt;There is a simpler way which at first may seem silly and that is to have the objects register themselves at the request of the renderer--basically the visitor pattern.&lt;/p&gt;
&lt;code&gt;
interface IRenderable {
  public void DrawMe();

  public void Add(Renderer renderer);
  public void Remove(Renderer renderer);
}

class Renderer {
  public void AddSpecialDohicky(Dohicky dohicky);
  public void RemoveSpecialDohicky(Dohicky dohicky);

  public void Add(IRenderable renderable) {
      renderable.Add(this);
  }

  public void Remove(IRenderable renderable) {
      renderable.Remove(this);
  }
}
&lt;/code&gt;&lt;p&gt;This allows for all sorts of interesting behavior. Also IRenderable could still support a basic one size fits all DrawMe() call if needed. Another side effect of this is that the Dohickys don't have to actually to be implementers of IRenderable which leaves things wide open for using composition instead of inheritance.&lt;/p&gt;&lt;p&gt;Naturally the draw back is that the Renderer is coupled with Dohickies but it makes it much easier to add optimizations to your renderer since it for example can cross coordinate with other objects being rendered so you do not have a bunch of objects operating in a vacuum simply for the sake of proper OO design. Like everything its all a matter of trade offs.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-4139827785517265129?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/4139827785517265129/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=4139827785517265129" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/4139827785517265129?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/4139827785517265129?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2007/11/design-pattern-soup.html" title="Design Pattern Soup" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkcDQH4_eSp7ImA9WB9WFk4.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-4601325875393351552</id><published>2007-11-20T23:15:00.000-08:00</published><updated>2007-11-20T23:27:51.041-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-20T23:27:51.041-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="nitpicking" /><category scheme="http://www.blogger.com/atom/ns#" term="games" /><title>Hellgate London</title><content type="html">Hellgate London is a fun game but it lacks polish. I have had it crash twice on my 2 GB machine with an out of memory error and on two other separate occasions objects appeared to stop updating.&lt;div&gt;
&lt;/div&gt;&lt;div&gt;It also is missing some things I kind of hoped would be no brainer additions from Titan Quest. Do I really need these displacement do hickers or scrolls of identify 2.0? Also the setting is fun at first but once you have been in one london sewer system you kind of have seen them all. Hopefully the game will transition to being just in hell or something more interesting.&lt;/div&gt;&lt;div&gt;
&lt;/div&gt;&lt;div&gt;On a positive note I enjoy the number of rare monsters that seem to show up in the game. Basically that and all the classic diablo features make the game fun but the crafting/upgrade system seems to be adding an additional element of game play that is amusing. Still you would think certain things would basically become more or less standard in hack in slashes such as displaying DPS not just damage!&lt;/div&gt;&lt;div&gt;
&lt;/div&gt;&lt;div&gt;With some patches the game has even more potential. Despite my nitpicking and bitchery I still seem to be playing a great deal of it. If in a couple of months I am still playing the game then I suppose it really is a success (go partial reenforcement scheduling!).&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-4601325875393351552?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/4601325875393351552/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=4601325875393351552" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/4601325875393351552?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/4601325875393351552?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2007/11/hellgate-london.html" title="Hellgate London" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;CkUAR3s8eyp7ImA9WB9WFUs.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-2926544108146893801</id><published>2007-11-20T03:59:00.000-08:00</published><updated>2007-11-20T04:04:06.573-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-20T04:04:06.573-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="shenanigans" /><category scheme="http://www.blogger.com/atom/ns#" term="games" /><title>I have defeted crysis!</title><content type="html">Very pretty game and long enough to keep me entertained! I kind of wish I could have blown more stuff up at the end but hey...&lt;div&gt;
&lt;/div&gt;&lt;div&gt;Now I am sleepy but first I must drink orange juice. Apparently I am participating in some sort of auxiliary thanks giving this friday also. Two turkeys... mmmm......&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-2926544108146893801?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/2926544108146893801/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=2926544108146893801" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/2926544108146893801?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/2926544108146893801?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2007/11/i-have-defeted-crysis.html" title="I have defeted crysis!" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;DEUFQ3w7fCp7ImA9WB9WFU8.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-1100359769430107521</id><published>2007-11-19T18:09:00.000-08:00</published><updated>2007-11-19T18:36:52.204-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-19T18:36:52.204-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><title>A relational model for REST</title><content type="html">&lt;p&gt;For awhile I have had the desire to create some sort of fantastic contraption that combines relational databases and REST services that allows for people for example to mash up distributed data in a nice formal and hopefully automated way.&lt;/p&gt;&lt;p&gt;I do not know much about database theory but the main difference is that with a REST service it is usually impossible to enumerate a given set of relations. This is something a query planner/relational calculus could easily work around I would imagine. Naturally some types of queries would be impossible!&lt;/p&gt;&lt;p&gt;The other half of the solution would be a common registry of adapters and relations since such software would need to have definitions as to what nouns are compatible and how to convert between similar data but with different interfaces. This would make work writing software that uses distributed services much simpler. Imagine being able to do use SQL joins to mash data up!&lt;/p&gt;&lt;p&gt;Maybe I will try hacking such a system up when I am not playing one of the bazzilions games that just came out (Mario Galaxy is awesome!). Hopefully it wont be to hard to create a proof of concept.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-1100359769430107521?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/1100359769430107521/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=1100359769430107521" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/1100359769430107521?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/1100359769430107521?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2007/11/relational-model-for-rest.html" title="A relational model for REST" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry><entry gd:etag="W/&quot;AkQHRXs-cSp7ImA9WB9WFEQ.&quot;"><id>tag:blogger.com,1999:blog-1107649793489699254.post-4892722592457913621</id><published>2007-11-19T10:39:00.001-08:00</published><updated>2007-11-19T10:52:14.559-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-19T10:52:14.559-08:00</app:edited><title>Trying blogger</title><content type="html">I have realized I am far to lazy to run and host my own blog. This also has to do with the fact that I would rather spend my time doing other things. This is why I am giving blogger a whirl! Hopefully its not too terrible. One of my concerns is there was no model for just being a presistant store for an rss feed/rest service. But it has a system for ftping your blog to a site. How old fashioned!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1107649793489699254-4892722592457913621?l=andrew-mcharg.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://andrew-mcharg.blogspot.com/feeds/4892722592457913621/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1107649793489699254&amp;postID=4892722592457913621" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/4892722592457913621?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1107649793489699254/posts/default/4892722592457913621?v=2" /><link rel="alternate" type="text/html" href="http://andrew-mcharg.blogspot.com/2007/11/trying-blogger.html" title="Trying blogger" /><author><name>Andrew</name><uri>http://www.blogger.com/profile/14915510837550321048</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://2.bp.blogspot.com/_11fyzU8B-jE/SQLGWQvwacI/AAAAAAAAAAM/oOdqhqQIku4/S220/Adium+Icon.png" /></author><thr:total>0</thr:total></entry></feed>

