Thursday, September 22, 2011

The Teacher

I was fortunate enough to help organize the Strange Loop 2011 conference, but this post is not specifically about that. During the conference, I had the privilege to talk to several of the speakers, and one stood out for me in a way I won't forget. Professor Gerald Sussman is the Panasonic Professor of Electrical Engineering at MIT and is perhaps best known (at least among the people that might read this blog) for inventing the Scheme programming language and co-writing Structure and Interpretation of Computer Programs (also known as "SICP" and the "Wizard Book"). Though this textbook is nearly 30 years old, it continues to be recommended reading for hackers who seek a deep understanding of computer programming.


2011-09-20 14.19.03

During the conference, I had several occasions to speak with Professor Sussman about a great range of topics. Professor Sussman is fantastically knowledgeable about many things. If you ever get a chance to have a conversation with the man, I highly recommend dropping everything to do it. At one of the session breaks, I caught the Professor at a coffee station and asked him about something I had heard, which was that in addition to being an expert in electrical engineering he was also a watchmaker. He told me that he had received a Rolex watch as a gift after earning his doctorate (in 1973) and that at some point the watch needed to be cleaned. He sent the watch (which he still wears) to Rolex and noticed upon its return that they had been careless in cleaning it and had either smudged the inside of the crystal or damaged the watch face (I unfortunately don't recall exactly the detail of the blemish). His abundant curiosity lead him to taking it apart to fix the mistake made at the factory. This was apparently Professor Sussman's introduction to the fine art of watch making.


Since that time, the Professor has been pursuing experience in the art of watch making. He told me that he travels weekly to the shop of one of the few Master Watchmakers in Massachusetts (somewhere in Stoneham) to do work in exchange for guidance in an art that only a master watchmaker can provide. I couldn't get this story out of my head. Here I was, talking to one of the most revered computer scientists of our time and listening to him recount his own journey toward mastery in a field other than what has been his life's work. It was both humbling and inspiring to hear that the man still lives the life of a learner.


Dr. Sussman doesn't have a cell phone and he doesn't watch television. Free time is too valuable to him to waste on such things. He occupies himself pursuing new understanding and sharing his panoptic knowledge with his own students. This man is a nerd. He is a nerd's nerd. I might say he wears his nerd on his sleeve, but he wore short-sleeve shirts during the conference and instead wore his nerd where it belongs: on his shirt pocket. (Below is a pocket protector generously given to me by Julie Sussman, Professor Sussman's wife and co-conspirator in the pursuit of awesome).


Nerd Pride


As we were chatting casually, I mentioned that I have trouble getting more than five hours of sleep a night. He only smiled and said I was "winning" because it gave me more hours to be alive. This perspective reflects an attitude that recognizes how many things there are in the world to learn, and more than that to relish in understanding. It was one of the most inspiring, personal experiences that I can remember.


The lecture above was taken from MITWorld.

Professor Gerald Sussman | Speakers | MIT World

Thank you Scott Bale, for capturing the shot when Professor Sussman was teaching me a great lesson.

Saturday, January 01, 2011

Test-Driven Learning (with Koans)

I wrote a piece on my employers tech article site about learning programming languages by fixing broken unit tests meant to expose little nuggets of wisdom. The article covers projects that provide programming exercises for 3 languages: Ruby, JavaScript and Clojure. Please read and let me know if you like it: http://sett.ociweb.com/sett/settJan2011.html

Saturday, October 16, 2010

Strangeloop Day 2

Opening Talk: NoSQL in the Enterprise (Billy Newport)

IMG_0026

Came in halfway through this talk but really enjoyed what I heard. The talk pointed out how NoSQL datastores aren't a clean replacement for relational databases and that their use must be considered carefully because of inherent complexities that come with schema-less distributed data storage. This talk was video taped, look for it online when the conf talks are published.

Next talk: JavaScript Functions (Scott Bale)

IMG_0027

Scott went through a number of function invocation patterns that Douglas Crockford describes in his book, "JavaScript, the Good Parts". This talk was also video taped, look for it. I am in the process of reading the book this talk is based on at the moment and I recommend it for anyone who has an interest in JavaScript.

He discussed the use of constructor functions to restrict scope and access to data as well as using modules to apply a namespace to JS functions.

Next talk: Classes are a Premature optimization (Justin Love)

