Back to the trenches

Instead of management and code, I’ll just be writing code (at least for now). Today, I started a new job at a small consulting firm in Virginia with a software lab that wants to start putting out products.

Today consisted of the environment configuration and filling out of forms typical of a first day.  Most of the last half of the day was taken up by a boot camp.  I found it to be a very enlightening how-to on consulting, as well as an intro to the company’s culture.

Stockholm, Sweden

Yesterday, before our concert at Ekebyholmsskolan, we got to tour Stockholm.  We arrived there from Finland via a Viking Line ferry named Isabella.  Two other chaperones and I spent virtually the entire time touring the older parts of Stockholm, including a number of churches.  Of the cities we’ve visited so far on the concert tour, Stockholm is the most beautiful.  I really like the architecture.  Bicycles get their own lanes.  It’s a city that’s very easy to tour on foot.  The fact that it’s on the water is also a big plus in my book.

We’re getting on our tour bus in another 15 minutes for the drive to Oslo, Norway.

Scandinavia Tour

I’m writing this from a school dorm at Toivonlinna, a Seventh-day Adventist school in Finland.  I’m one of a number of chaperones for a high school choir giving concerts in Scandinavia.  We gave a concert at the school this morning (and I really do mean “we”, since the chaperones got drafted to sing also).  Our concert yesterday in Turku went well enough that the choir went back up to sing an encore.  Iceland was our first stop, and despite its name, it was warmer than Finland is now.  Even as I type, it is snowing.

The next stop on our tour is Sweden.  We’ll be taking an overnight ferry there from Finland (assuming the weather cooperates) after lunch, a cathedral tour, and some shopping.

A More Perfect Union

Barack Obama spoke at length yesterday on the issue of race in general and his former pastor in particular.  If you haven’t already seen and heard the speech, or read the transcript, I encourage you to do so.  There is no soundbite that can do justice to the importance and brilliance of his message.  If there was ever a politician who could legitimately argue that he’s a uniter and not a divider, it is Barack Obama.  I only hope it helps him win in Pennsylvania.

$1.67

That’s how much one (1) euro cost me yesterday when I was converting currency with Chevy Chase Bank for an upcoming trip. You know things are bad when even the branch manager is surprised by the rate of exchange. The exchange rate is probably even worse today. Even if I took out the fees they charged, the exchange rate is probably 20-30 cents worse than it was when I first went to Europe in 2005.

It reminded me of economics classes in business school, and what we learned about what countries do to defend their currency.  The Fed is doing the opposite of those things right now, so between that and deficits our government runs, I expect the dollar to be worth less and less in the near term.

Time to buy an iPhone?

I went to the barbershop on Friday.  During my haircut, I ask my barber how he likes the iPhone.  He doesn’t just like it, he loves it.  I got quite a sales pitch from him.  Then the guy getting his haircut next to me chimes in.  He just got an iPhone as well.  He actually said he’d been thinking about getting a laptop, but found the iPhone did what he needed.Of all the iPhone owners I’ve talked to since it came out (friends, fellow conference attendees, even a guy waiting for the bus in Seattle),  I have yet to hear any complaints.I haven’t caved in and bought one (yet), for a few reasons:

  • I’ve been kind of annoyed with AT&T Wireless lately over dropped calls
  • Don’t really like the idea of a $70/month cellphone bill
  • I’m kinda waiting for the next version of the iPhone (new hardware anyway)

Every day that goes by however, I find I dislike the Motorola Razr I’ve got just a bit more.  The gap between my current monthly cellphone bill and that $70/month is starting to get smaller too (probably too much text messaging).  I’m also not sure I want 3G badly enough to wait months and months for it.

Refactoring

Last night, I went to a presentation on refactoring by Jonathan Cogley.  My notes are below:

refactor – improve the design of existing code incrementally

Code must:

  • do the job
  • be maintainable/extensible
  • communicate its intent

Code that doesn’t accomplish all of the above is broken.

Refactorings

  • rename
  • extract method
  • inline method
  • introduce explaining variable
  • move method
  • inline temp

technical debt – anything that needs to be done to the code that gets put off until a later date

I found a much better definition for technical debt.  It makes a nice argument in favor of refactoring (though not as good as it would be with some way to quantify and measure it).

code smell – indication that something could be wrong with the code

Code Smells

  • duplicated code
  •  long methods
  • large classes
  • Too many private/protected methods
  • Empty catch clause (FxCop flags these by default)
  • Too many static methods
  • Variables with large scope
  • Poorly-named variables
  • Comments
  • Switch statements
  • Unnecessary complexity

Even though comments in code to tend to get out of date, I’m not sure I’d call them a code smell.  Wikipedia has another definition of code smell, along with a link to a taxonomy of code smells.

When to refactor:

  • before a change
  • after all current tests are green

Sometimes, refactoring is necessary to understand code.

reduce scope – bring variable closer to where it’s used

Be sure your unit tests don’t re implement what the tested code is doing.

Eliminate double assignments (a = b = 0) for clarity.

Each method should have only one operation/concept.

If you must use code comments, they should explain the “why”.  The code should be clear enough to explain the “what”.

Favor virtual instance methods where possible in your code.

Avoid using the debugger.  Write unit tests instead.

Performance improvements tend to make code harder to understand.  Don’t use refactoring to address application performance.

Recommended reading:

Refactoring to Patterns