bitwix

Tangential comments about Software Development

Friday, January 27, 2012

Coincidence?

  • Google Predict through the API Explorer - tick.
  • Through Google's sample code - tick.
  • Cut down to my own DLL - failed.
I tried various things. It was when I chose to reference my own DLL from the Google sample that it said my project was targetting a different .Net framework. So I changed it to be .Net 3.5. I ran the test.

As it was passing, TweetDeck showed me Uncle Bob Martin's re-tweet : RT @jon_cham: Prolific developers don't always write a lot of code, instead they solve a lot of problems. The two things are not the same.

Thursday, December 29, 2011

Make it fast

I spent an afternoon on the Word Chain kata. The challenge is given two words of equal length (e.g. CODE and MESS) to find words that change one into the other, altering one letter at a time, so CODE MODE MODS MOSS MESS.

I got it to work, using the SCOWL dictionary. I improved my algorithm, by searching from both ends rather than just one. I split classes into smaller ones with limited responsibilities - a ChainSeeker, a Tentacle, a Route. It was better.

I then decided, uncharacteristically for me, to make it fast. So a list of used words was replaced by a hashmap. It was faster.

As I proceeded, the slowest part was finding the possible words to go next. Input CODE, output a list of MODE, NODE, COPE, CODA etc. Here's the final code I used:

public List<string> GetPossibleNextWords(string word)
{
    List<string> result = new List<string>();
    int wordhash = HashMap.MyHash(word);

    for (int i = 0; i < word.Length; i++)
    {
        string before = String.Empty, after = String.Empty;
        long hash0 = wordhash - HashMap.HashAt(word[i], i, word.Length);

        char skipc = word[i];
        for (char c = 'a'; c <= 'z'; c++)
        {
            if (c == skipc)
                continue;
            long hash = HashMap.HashAt(c, i, word.Length);
            if (KnownHash(hash + hash0))
            {
                if (before == String.Empty && after == String.Empty)
                {
                    before = i > 0 ? word.Substring(0, i) : String.Empty;
                    after = i + 1 < word.Length ? word.Substring(i + 1) : String.Empty;
                }
                result.Add(before + c + after);
            }
        }
    }
    return result;
}
It's faster, but it's worse. I'm taking advantage of understanding the hash algorithm to calculate the new hash from changing a letter. I'm keeping these strings before and after blank until I really need them, then holding them in memory on the off-chance that I need them again.

I daresay it could be made faster still. I'm sure that creating and passing List<string> objects is inefficient. But I think I've learned something, which is that I can keep making code faster, but at the expense of legibility.

Sunday, November 06, 2011

Judicious use of decoration

Jessica Hische has this great blog, Daily Drop Cap, with letters to use at the beginning of paragraphs. Just last month, I read Roads to Quoz by William Least Heat-Moon where he admits to a fondness for the letter Q. Johns, Jemimas, Jacks and Juliets around the world may share with me a preference for the tenth letter of our alphabet. Judge me not for having married another. Jump on the opportunity to admit your passion! Jettison timidity and celebrate the letter in whatever way you choose!

Sunday, October 30, 2011

Algol for Interviewing

Next time I'm interviewing a programmer for a job, I'd like to use this fragment of Algol. It comes from Electronic Computers by Hollingdale and Tootill (published 1965) which I stole from my brother-in-law's bookshelves.

begin comment Evaluate pi from Vieta's formula;
  real e, f, product; integer count;
  e := read tape;
  f := 0; product := 1; count := 0;
  for count := count + 1 while f < 2 - e do
    begin f:= sqrt( 2 + f );
      product := product x f/2
    end;
  newline; print (2/product); print (count)
end

Good algorithm, better maths. Sixteenth century Italy was an advanced place intellectually.

Monday, September 12, 2011

Je suis un bricoleur