IMG_0028

What many people think of as object-oriented programming seems to be class-oriented programming.

Class-based inheritance introduces complexities because classes are objects that have metaclasses.

Prototypal inheritance is simpler because there isn't a distinction between concepts like classes vs. objects. With a prototypal system, nested contexts form chains of connected functions, where type identity is traded for extensible, inheritable behavior.

The lunch hour had a panel discussion on NoSQL was well moderated by Ken Sipe, but the discussion left me wanting more. This was followed by a "dream team" panel discussion that included Douglas Crockford, Alex Payne, Guy Steele, Josh Bloch, Bruce Tate and was expertly moderated by Ted Neward.

IMG_0029

This was an often spirited discussion that ranged from topics like what languages new aspiring developers should learn, to whether programming languages will ever form to help make parallel problems more easy to address and understand.

Perl got a lot of hate in the languages panel. Bad show, panelists!

Next talk: Android Squared (Bob Lee & Eric Burke)

IMG_0030

Eric explained how the Square reader decodes the wave form from the magnetic stripe on a credit card. They have to deal with peculiarities from different mobile devices interfering with the wave form from swiping a card as well as variations like swipe speed and other factors.

He also talked about how having a large database of swipe samples (containing phony numbers) allows them to write tests to examine holes in their decoding algorithms.

Square has released an open source library for Android that contains some Android and Java extensions (I believe): http://github.com/square/retrofit

Bob went into detail about how square queues metrics and server communication data on the device until it connects with the server. He also explained the API he wrote for reading and writing efficiently into flash file sectors on Android.

The queue file API and a shake API are included in retrofit. Bob later described a REST API that the android client uses to make network data exchanges.

Bob also shoed a POS app he wrote for Taste St. Louis in 2 hours that used the POS square API available for Android 3rd party apps. Very impressive!

Next talk: Dimensional Data in a distributed hash table (Mike Malone)

IMG_0031

He spent the beginning of his talk describing CAP theorem and how at his company, their needs were better served by availability instead of consistency. They have implemented a distributed hash table implemented on top of Cassandra. The major points of his talk were: Integrity vs. Availability, Locality vs. Distributability, and Reductionism vs. Emergence.

Sadly, this talk was totally over my head.

Next talk: Outside-in TDD in Clojure (Brian Marick)

IMG_0032

Brian contrasted Detroit-style TDD vs. London-style TDD (bottom-up vs top-down approach to designing systems guided by tests). He then played a pre-recorded coding example that showed the progressive implementation of an animal reservation system he previously created in Ruby.

Along the way, we got to see the mocking framework he is working on: Midje. In the coding example, we saw test definition, test execution result, and the code under test all within the same editor pane. This was interesting because it means that the eye doesn't have to move around the length and width of the monitor.

He explained why working with his mocking framework lets the course of development slice the problem domain into layers that can be tested totally independently.

Final Keynote: Douglas Crockford brought down the house

IMG_0035

Epilogue

Strangeloop was an example of a brilliantly thought-out and executed conference. There was an excellent mix of well-known experts and new comers offering highly technical insight for a price within most developers reach. I'd say this was a conference that developers could ill-afford to miss and I can't wait to see what Alex Miller follows-up with next year.

Friday, October 15, 2010

Strangeloop day 1 (part 2)

After a great lunch with Jeff Barsciezski, Luigi Montanez, and Yehuda Katz, I listened to a standing room only talk on civic hacking which covered many examples of companies that build up around serving public (government collected) data.

IMG_0020

Next talk: mobile HTML 5 (Michael Galpin)

IMG_0022

Mobile browsing is being done on many different platforms (iOS, Android, Blackberry).

Frameworks like PhoneGap & Titanium are powerful ways to create apps for mobile platforms, but aren't what HTML5 is about.

Viewport, Geolocation, DOM storage (local storage vs session storage) became the replacement for the original proposal for database storage on the device. Web workers, and many other aspects of HTML5 were covered.

Next talk: nodeJS (Ryan Dahl)

At the start of this, it seemed to be the same talk Ryan gave at jsconf. Then he went into live coding examples, demonstrating dns resolution and streaming command-line apps.

IMG_0023

