Wide Awake Developers

Education as Mental Immune System

| Comments

Education and intelligence act like a memetic immune system. For instance, anyone with knowledge of chemistry understands that "binary liquid explosives" are a movie plot, not a security threat. On the other hand, lacking education, TSA officials told a woman in front of me to throw away her Dairy Queen ice cream cones before she could board the plane. Ice cream.

How in the hell is anyone supposed to blow up a plane with ice cream? It defies imagination.

She was firmly and seriously told, "Once it melts, it will be a liquid and all liquids and gels are banned from the aircraft."

I wanted to ask him what the TSA’s official position was on collodal solids. They aren’t gels or liquids, but amorphous liquids trapped in a suspension of solid crystals. Like a creamy mixture of dairy fats, egg yolks, and flavoring trapped in a suspension of water ice crystals.

I didn’t of course. I’ve heard the chilling warnings, "Jokes or inappropriate remarks to security officials will result in your detention and arrest." (Real announcement. I heard it in Houston.) In other words, mouth off about the idiocy of the system and you’ll be grooving to Brittney Spears in Gitmo.

On the other hand, there are other ideas that only make sense if you’re overly educated. Dennis Prager is fond of saying that you have to go to graduate school to believe things like, "The Republican party is more dangerous than Hizbollah."

Of course, I don’t think he’s really talking about post-docs in Chemical Engineering.

Expressiveness, Revisited

| Comments

I previously mused about the expressiveness of Ruby compared to Java. Dion Stewart pointed me toward F-Script, an interpreted, Smalltalk-like scripting language for Mac OS X and Cocoa. In F-Script, invoking a method on every object in an array is built-in syntax. Assuming that updates is an array containing objects that understand the preProcess and postProcess messages.

updates preProcess
updates postProcess

That’s it. Iterating over the elements of the collection is automatic.

F-Script admits much more sophisticated array processing; multilevel iteration, row-major processing, column-major processing, inner products, outer products, "compression" and "reduction" operations. The most amazing thing is how natural the idioms look, thanks to their clean syntax and the dynamic nature of the language.

It reminds me of a remark about General Relativity, that economy of expression allowed vast truths to be stated in one simple, compact equation. It would, however, require fourteen years of study to understand the notation used to write the equation, and that one could spend a lifetime understanding the implications.

Technorati Tags: java, beyondjava, ruby, fscript

Inviting Disaster

| Comments

I’m reading a fabulous book called "Inviting Disaster", by James R. Chiles. He discusses hundreds of engineering and mechanical disasters. Most of them caused serious loss of life.

There are several common themes:

1. Enormously complex systems that react in sometimes unpredictable ways

2. Inadequate testing, training, or preparedness for failures – particularly for multiple concurrent failures

3. A chain of events leading to the "system fracture". Usually exacerbated by human error

4. Politics or budget pressure causing otherwise responsible people to rush things out. This often involves whitewashing or pooh-poohing legitimate criticism and concern from experts involved.

The parallels to some projects I’ve worked on are kind of eerie. Particularly when he’s talking about things like the DC-10 and the Hubble Space Telescope. In both of those cases, warning signs were visible during the construction and early testing, but because each of the people involved had tunnel vision limited to that person’s silo, the clues got missed.

The scary part is that there is no solution here. Sometimes, you can’t even place the blame very squarely. When half-a-dozen people were involved with unloading and handling of oxygen-generating cylinders on a ValuJet flight, no single individual really did something wrong (or contrary to procedure, anyway). Still, the net effect of their actions cost the lives of every single person on that flight.

It’s grim stuff, but it ought to be required reading. If you ever leave your house again, you’ll be much better prepared for building and operating complex systems.

Technorati Tags: operations, systems

——–

New Interview Question

| Comments

So many frameworks… so much alphabet soup on the resumes.

Anyone that ever reads The Server Side or Monster.com knows exactly which boxes to hit when they’re writing a resume. The recruiters telegraph their needs a mile away. (Usually because they couldn’t care less about the differences or similarities between Struts, JSF, WebWork, etc.) As long as the candidate knows how to spell Spring and Hibernate, they’ll get submitted to the "preferred vendor" system.

Being one of those candidates is tough, but that’s not the part I’m concerned about now. I’m interested in weeding out the know-nothings, the poseurs, and the fast talkers.

When I’m interviewing somebody, my main criterion is this: would I want to work on a two-person project with this candidate? My secondary criterion is "Would I feel comfortable leaving this person along at a client site? Will they deliver value to the client? Will they look like an idiot, and by extension, make me look like an idiot?"

My friend Dion Stewart had a great idea for a weed-out question. No matter what frameworks the candidate shows on the resume, ask them what they disliked the most about the framework. (I have my top three list for each framework I’ve worked in… except NeXT’s Enterprise Objects Framework. But that’s another story.)

If they can’t answer at all, then they haven’t actually worked with the framework. They’re just playing buzzword bingo.

If they answer, but it sounds like bullshit, then odds are they’re bullshitting you.

If they have never thought about it, haven’t formed an opinion, or say "it’s all good", then they lack passion about what they do.

A candidate that is driven, that cares about the quality-without-a-name should be able to go on a rant about something in each framework they’ve actually worked with. In fact, you’ve really hit the jackpot if your candidate <i>can</i> go on a rant, but does it in a professional, reasoned way. I love to see a candidate that can show some fire without seeming like a loon. That’s when I can see how they’ll react when the client makes a decision the candidate considers boneheaded. (I’ve seen some spectacular pyrotechnics from consultants that forgot whose money they’re spending. But that’s another story.)

Technorati Tags: resume, jobs

JAI 1.1.3 in Beta

| Comments

