long overdue update

Posted on June 28th, 2009 in Uncategorized by sam

A few months ago I moved halfway across the country and started a new job with a new employer in the Baltimore area. It’s been a bit hectic. While I do have a couple of more focused blog posts in the pipeline, I wanted to get something up here before I let imnotpete.com slide any more.

So, major updates. Bought a Dell Mini 9 the very last day they had them. Very nice machine so far, though I have the same keyboard problems everyone else has: quote key is way down by the space bar, pipe and backslash are Fn-keys now, and I keep accidentally hitting the trackpad while I type, which then repositions my cursor. On the whole though, it’s not terrible - it is essentially my daily driver now, and I’m writing this post on it.

Finally got the companion software for my Sun SPOTs installed. Hopefully will have some time now to experiment with them and J2ME. Thanks for the gift, Bruce!

I managed to brick my wireless router during an upgrade of dd-wrt (my fault, not theirs). That was fun.

I just discovered dealextreme.com. Anyone have any horror stories about them, or are they trustworthy? I realize it’ll be cheap Chinese knockoffs (like the iFone and SCIphone), but at those prices it doesn’t have to be perfect.

I’m really looking forward to the 18-19 new Android phones Google mentioned. We plan to jump AT&T’s ship and go to Sprint when our contract is up this winter, so I’m very hopeful Sprint will get one.

I’m back in the old trap of reading 300 books at the same time again, so they take forever to finish. I’m very slowly working my way through Godel, Escher, Bach, as well as Animal Farm and Thoreau’s Walden. I’m also rereading Look to Windward, by Iain M. Banks, which is perversely going very quickly.

Oh! Good news! The Blogathon has been announced for this year (after a hiatus last year), so that’s great news. I will most likely be participating (probably benefiting Child’s Play again). More news forthcoming as we learn more.

I think that’ll do it for now. Look forward to more posts again now that I’m largely settled in.

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

followup: learning the singleton pattern

Posted on February 23rd, 2009 in Uncategorized by sam

Just over a year ago, I wrote about learning the singleton design pattern (and then implementing it in ActionScript). I was happy to have found I could use singletons in AS3, since I had several use cases in mind.

Since then, I’ve learned more about things like dependency injection and the Law of Demeter. I’ve learned more about test-driven development. And I’ve learned something else: Global state is almost universally a complicator when combined with these practices. The other thing I’ve learned: the singleton pattern IS global state.

Let’s walk through this. Suppose you are developing an application which is using an in-memory storage implementation (hey, it’s a young app). You write the storage using the singleton pattern - in any class that may need a reference to that, you just do

StorageImpl.getInstance().addPreferenceItem(new Preference("whatever"));

This works, and appears to work well.

Now, a month or two later, you have a requirement for database persistance in the app. You write another implementation, call it DatabaseStorageImpl. You change all of your code over to this:

DatabaseStorageImpl.getInstance().addPreferenceItem(new Preference("whatever"));

And everything still works. Except for the one or two places you missed when converting it over. Except for your unit tests, which now either don’t work, or require the presence of your database.

How do your tests know which implementation is being used in the code they test?

The solution to all of the above problems is dependency injection. I’m not going to go deeply into this now, but here is a great explanation of the pros and cons: Misko Hevery’s “Global State and Singletons” (Clean Code Talks)

Anyway, here’s the upshot: I’ll leave up my AS3 singleton implementation, but use it at your own risk. My policy at this point is to avoid singletons unless I have a very specific reason NOT to use dependency injection - and I have yet to come up with such a reason.

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

reading reboot

Posted on January 11th, 2009 in Uncategorized by sam

Ok, it was time for a change. I’ve been reading 5 books at once for a couple of months now, and since I haven’t gotten more than halfway through any of them, this seems like a bad idea.

So I’ve pared myself down to two books currently. One fiction, one nonfiction. I’m finally getting a chance to read World War Z, by Max Brooks, a book I’ve had recommended to me time and again over the last few months. One hundred pages in, it’s definitely worth the read. Need to pick up the precursor book, now…