... the 'bricoleur' is still someone who works with his hands and uses devious means compared to those of a craftsman. The 'bricoleur' is adept at performing a large number of diverse tasks; but, unlike the engineer, he does not subordinate each of them to the availability of raw materials and tools conceived and procured for the purpose of the  project. His universe of instruments is closed and the rules of his game are always to make do with 'whatever is at hand' ... the engineer is always trying to make his way out of and go beyond the constraints imposed by a particular state of civilization while the 'bricoleur' by inclination or necessity always remains within them.
Claude Lévi-Strauss, The Savage Mind, pp 16-19, quoted in Adhocism

The distinction is between appropriateness and urgency. The scientist is intent on using the tools and hypothesis appropriate to his job, whereas the bricoleur or adhocist is intent on undertaking his job immediately, with whatever resources are available.
Charles Jencks, Adhocism, p 17

I am a bricoleur. That explains my divergence from some colleagues who want me to embrace a new language, and from greater agile minds who want me to use mock objects. I can make do with what I've got. Note, however, that Jencks insists that the bricoleur and scientist are equally objective and deal equally rigorously with the facts. The distinction is not one of kind or quality.

Wednesday, August 17, 2011

SquareOnBoard Wordle



Wordle of code. This is heavily commented for Intellisense, causing the popularity of see, summary and returns. The class itself, SquareOnBoard, is more common than other classes such as MGCell or ExportParameter so not too bad on the feature envy front. I see there are both string.Empty and String.Empty, and we're using null rather than a Null object.



Here's a second class. In this case I got Wordle to include common words, so if appears. I also used the alphabetic sort option. This one has no Intellisense comments. The effect of these changes is to see that I use r and c variables, and increment both with ++. The class itself, Surface, is hardly mentioned while the work it does is clearly on squares of various sorts. m is actually the m_ prefix on a member variable.

What fun www.wordle.net is!






Monday, August 15, 2011

Agile 2011 Sessions, Notes and Links

MONDAY

Fluency over Proficiency: Accelerating Agile Learning and “Hunting Language”, Willem Larsen
Also known as who I crashed and burned at learning American Sign Language

The Transformation Priority Premise, Robert C. Martin
Bowling score game : designed 400 lines, test driven 14 lines

TUESDAY

Fluency over Proficiency again, as an Open Jam session. I moved on a little bit.

Powerful Questions, Carlton Nettleton

Adaptive Leadership: Accelerating Organizational Agility, Jim Highsmith

Lightning Talks including Michael Feathers on limits of agile

WEDNESDAY

Creating an Environment by Making, Keeping, and Amending Agreements, Amr Elssamadisy

Continuous Integration, Jez Humble

Agile Game Incubator, Michael McCulloch and Don McGreal
Zhong Zhi, a one-handed agile game invented and refined

Making Hard Choices about Technical Debt, Nanette Brown, Robert Nord
Board game fun, and yay I beat Elisabeth Hendrickson
See Ward Cunningham's OOPSLA 92 presentation

Lightning Talks including www.prezi.com

THURSDAY

Creating Customer Delight, Stephen Denning
Net Promoter Score = Reichheld’s single question to customers. How likely are you to recommend us? 0 No – 10 Definitely. Count 9s +10s less 0-6s. Positive territory is good.

Experimentation: a Missing Agile Practice, Arlo Belshee

The Kata In The Hat, Emmanuel Gaillot & Jonathan Perret

Slackers and Debtors: Meet Commitments, Reduce Debt, and Improve Performance, James Shore

FRIDAY

Code, Kevlin Henney
The Agile Mindset, Linda Rising

QUOTATIONS ETC

WILL TEACH CLOJURE FOR FOOD
I think middle management gets a bad rap [applause] Jim Highsmith
Without exception, all of my biggest mistakes occurred because I moved too slowly. John Chambers, CISCO CEO, quoted by Jim Highsmith
“It’s not an act, is it Bob?” friend of Robert Martin, on finding him playing with his laser pointer in a mirrored bathroom
As TDD developers, after doing a design, the first thing we do is ignore it RCMartin

“What’s the chance of changing my wife?”
“I divorced mine”
“You gave up on changing your wife”
“No, she gave up on me”

SUGAR HOUSE

Wildflowers Bed and Breakfast
Sugar House Coffee
Omar's Rawtopia
Wasatch Jazz Project