I’ve been using JAI 1.1.2 for the past year. It’s an incredibly powerful tool, though I will confess that the API is more than a bit quirky.

Early this year, Sun made JAI an open-source project available at java.net. That project has been working on the 1.1.3 release for most of the year. It’s now in beta, with a few enhancements and a lot of bug fixes.

The most significant enhancement is that JAI can now be used with Java WebStart. Previously it had to be installed as a JRE extension.

Also, one of the big bugs is fixed. Issue #13 is fixed in the beta. It could cause the JPEG codec to use excessive amounts of memory when decoding large untiled images. (Which we do in our app a lot!)

Technorati Tags: java

Ruby Expressiveness and Repeating Yourself

| Comments

Just this week, I was reminded again of how Java forces you to repeat yourself. I had an object that contains a sequence of "things to be processed". The sequence has to be traversed twice, once before an extended process runs and once afterwards.

The usual Java idiom looks like this:

public void preProcess(ActionContext context) {
  for (Iterator iter = updates.iterator(); iter.hasNext(); ) {
    TwoPhaseUpdate update = (TwoPhaseUpdate) iter.next();
    update.preProcess(context);
  }
}

public void postProcess(ActionContext context) {
  for (Iterator iter = updates.iterator(); iter.hasNext(); ) {
    TwoPhaseUpdate update = (TwoPhaseUpdate) iter.next();
    update.preProcess(context);
  }
}

Notice that there are only two symbols different between these two methods, out of 20 semantically significant symbols. According to the Pragmatic Programmers, even iterating over the collection counts as a kind of repetition (and therefore a violation of DRY - don’t repeat yourself.)

The Ruby equivalent would be something like:

def preProcess(context)
   updates.each { |u| u.preProcess(context) }
end

def postProcess(context)
   updates.each { |u| u.postProcess(context) }
end

Now, there are two differening symbols out of 10 (20% variance instead of 10%). There’s been no loss of expressiveness, in fact, the main intention of the code is clearer in the Ruby version than in the Java version.

Can we make the variance higher? Perhaps.

def preProcess(context)
   each_update(:preProcess, context)
end

def postProcess(context)
   each_update(:postProcess, context)
end

def each_update(method, context)
   updates.each { |u| u.send(method, context) }
end 

Now the two primary methods have 2 symbols out of 7 different or nearly 28%. The expressiveness is damaged a little bit by the dynamic dispatch via "send". It would be unthinkable to use reflection in Java to make the code clearer. (Anyone who’s worked with reflection knows what I mean.) Here, it’s not unthinkable, but it might just not help clarity.

Technorati Tags: java, beyondjava, ruby


MySQL 5.0 Stored Procedures

| Comments

The MySQL 5.0 release is finally adding stored procedures, triggers, and views. This is a welcome addition. With the strong storage management features, clustering, and replication from the 4.x releases, MySQL now has all the capabilities of an "enterprise" database. (Of course, the lack of these features didn’t stop thousands of users from deploying earlier versions in enterprises, even for "mission-critical" applications.)*

Here’s a fairly trivial example:

create procedure count_table_rows ()  reads sql data begin
      select table_name, table_rows from information_schema.tables;
end

* Somtime, I have to post about the perversions of language perpetrated by people in business. "Mission-critical" means "without this, the mission will fail." What percentage of applications labelled as mission-critical would actually cause the company to fail? Most of the time, the "mission-critical" label really just means "this application’s sponsor has large political clout".

Technorati Tags: mysql

The Dumbest Thing I’ve Seen Today

| Comments

I generally like Swing, but I just found something in the Metal L&F for JSlider that strikes me as a big WTF. The BasicSliderUI allows you to click in the "track" of the slider to scroll by a block. That’s either 10% of the span of the slider, or a minimum of 1 unit. The MetalSliderUI overrides that sensible behavior with a method that scrolls by just one unit. Period.

Here’s a quick fix:

JSlider slider = new JSlider(); 
slider.setUI(new MetalSliderUI() {
  protected void scrollDueToClickInTrack(int dir) {
    scrollByBlock(dir);
  }
});

Technorati Tags: java, swing

Programmer Productivity Measurements Don’t Work.

| Comments

Programmer productivity measurements don’t work.

The most common metric was discredited decades ago, but continues to be used: KLOC. Only slightly better is function points. At least it’s tied to some deliverable value. Still, the best function point is the one you don’t have to develop. Likewise, the best line of code is the one you don’t need to write. In fact, sometimes my most productive days are the ones in which I delete the most code. Why are these metrics so misleading?

Because they are counting inventory as an asset. Lines of code are inventory. Function points are inventory. Any metric that only measures the rate of inventory production is fatally flawed. We need metrics that measure throughput instead.

Technorati Tags: lean, agile


More Beanshell Goodness

| Comments

Thanks to the clean layered architecture in our application, we’ve got a very clear interface between the user interface (just Swing widgets) and the "UI Model". In the canonical MVC mode, our UI Model is part controller and part model. It isn’t the domain model, however. It’s a model of the user interface. It has concepts like "form" and "command". A "form" is mainly a collection of property objects that are named and typed. The UI interacts with the rest of the application by binding to the properties.

The upshot is that anything the UI can do by setting and getting properties (including executing commands via CommandProperty objects) can be done through test fixtures or automated interfaces. Enter beanshell.

After integrating beanshell, all of our forms and properties were immediately available. Today, I worked with one of my teammates to build a beanshell script to drive through the application. It creates a customer and goes through the entire workflow. Run the script a million times or so, and you’ve got a great pile of test data. Schema changes? Domain model changes? No problem. Just re-run the script (and wait an hour or so) and you’ve got updated test data.

Technorati Tags: java