For nonfiction, I’m going to work through the rest of Catholicism and Fundamentalism, by Karl Keating. This is to continue to bring me up to speed on my newly chosen church, and so I can have a better understanding of this faith I call my own.

I just wrapped up reading Snow Crash for the second time. Was just as good as I remembered it, and now I even understood a bit more. That’s always gratifying.

After this, I am at a loss as to what to read next. Our library (the apartment’s second bedroom) passed 1,000 books some months ago, most of them yet-to-be-read. It comes to the point of having too many choices - almost have to just run my fingers along a shelf and pick something with my eyes closed.

My wife is working through Douglas Hofstadter’s Godel, Escher, Bach (it usually resides on our “smarter than we’ll ever be” shelf), and from the discussions of AI and human intelligence that we’ve had so far, I can’t wait to get my hands on it. I’ll let her tell the story of that book, though.

I should probably pick up another technical book of some sort.

And to bring this rambling, pointless piece of drivel to a close, here’s a picture of a bunny with a pancake on its head.

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

HAPPY NEW YEAR

Posted on January 1st, 2009 in Uncategorized by sam

Happy 2009 world!

Also, I just posted to a group on Facebook, and apparently I’m awesome:

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

developer’s toolbox

Posted on November 21st, 2008 in Uncategorized by sam

Periodically, I like to take stock of my development environment and see what tools I’ve been using. Given that I have this blog sitting around, it seems like a good place to record the results

Coding:

Ok, so here’s the deal. For several months, I’ve been using Vim as my sole IDE for Java and Groovy coding - I have gotten hooked on the incredible ease of navigation and editting. For me, this made it more useful and quicker than a full IDE such as Eclipse or IntelliJ’s IDEA. Then, a couple of weeks ago, I found viPlugin, an Eclipse plugin that provides nearly all of Vim’s functionality. Also, it works great in Flex Builder (which is built off of Eclipse). So, I’ve switched back to a rich IDE with Vim keyboard-navigation features. I’ll still list my Vim-centric tools here if you want them, but I don’t use them full-time anymore.
Eclipse
viPlugin
Vim
Vim syntax files

Flex Builder (viPlugin works in this, as well, since it’s just an extension of Eclipse)
BASH (not to be confused with bash)
Maven

Groovy (Currently used mainly for rapid prototyping “does this work?” of java code)
Python (My principle calculator :-D)

Testing:

Web Developer Toolbar
JUnit
Groovy-modified JUnit
hudson
Browsershots
poster-extension

Reference:

JavaSE 6 API
Groovy API
Flex3 API
Chad Gallemore’s blog
James Lorenzen’s blog
CustomizeGoogle (never see experts-exchange in your google results again!)

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

nirvana: pair programming and test-driven development

Posted on November 16th, 2008 in development by sam

So, for the last week or so, I have finally managed to force myself into both pair programming and test-driven development (TDD). Oh my… how have I managed to be a developer for this long without those two things? “Pairing” in my office has often meant “we’ll work on similar stuff and check in with each other every half hour or so.” That isn’t pairing - that’s keeping your teammates informed. TDD in my office is usually “if I think of it, I’ll write a small test beforehand, then code the whole implementation up, then write more tests if I have time (never).” This is not TDD - this is lip service.

So, real pairing. Two developers watching one screen, both keeping an eye on the line-by-line coding as it happens, frequently swapping places (who drives and who watches). Although my coworker and I sit near each other physically, we used VNC for the actual screen watching - less invasion of personal space. This also made it an easy transition to our team’s telecommuting day - just add Skype into the mix and continue as we were. Our habit has been to commit to Subversion after each implementation class is done, and switch control at that time as well.

The con here is fairly obvious, and has been debated many times at my workplace. Pair programming simply takes longer to develop the same piece of functionality. Two developers working on a single task will not complete it in half the time. Unfortunately for pairing proponents, the benefits are less obvious to those you are trying to convince - the actual code produced has far fewer bugs due to receiving the close attention of two developers. The resulting design will be simpler, and two developers’ worth of knowledge and experience will be poured into the design and choice of libraries. There is also an automatic alleviation of the beer-truck factor - neither developer has a monopoly on knowledge of the implementation.