Eventually, he started talking about scaling node deployment strategies, which included having node running in multiple processes communicating with each other via unix file handles (letting the kernel handle load balancing rather than using an explicit load balancing component). He also talked about clients using webworkers acting as actors for interacting with asynchronous node servers.

During Q&A, a question was asked about how node compared to other async servers (erlang). According to Ryan, they are comparable, but he didn't have numbers he could show.

Keynote: Guy Steele

(programming while the earth was still cooling, everyone knew math and was apparently insane)

IMG_0024

He gave a long and detailed analysis of the worst code he ever wrote (card programming from 40 years ago). This had lots of humor and maddening complexity. But he transitioned well into Fortress, the research language he is designing for parallel execution problems. Heady stuff. I needed beer afterwards.

Thursday, October 14, 2010

Strangeloop talks day 1

IMG_0017

Hilary Mason starts the day with a talk about machine learning and how the technology has evolved. Among the advances that have made machine learning accelerate:

  • Algorithms
  • On-demand (elastic) computing
  • Access to large amounts of data

Analyzing large amounts of data to find either patterns or to identify data trends requires algorithms to disambiguate data that is contextually unrelated.

Data classification through statistical modeling based on characteristics.

IMG_0018

And then she went into math and Bayesian probability.

Bitly trick:
http://bit.ly/3ert+ <-- add a plus to the end of a link to see realtime metrics about a link (statistics about clicks and where they are coming from over time).

Next talk: Riak (Rusty Klophaus @rklophaus) Dynamo-inspired NoSQL key-value datastore

Nosql is being driven by narcissism, voyeurism, and materialism :)

  • Has same interface for single and multiple node deployment
  • Configurable replication for buckets
  • Data relationships can be defined for querying
  • Replicates data across nodes as they are added to a cluster
  • Supports map/reduce operations
  • Can have HTTP interface to introduce caching and streaming
  • Full-text search
  • Riak is slower in virtualized environments.
  • Multi-site replication is an enterprise feature

Upgrading instances doesn't support rolling upgrades, so non-multisite upgrades would mean bringing down the ring to change the software.

http://hg.basho.com

Next talk: supporting an open source community (Yahuda Katz)

IMG_0019

Rails optimizes for developer happiness. The python community optimizes for explicitness. Focusing on happiness as a primary goal would draw developer attention faster than another more easily measurable metric. Performance or other kinds of optimizations can be attacked later.

Nothing beats adoption. Making your project easy to adopt (friendly licenses, support community) makes a big difference.

Business is good for the ecosystem; projects that allow independent businesses (training, consulting) to be built up around them will create the ecosystem that supports the viability of a project and the community involved in it.

Human beings underestimate the network effect.

MIT is a great license to promote a "network effect" for a project.

PDI (please do investigate): ask the community to fix a problem they care about and then incorporate the change if it makes sense for the larger community.

Market early with good propaganda.

