Monthly ArchiveAugust 2003



Software 30 Aug 2003 05:19 pm

Building Parsers With Java

Building Parsers with Java

Software 29 Aug 2003 10:57 pm

Commentary on Commenting

Brian Marick posits in Exploration Through Example that code is only as readable as the audience is literate. It sounds obvious on the surface, but he brings out some subtleties in the idea, and links to some interesting non-CS books about understanding style’s affect on meaning.

On initial inspection, I completely agree with his idea. I find that as I have been learning new languages like Ruby and Lisp, the syntax is pretty easy, but what takes time to really absorb is how it is used idiomatically. Reading a lot of other code seems to be the best way to get to it, well coupled with writing code.

Ruby blocks are a great example of idiomatic power in a language. Most of the standard stuff can yield to a block. A great one I discovered the other day was changing the sort behavior on an array. In Java I would create a Comparator class that took the items and compared particular properties. The properties would of course have to implement Comparable explicitly. Then I would pass those things into Collections.sort.

class Thing implements Comparable {
private Comparable someOtherFieldToSortOn;
public static void main(String[] args) {
Collection things;
Collections.sort(things, new Comparator() {
public int compareTo(Object a, Object b) {
return a.someOtherFieldToCompareOn.compareTo(b.someOtherFieldToCompareOn);
}
}
}

In ruby, I just pass a block to the sort call.
class Thing
attr_reader: @someOtherThing
end

things.sort { |a,b| a.someOtherThingToSortOn<=>b.someOtherThingToSortOn }

This code assumes that you have already implemented a comparable in Java or a <=> in Ruby that is the standard sorter.

In Ruby, the block also gets lexical closure which is really nice as well. I am still figuring out all the ways to use that.

Software 29 Aug 2003 10:55 pm

Simplicity and Frameworks

On Christian Sepulveda’s BlogĀ  I saw a reference to a quote from Einstein that I love.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius–and a lot of courage–to move in the opposite direction. –Albert Einstein

I wonder if this is why it feels like it takes me so long to get up to speed using a new, unfamiliar, large code base sometimes? The problem is that as I am reading the code in a framework to figure out how to use it, I often find things that I would expect to be done in a different way. Personally, my first response is to think that another way is better. Nowadays, I assume that there was a good reason it was developed differently, and I then ask what was the reason? The problem is that after a certain number of these interruptions I get lost. I have to step back and reorganize my thoughts on the higher level organizing principles. What problem are we solving? What problems did they encounter solving it in the obvious way?

I have to start building the structure I want, or refactoring the existing structure to code in the way that I want, a way that I consider better and worth the initial investment. After some time, I usually ending up coding faster than others on the project, but I have to build out a structure first. Am I too arrogant? Do I just want a system that I built instead of something else? Do I know better how to organize software? Am I a lousy crackpot programmer who thinks he knows better, but is full of shit?

Software 29 Aug 2003 05:10 pm

Commentary on Commenting

Brian Marick posits in Exploration Through Example that code is only as readable as the audience is literate. It sounds obvious on the surface, but he brings out some subtleties in the idea, and links to some interesting non-CS books about understanding style’s affect on meaning.

On initial inspection, I completely agree with his idea. I find that as I have been learning new languages like Ruby and Lisp, the syntax is pretty easy, but what takes time to really absorb is how it is used idiomatically. Reading a lot of other code seems to be the best way to get to it, well coupled with writing code.

Continue Reading »

Software 28 Aug 2003 09:37 pm

FIT testing

FIT Wiki is a place to learn about the FIT integration testing framework. Once I have time again, I think I will investigate further. It looks like it might be a useful way to let non-programmers write acceptance tests. I am a bit leary, but who knows.

There is also a version of the framework in Ruby by Dave Thomas.

Software 28 Aug 2003 01:15 pm

Ahh, that special feeling

Alright, I’m a registered Moveable Type user, and it feels good. I love supporting independent software vendors that make good products. Next up I think I’ll register Opera and NetNewsWire.

I wonder if these guys make a decent living doing this?

Software 27 Aug 2003 03:20 pm

MT2.64

Just upgraded to MoveableType 2.64. It is time to give them a donation. Great software.

Beware moving your blog across systems. There may be a different version of Berkeley dbm. There are tools liek dump and db_upgrade that can help, somtimes. I unfortunately had to export all my entries and create new blogs and re-import the entries. This was not because of the MT upgrade, but because my provider upgraded. Argghhh.

Uncategorized 14 Aug 2003 06:33 pm

Ruby Class Hierarchy Pictures and ri Browser

Ruby Class Hierarchy and ri are two handy tools for learning ruby. The contrib directory for ri even has an emacs plugin that lets you examine the docs for a ruby function on point. Of course, getting the paths straight through windows, emacs, and cygwin seems tedious, hopefully it will work better on the Mac.

Uncategorized 12 Aug 2003 04:50 pm

Patterns Quiz

GoF design patterns quiz. Test your knowledge of the Gang of Four Design Patterns.

Uncategorized 05 Aug 2003 07:06 pm

Open Directory – Computers: Systems:

Open Directory – Computers: Systems: Apple: Macintosh: Development: Languages: Python