Tying in with this, at least temporally for me, is the concept of test-driven development, or TDD. In this past week, my pairing partner and I have defined TDD as “no implementation code is written unless there is a unit test to exercise it.” Our typical work flow was to write the interface for a class we needed and let Eclipse generate a skeleton class from the interface. Then, write a test for one of the methods in the interface, write just enough code to make the test pass, and repeat. This melds wonderfully with pair programming. It assures there are even fewer bugs in the final system, since you are largely assured of having extensive automated testing. Design is kept simple since code is only written to satisfy a test - reduction of code bloat.

Since this is (almost) my team’s first foray into pairing and TDD, we were generous in our estimates. When tasking out our stories (we’re a scrum shop), we took our one-person estimate for a task and doubled it. For this past week of work, my pairing partner and I have consistently beaten these estimates while not faltering on TDD - our end-of-sprint rush to integrate and fix bugs found during the manual test will hopefully be largely alleviated.

This is the coding-heaven that I have been striving for since I entered the software development “real world.” I’ve seen glimmers of it here and there, but now I see what the full version looks like, and I’m on cloud nine.

Further Reading:
A short case study of pairing, one of the references from the Wikipedia article [PDF]

[EDIT: It's been brought to my attention that I should explain the phrase "beer-truck factor." At least in my office, this is the risk that if only one person has deep knowledge of the system, the team could be in a bind if that person quits or is removed from participation in some other way - such as getting hit by a beer truck.]

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

finished problem B refactoring

Posted on July 20th, 2008 in Uncategorized by sam

Because I promised in my last post, and because I like to show off, here are the results of my refactoring code jam problem B. Old and new. Took it from 143 lines to just 69 - I’m definitely happy with that.

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

codejam, groovy, and refactoring

Posted on July 19th, 2008 in Uncategorized by sam

This past Wednesday I entered Google’s code jam 2008. For those that don’t know (as I didn’t before one of my coworkers brought it up), this is a yearly programming competition. You are given a small selection of problems to solve, and a set period of time (hours, not days) to solve it in. When you have your program done, you download their test input, run your code against it, and then upload your results and source code.

Wednesday marked the beginning of the 24-hour qualifying round. After this, the people who made it in (a few thousand contestants) continue to online round 1. After 3 online rounds, there are a few rounds onsite at Google offices.

Having succumbed to evangelism from some other people, I decided to go ahead and code my solutions in Groovy. This was (and is, since I passed the qualifiers. w00t!) a great opportunity to force myself to learn more Groovy. Closures, quick prototyping, static typing… all the things I’ve loved about Python, but with slightly more familiar syntax, the ability to natively use the millions of Java libraries, and, for work, no need to install any new VM/interpreter on target systems.

What with learning some Groovy idiosyncracies and overcoming my own mental roadblocks, it took me about 9 hours to do the first two problems in this round. With some decent lessons learned, I think I can pare my time down to around 2 hours for a problem, which falls within the expected times for the “real” rounds.

Now that I have some breathing room, I’m using these problems as exercises in refactoring; taking my first quick prototypes and making them readable and reasonable. So far, I’ve taken my solution for problem A (the search engines one) from 102 lines to 70, while improving readability. Here is the (working) code I turned in and here is what I have now that I’ve slept on and revisited the code. A couple of the things I change involved not using Groovy-specific bits of sugar just because they were there. For instance, my main() method became much simpler when I switched away from Groovy’s awesome File.eachLine() closure and just used a standard Java Iterator. This allowed me to handle the input in a more straightforward manner. If the input were similar data on each line, I think the closure would have been better, but Google has structured their files more complexly than that.

Now that a wonderful participant has actually gone through and collected stats for the languages used, I can learn from the other Groovy-ers (you can download anyone’s solution from the code jam’s score pages, after each round is complete). One thing I’ve already noticed is that the high-ranking Groovy user, nebolsin, uses several Groovy features I haven’t seen before, but also uses C++/Java-style for loops (for (int i=0; i<10; i++) {) instead of the simpler Groovy way (for (i in 0..<10) { or even 10.times() {).

I expect to post again when I’ve finished the refactor of my solution for problem B. Also doing other quick-coding exercises as practice. Training for a coding race… wow.

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

My Home Automation Dreams

Posted on June 1st, 2008 in Uncategorized by sam

Just some brainstorming I’ve been doing lately. So far, my wife and I have only rented, which somewhat limits what we can do with our home. Granted, we loved our old house and this apartment is great (feels like living at a resort :-)), but sometimes I need more control.

Anyway, something that’s been on my mind lately is home automation. I would love to geek up a house to do exactly what I want. Here’s what I’ve been thinking of. I’m assuming money is no object, and since I probably won’t be able to do this until several years from now, I expect most of the tech will be pretty cheap when I get started.

I want to be able to control most everything in my home from wherever I am. I’d also like this to be unobtrusive and simple. How about a laptop touch-screen display, framed and set up with a nice picture (Monet?) and hanging on the wall. Touch it appropriately, and it alt-tabs over to a control panel. This control panel hooks into a server hidden away somewhere and gives me house-wide control over most of the following features:

My music, anywhere. I want a decent set of speakers set up in all or most of the rooms of my house - kitchen, den/living room, and office, at least. Pop up the control panel on my Monet and set up a playlist from the mp3s stored on that server, and it automatically pipes to the speakers in the room I’m in. If I go to another room, either let me manually transfer the music to the new room, or track me via RFID, Bluetooth (BlueProximity anyone?), or something similar.

HVAC control. I’ll have room-by-room central air control, naturally set up with this client-server system. No need for an extra thermostat in each room taking up wall space.

Security control. If I have any security monitors set up, I want to be able to access them from any of my dumb terminals. Probably password this in some way.

Information mashups. What’s the weather forecast? I can pull up an online recipe in the kitchen, or a car repair tutorial in the garage (lame, I know).

Alerts. Is there a tornado warning here? Do I have new email (this could tie into the aforementioned RFID/Bluetooth tracking to only display in the room I’m in)? Is someone at the front door (whether they’ve rung the doorbell or not - motion detector!)?

Cat tracking. I’m done in the basement and about to kill the lights and close the door, but I can’t be sure Anastasia didn’t follow me down here. Luckily, my Monet control panel says the RFID tag in her collar is currently batting things off the top of my dresser in my bedroom. I’ll deal with that later, but I can close up the basement now.

Along with the hidden panels on my walls, I would of course have a desktop machine in the office hooked into the system, and an EeePC or similar ultraportable near my coffee table in the den/living room. If I want to find out who that actress is in the movie I’m watching, I don’t want to get up and walk to the wall to do it.

There are a few other things that don’t make sense for the control panel theme, but can hook into the system just fine.

RFID/Bluetooth door locks. I want a front door that can tell when I’ve walked up to it, and unlocks (and maybe opens) at the push of a hidden button outside. If I walk up with arms full of groceries, I don’t want to have to dig for keys to get in - I’ll just lean on the button and walk inside.

Wireless connection to the mp3 player in my car. If I have to go buy some spackling or a hammer or whatever else I need as a homeowner doing geeky repairs, I want that playlist I was listening to to automatically transfer over so I can keep jamming on the way to Home Depot.

So, we’ll have to see how all of this matches up with my near-Amish wife who wants an authentic Victorian house.

Anybody feel like donating me an X10 gift card?

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon

Mark Your Calendars

Posted on May 7th, 2008 in Uncategorized by sam

*salivates*

Um… ok. I didn’t have anything useful to say. :-(

  • Digg
  • del.icio.us
  • blogmarks
  • Fark
  • Reddit
  • Slashdot
  • Technorati
  • Propeller
  • StumbleUpon
Next Page »