Many, many other points (couldn't keep up). Outstanding talk! (Best talk of the day, actually.)

Saturday, October 02, 2010

Watchr is teh awesome

Autotest spoiled me for immediate feedback during the development cycle. So as I was going through the Relevance functional koans for Clojure, I had a little Watchr script continually re-running the tests from the exercise at every file save. This is what that script looked like:

There's barely anything there. All it does is run the "run.sh" script that comes with the koans whenever a ".clj" file in anywhere under the "src/koans" directory is saved. It's just a simple little thing, but so very useful.

I later discovered a fork of those koans (from David Laing) that adds JavaScript lessons. So I adapted my watchr script to start the KoansRunner file in Safari, reload the test page, and scroll to the bottom on every save of the JavaScript files.

I can't say enough about the value of rapid feedback from automated tests during the learning/development cycle. The absence of context switching to manually rerun the tests is great WIN.

Clojure sequence comprehensions

I am learning Clojure and I like it. Following the ThinkRelevance functional koans has given me a really good interactive playground for learning this language. Reading through examples in a book cannot compare to actually having to write code in order to solve a problem and in the process learn syntax and the rules of a language. What a concept!

I came across something in the sequence comprehensions section that I thought was interesting.

The "for" macro can loop over one (or more) groups of things and produce the vector combinations above. I was reminded while reading this of Ruby's Array#product method, which does the same thing (return the product of 2 or more arrays).

Sunday, September 19, 2010

Thoughts from Code Retreat - St. Louis

Yesterday was the St. Louis Code Retreat and I wanted to capture my experiences and observations. I hadn't heard of Game of Life before reading about Corey Haines' code retreats last year. My field of study in college was life sciences so I missed out on things like Conway's game of life that mathematicians and CS majors are probably exposed to. In prep for the event, I gave Game of Life a try for myself. It was a great experience! I felt totally sucked into the elegance and simplicity of the problem. But enough about that.

On organizing it

IMG_0007 DSC_0008

We were fortunate to have great sponsors. Microsoft provided the venue, a large space with ample capacity for the 40 people who were signed-up for the event. Oasis Digital funded the breakfast (fantastic pastries, fruit, and coffees) and Object Computing, Inc. (my employer) paid for the sumptuous buffet lunch from Mayuri.

The event was announced back in July and within a week of the free tickets becoming available, all were taken by eager developers from various technical backgrounds. However, of the 40 who signed up to attend, only 26 made it to the event. I had read accounts of previously held code retreats that warned to expect people signing up for the event but canceling at the last minute; given how hard it is to coordinate with a large group of people, this is not surprising. But to have only 65% attendance was, honestly, a disappointment. Given the size of the turn out, though, I was very happy with the range of technical interests among the folks that were there to learn, experiment, and enjoy programming.

Languages, Tools & Format

At the beginning of the day, I said a few words about how the day would be organized. We were to have 3 40-minute pair-programming sessions before lunch, with developers implementing the Game of Life problem in their preferred language or technology, and doing it test-first. Then switching pairs at the end of each session, deleting the last sessions effort and starting over.

DSC_0004

The point of the event was practice. Through exploring new languages and experimenting with different approaches to a common problem, all those who made it that day would get a chance to improve on some skill they already had or work with someone who could teach them something they were interested in learning. Attendees took on the game of life problem using a number of different languages and tools.

  • Eclipse
  • Emacs
  • IntelliJ IDEA
  • TextMate
  • Visual Studio
  • C#
  • Clojure
  • F#
  • Java
  • JavaScript
  • Objective-C
  • Ruby
  • SQL

A common reaction to the 40 minute time limit was that it was far too short to get a working implementation of Game of Life. The time constraint led to some sessions that scrapped testing altogether in the interests of getting a working implementation as quickly as possible. For others, it meant only being able to implement a partial, test-backed solution. Personally, I appreciated peering into the lightning-like minds of some of St. Louis' most talented software professionals. I liked what I saw in the clojure implementations that I watched and paired on and found myself inspired to take clojure on as my next language of study.

Organizing this event was a learning experience for me. Several people asked whether there would be another one next year. I really hope so ;-) It wasn't a crazy level of effort to organize (nothing on the scale of a major conference). I am curious whether I'd set the date for the event too far in the future and whether that was why there were so many people that cancelled their tickets. Next year, if the stars align like they did this year for venue and food sponsors, St. Louis will see another Code Retreat.

Interesting implementations

I have found a number of Game of Life implementations on the web that I think are pretty cool. Here are just a few.

Sunday, July 18, 2010

module_function (where have you been all my life?)

I recently discovered a feature of Ruby that surprised me. Really, I was surprised that I hadn't heard of it before (for as long as I have been a fan of the language).

module_function can be used to make one or more Module methods accessible as type-scoped methods (in the same way that declaring them as self methods would). For example:

In this form, the methods of the module must be declared before the line containing module_function. You can pass one or more method names (as symbols) in the call. In fact, you can even re-write this as follows:

This form makes all methods declared after module_function behave as type-scoped functions (callable in the form of: Foo.bar or Foo::bar). You can "turn-off" the behavior of what is given type-scoped calling access by declaring a visibility modifier after the last method you want to expose in this way.

Now the Foo functions can be called either as type-scoped functions or Foo can be included in a class or added to an object.

One thing you now can't do, though, is refer to the module_function scoped methods as instance methods of classes or objects into which the Foo module is included. IOW, trying to call: Something.new.foo in the above sample code blows up with a warning about trying to access a 'private' scoped variable.

Saturday, May 15, 2010

Regex riff (for words not containing a string)

I had the need to figure out how to parse a string and pull out any words that didn't contain "Foo" in them. After a lot of cursing, I came up with something that works. For the string "Which BarFoo Is It Foo Bar":

Yields: "Which", "Is", "It", "Bar"

Regular expressions are diabolical.

Sunday, December 27, 2009

My dot-Autotest

Among the things that make me ga-ga for Ruby testing libraries is the ZenTest gem, which includes a super handy utility called 'autotest'. Autotest is meant to be run from the top of your project directory and it will search through your /test directory and run all test files it finds there (and report passes/failures on the console). My own development preference is writing specifications for my software using RSpec, which includes a tiny utility script called 'autospec' that enables 'autotest' to run anything it finds under the /spec directory of your project environment. As well, setting an environment variable called AUTOFEATURE=true tells autotest to search through your /features directory and run all your Cucumber features after file-system changes (this capability is added by Cucumber and not actually part of the ZenTest gem).

I have been running autospec nonstop as I tinker with a Sinatra app I have been writing. The normal behavior for autospec is that it runs all specs & features and then stops, watching the filesystem for any file changes that trigger it to run specs again. Recently, though, I noticed that the specs would start running and then go into an infinite loop of running and running and running... At first I thought that I'd updated a gem in the vendor directory of my Sinatra app that broke autospec somehow. After doing a lot of tinkering, I tracked it down to a Webrat log file that gets updated each time my Cucumber specs make it all the way through the login feature of my web app.

Autotest includes a configuration capability that lets you specify which file updates it should ignore (i.e. which files can be updated without triggering an execution of all the specs for your project). These exceptions can be declared in a .autotest file that needs to reside in the home directory of your development environment. I think I have covered all the bases for things that I want to keep from triggering my autospec runs. Here is what my file looks like:

The 'autotest/growl' require is so that I can see growl popups when my specs pass or fail. The gem for this is 'autotest-growl'.

UPDATE - 12/28/09: The 'autotest' script supports a '-v' flag which will cause it to report what file it saw changed to trigger your last test run. I only learned about this flag thanks to a comment on this original post by the great Ryan Davis.

Sunday, November 08, 2009

Calculator Kata revisited

Just as a follow-on, I went back to the Calculator Kata and applied a functional Ruby approach with the rule of no mutable state allowed. I was inspired by Tom Stuart's Thinking Functionally in Ruby talk.

This time I create a reusable Proc for scanning the expression according to the regex that extracts [left_operand, operator, right_operand] arrays. I evaluate the expression with reduce, using the evaluation of the first equation in the expression as the initial value, and then applying that as the left hand side of all other equations in the expression. The drop(1) call removes the first element of the parsed expression so that the reduce call can operate on the second and all subsequent equations in the expression. Since the initial value passed to reduce is the evaluation of the first equation, the memo passed to all evaluations in the reduce block is the last evaluated result.

The above code passes the same spec as I included in the previous post

Monday, October 26, 2009

Strange Passions Confusion

A funny thing happened to me on Friday. I was scheduled to present at one of the Strange Passions events for the first Strange Loop conference. Earlier in the morning, I practiced a code kata I was planning on showing when it was my turn to present. The kata was an exercise I use when I do tech interviews of prospective candidates for developer positions at the consulting firm where I work. It calls for building a calculator that can parse a string expression and return the result of the expression as a string. This is an exercise that I have used for years, one that I have done many times in Java as well as in Ruby. The problem is ideal for observing test-first habits in programmers because it is a very easy problem for which to write tests.

When the time came for me to present, I gave a few minutes of introduction to the exercise and dove in. The first test took less than a minute to write, and I switched over to writing just enough to pass the first test. And then I froze. My mind went completely blank. This is an exercise that can be solved many different ways, and at that moment, in front of a decent crowd, I couldn't think of a single one. It was a totally unnerving experience. So I sat there for a minute or two, struggling to remember how I had solved this before. The audience grew impatient. I can only imagine that it was like watching a train wreck. Then, after what felt like an eternity, something unclogged in my brain and I started up again.

The next day, I thought a lot about it. I remembered that something similar happened to me on the night of my wedding. My wife and I took Tango lessons for 4 months prior to our wedding because we wanted our first dance to be a Tango. We had a routine that the dance instructor helped us work out and we practiced and practiced. On the night of the reception, the music started and I began the routine. Then, mid-way through, everything went blank. It was a two-part routine, and the lights went out in my head at the end of the first part. I panicked and led my wife through the first part of the moves we had practiced.

These lapses in memory to execute something that is almost second nature while in front of a crowd is generally thought of as stage fright. It may very well be that I have sporadic bouts of this phobia, and what happened Friday at Strange Loop was just another occurrence. I teach classes and had presented the day before at the conference, so it is not unusual for me to be presenting something in front of an audience. It was, however, disappointing to leave the crowd twiddling their thumbs while the wheels in my head spun for traction and I am unsure what to do to prevent this same episode from happening again.

I have written several variations of the calculator kata, that I present here to anyone interested in picking this up as an exercise for their own practice. The exercise is as follows: create a simple calculator that accepts a String arithmetic expression and returns the result of the expression, also as a String.

The Spec


Solution 1

This is the ugliest of the bunch. Split the expression at each space character, then add the parts of the expression into an array until there are 3 elements in the array, at which time I figure out which operator should be applied to the left and right sides of the expression, and then calculate and store the result as the left side of the expression to be evaluated next. On line 7, I am also adding a convenience method to the array to reduce some code duplication. This solution is readable but wordy.

Solution 2

This next approach greatly simplifies the strategy for calculating a binary expression. I still split on spaces and add each part of the expression string to an array, but instead of figuring out the operator for the expression, I take advantage of the operators existing as methods on the Fixnum class. This solution turns the left and right operands into integers, passing the right operand and the operator to the 'send' method of the left operand integer, and storing the result of the evaluation back in the parts array.

Solution 3

This one is a variation on Solution 2. Instead of splitting on spaces, I use a regular expression and capture groups to extract out the operands and operators for each part of the expression contained in the string. This solution still takes advantage of arithmetic operations existing as methods on the Fixnum class, so the difference from Solution 2 is primarily in the way that the parts of the expression are extracted.

Solution 4 -- Updated - 10/27/09

This final solution is defers to the Ruby interpreter to solve components of the equation. This approach can't simply rely on the Ruby interpreter to evaluate the entire expression because the arithmetic operators have different precedence order in Ruby. I use capture groups and positive lookahead (?=(\d+)) to get the three parts of the binary expression, thereby ensuring left-to-right expression evaluation (which is how I wanted the Calculator to work).

Special thanks to Michael Easter for pointing out the flaw in the original version of solution 4, which actually did just hand the expression over to the interpreter. I hadn't included a test that combined all four operators, which exposes the order precedence issue in Ruby. That has been remedied in the spec above.

Saturday, August 22, 2009

Handy RubyMine feature - Open Current File in Browser

I just discovered a little feature in RubyMine that I think is very cool and useful. Editing a view file causes a little overlay to appear in the corner of the editor pane showing icons for Firefox, Safari, and Opera. Clicking any of these will open the currently edited file in the browser of your choosing (assuming you are working in development mode and have a server running).
Neat!

Sunday, July 26, 2009

My Code Review Criteria

As a Scrum Master, I do code reviews. Recently, someone on my team asked whether what I look for in a code review was documented anywhere. This post is my starting point for documenting what I look for. I am hopeful that someone reading this may point out things that I haven't thought of that would be good to add to the list.

Backed by automated test
This should be self explanatory. No conditional logic or otherwise observable behavior should be added to the system without an automated test that confirms the predicable flow of the code.

Reinvents the Wheel
Does the code recreate some function that exists in a library included in the code base (or perhaps something from a utility library)? The chances of this are higher if you are reviewing code written by a developer new to the team. Does the code recreate a micro-framework or design pattern for which supporting types already exist and can be reused?

Doppelganger
Does the code contain logic duplication from elsewhere in the source file or from other files in the code base? Are there refactoring opportunities to extract code under review into a block reusable within the source file?

Maintains Harmony
Does the code under review look like it was written by the same hands as the rest of the code in the source file? In my mind, all source should read as if it was written by a single diligent developer, no matter the size of the team responsible for the system. That said, a projects' code style is an issue for teams to agree on internally and be ever vigilant for its application.

Says what it is / Says what it does
Are variables, constants, methods, and types descriptively named? Are any names inappropriately abbreviated or otherwise confusing?

Tell, don't ask
Classes and other types should accept their dependencies (through injection) rather than calling out for them (either via instantiation or other means). Accepting dependencies simplifies the ability to test code as well as change implementations of the types supplied at runtime. Does the code provide some means for external dependencies to be handed to the object? Are those external dependencies specified as interfaces or other non-concrete type declarations?

Too many notes
Are there any obvious opportunities for refactoring to simplify or reduce the size of the code under review? Does each method fit entirely within the view screen? The Single Responsibility Principle says that each type in a system should have one and only one reason to change. Are any methods, functions, or types written with multiple responsibilities?

Does it work?
Finally and most importantly, does running the system or related tests demonstrate that the code under review functions as expected?

Wednesday, February 18, 2009

Git tab completion from Cygwin

I have been a fan of Git since starting to use it regularly and am going to give a talk on it at a tech lunch for my company in April. For the last two weeks, I have been using Git as an SVN front-end (my company has a backed-up SVN repo that I am using for SCM) while developing for a Windows target platform application. So far the experience with Git from cygwin has been a bit mixed. Another developer I am working with ran into problems with Git from cygwin (as opposed to msysgit) that I was unable to reproduce. His problem prevented him from being able to do simple commits on staged files. Bummer.

The little tidbit I wanted to document here is related to getting tab-completion of git commands working from the Cygwin bash shell. There are plenty of posts that already document how to do this, but cygwin kept complaining about having extra tokens in the shell scripts I was sourcing from my .bash_profile. After a little bit of forensic googling, I saw a post explaining that Windows line feed characters inserted by the text editor I was using on my shell scripts was causing my problem and that I should run the scripts through the d2u utility. Problem solved!

So for Windows folks running git from cygwin, here's how you get the awesomeness of tab-completion for git:

  1. Download the source for the version of git you have installed from http://www.kernel.org/pub/software/scm/git/
  2. Copy the git-completion.bash file from the contrib/ directory and paste it into your home dir -- (I renamed my file .git-completion.bash).
  3. Run that file through dlu: $:> d2u .git-completion.bash
  4. Source the file from your .bash_profile (in your cygwin home directory):
    if [ -e "${HOME}/.git-completion.bash" ] ; then
    source "${HOME}"/.git-completion.bash
    fi
  5. Restart your cygwin shell and you should be have git tab completion working. I can't say enough about how helpful tab completion is for git (or how smart the shell script is - truly is teh awesome)

Saturday, January 10, 2009

Learning Ruby

I began learning the Ruby programming language by using a problem I had already solved one way and rewriting the solution in Ruby. Taking a domain that I had great experience in and fitting Ruby into it made the process of exploring the syntax and rules of the language a comfortable one. To use a sports metaphor, it gave me home field advantage.

I blogged about it. In fact, the blog entry was another Ruby learning opportunity for me. The pretty syntax highlighting for the Ruby source code I included in my blog was colored by a Ruby library (gem) called syntax. I found it helpful to create a Ruby script to take the source code I had written and generate syntax-highlighted HTML (yet another learning experience).

At some point early on, I got a great reference book and dove into it as needed. Other books followed, as well as adding *many* blogs to my blogroll. As I learned, my appreciation of the language grew and I spent time working on things that would help me write Ruby.

Over time, I wrote more Ruby code as well as more about Ruby and sought opportunities to learn Ruby by teaching it. I have also been fortunate to have a patient and knowledgeable mentor to ask questions to and learn from.

The learning stage changes eventually in to the doing stage. Much like a fusion chef, I discovered ways of mixing expertise I had in other areas with Ruby. An ingenious Ruby & Swing library (or is it a framework... you decide) called Monkeybars reignited my passion for rich-client user interfaces. I dug-in and started contributing to the project and later recorded a screencast demonstrating how to use it.

Fool that I am for the fun I have writing Ruby, I wrote a Rails website to host the screencast (as well as another I recorded for yet another Ruby/Swing library). All this is to say that learning something (like Ruby) can be a rewarding and enjoyable journey. Though I have travelled a fair distance, there are still so many new directions to go. As I write this, I stand at the beginning of a new trail. At my side I have the project I will re-write, a trusty reference book on the delivery truck and a patient mentor (who doesn't blog -- looking at you, Dave Giovannini) to hold my hand when I need it. And what do you know (I think I have seen this picture before...) there is even a fusion restaurant that makes stuff I have a feeling I will like.

<broad-grin/>

Saturday, December 27, 2008

Noche Buena 2008

Christmas Eve has always been the most special day of the year for me. Memories from my childhood include Noche Buena dinner parties full of family and friends dressed very nicely and a house permeated with the smells of a Cuban kitchen. Sometimes ham, sometimes pork, always black beans and rice, yuca, some vegetables, desserts, and lots of booze. A joyous occasion that usually ended with bodies laid out on the floor in front of the tree or by the fire, watching snowflakes fall and telling stories of adventures past.

Since becoming a father, it has been a priority for me to try my best to recreate the memorable experience for my kids that was my own warm memory of Christmas Eve.


Noche Buena 2008 from Mario Aquino on Vimeo.

Epilogue

We had prepared for a dinner party to seat 11 adults and 2 kids. The pig was so late in being ready to eat that the Noche Buena dinner was effectively ruined. All our guests had gone home with little more than hors d'oeuvres and some wine in their bellies. Despite all our efforts, there is no rushing a pig in a Caja China in December in St. Louis. At times I felt like Icarus... at times, like Captain Ahab. The regret was palpable and the expense of the day, substantial.

My opinion of the Caja China is that it is an extremely inefficient apparatus for roasting pigs. As you can see from the video, the heat source is above the meat, which lies in a metal-lined plywood box. This guarantees that the meat will be cooked slowly. However, the documentation for the Caja China says that a pig should take between 3 & 4 hours to cook, but our experience was that it took over 10 hours to cook the pig. Perhaps in Miami, where the temperature usually stays above 65 °F, the cook-time for a pig stays within the 3 - 4 hour window. Sadly, that was not our experience.

Tuesday, December 23, 2008

Habemus Porcus

Battling rotten weather this afternoon, we travelled out to Kenricks Meat Market to pick up our Noche Buena pig. My Dad brought the biggest cooler he had for taking the pig from the market back to my house. Once back home, the Yak Shaving commenced. We had to clean the pig, find a big enough plastic container to marinate it in, wash a bunch of things to mix the brine with the mojo we had prepared earlier, transfer the pig down to the kitchen, move a bunch of things around, keep the dog in the office, etc.

Two hours after getting it back to our house, the pig was finally juiced-up and bagged neatly for overnight marinading. It's out on our enclosed porch and the forecast calls for an overnight low of just above freezing. My Dad was concerned that wild creatures might break-in to our porch in the night and start to munch on our pig once the divine scent of the mojo gets carried into the backyard. I am not concerned.

Monday, December 22, 2008

Caja China Chicken Test

In preparation for the most important dinner of the year (the Noche Buena pig roast), I decided to test the cooking performance of the Caja China that we bought recently. I used self-starting coals to get the grill hot, though didn't use enough coals to cover the top of the box (mistake #1). After the coals were white-hot, I added Kingsford charcoals using roughly the same amount I had started with, and once again waited for them to be hot enough to spread and get more coverage of the top of the box.

By 5:15, I was ready to add the roaster chicken I had purchased for the test. This chicked was still quite cold for having sat in the trunk of my car in 15 °F weather for most of the day. The Caja China instructions advise adding meat that has been warmed to room temperature, but I decided to go for it anyway (mistake #2).

At the end of the first hour of cooking, we flipped the chicken. I could hear that the skin on the bottom of the bird (which had been facing the heat from above) was crispy as we flipped it over. I thought this was a good sign and that the chicken would soon be done and ready to eat. After flipping it, I recovered the tray of coals on top of the box and added a nominal amount of charcoals to the tray (mistake #3). The instructions say to add roughly 1/2 bag (8 lbs.) of charcoal after flipping the bird, but I didn't added that much.

Forty-five minutes later, I peaked into the box to see if I could read the meat thermometer we had added to the bird. The top was not as brown and crispy looking as I had expected it would. I realize now that I should have followed the charcoal amount recommendations to the letter. This will definitely happen when we cook on the afternoon of Noche Buena.

As you can see from the video, the chicken is a good shade of brown near the neck of the bird, but much less so near the bottom. The ambient temperature for the entire cooking episode was roughly 20 °F and the forecast for the day of Noche Buena calls for similar weather. I expect to post more details after we get the pig and start the prep. This is the first time I have ever roasted a whole pig and am really excited about it!