Welcome aboard, Tim!

2 AM July 25, 2006

Looks like Tim Bray is jumping on board the dynamic language train:

For people like me, who are proficient in Perl and Java, Ruby is remarkably, perhaps irresistibly, attractive. Over the last week I’ve got an unreasonable amount of work done in a ridiculously short period of time, with lots of interruptions, in a language I previously didn’t know. It’s intuitive enough that I’ve often found myself guessing at a syntax or a method or a usage and getting it right first time.

Welcome aboard, Tim! As for myself, I’m besotted with Python – for almost all the same reasons Tim loves Ruby. Perhaps that’s because I never had the pleasure of learning Perl first.

By alang | # | Comments (3)
(Posted to Software Development and javablogs)

Sun Speaks Marketese

7 AM July 24, 2006

Sun have always struggled with marketing to both techies and managers. A major trap here, is when marketing to one group, looking utterly stupid to the other.

If you are a developer, try this: go to http://www.sun.com/servers/x64/x4500/, click on “Virtual Tour”, then on the popup window, choose “Experience It” and watch the “Executive Overview”. (Or just click this Direct link.) It begins with business-oriented pseudo-technobabble voiceover, but that’s forgiveable on account of the pictures of totally cool hardware.

However, a few seconds in, it goes wrong. Up pops the talking head of a John Fowler, Executive Vice President, who intones:

These systems are ideal for customers who use IT strategically, who align IT infrastructure with business strategy.

Are Sun’s CIO customers really so insecure as to fall for this piffle? Or do Sun marketing just wish they were? Even John Fowler, talking head, doesn’t sound convinced.

This video makes Sun look truly, deeply clueless.

Here’s my unsolicited advice for the next Sun “Executive Overview”:

  1. Get someone who sounds enthusiastic.
  2. Get that someone to write their own script, in their own words.
  3. Make sure the script doesn’t sound like a press release.
  4. Go down to your local primary school, find the debating team, and get them to put your marketing arguments together.
By alang | # | Comments (1)
(Posted to Software Development and javablogs)

Initialising application data in Django

9 PM July 12, 2006

I found an alternate way to initialise Django application data. The usual method is to create specially named SQL data files (as described in the documentation) which are executed as syncdb creates your model tables. SQL is generally adequate, but sometimes, more complex initialisation is best be in code.

To run your own code each time syncdb is executed, Put the following code into a file named management.py, in your application directory (the same directory as models.py).

from django.dispatch import dispatcher
from django.db.models import signals
from myproj.myapp import models 

def init_data():
    # Your initialisation code here

dispatcher.connect(init_data, sender=models, signal=signals.post_syncdb)

Here’s how it works. When you run syncdb, Django first imports each application’s management.py. The last line of code in this module (dispatch.connect…), tells the Django dispatcher to listen out for the ”post_syncdb” signal, and to call the init_data function when it hears it. Later, when syncdb completes, it fires the post_syncdb signal, which cases the dispatcher to call your init_data function.

The net effect is, each time you do a syncdb, @init_data is called.

By alang | # | Comments (4)
(Posted to Software Development and Python)

How not to name a product

11 AM July 10, 2006

If I were building a system for capturing training records, I wouldn’t call it, “Train Rec”, would I?

By alang | # | Comments (2)
(Posted to Rants, Software Development and javablogs)

java.util.Properties and Generics

12 AM July 10, 2006

I can’t wait for Java 6.0. It looks like community involvement is a success.

For instance, just now, I was working in JDK1.5, where I had a properties file and needed to see the kes. I wrote:

  for (String key : props.keySet()) { 

Which seems sensible enough, except that the compiler rejects it with, “Type mismatch: cannot convert from element type Object to String”. A little bit of digging found the JDK1.5 Properties class declaration:

   class Properties extends Hashtable<Object,Object> {

Given that the Javadoc says, “Each key and its corresponding value in the property list is a string”, I can’t see why Properties doesn’t extend Hashtable<String, String>. Looks like laziness to me, but if someone has an alternate explanation, I’d appreciate hearing it.

On the bright side, it seems that I’m not the first person to encounter the issue, and, according to this bug report, Java 6.0 will have a way to do what I want without casting. Hoorah!

Update: This is the pre-Java 6.0 workaround:

  for (String key : (Set<String>) (Set) props.keySet()) {

Oh, and don’t forget to add @SuppressWarnings(“unchecked”) to the method declaration.

By alang | # | Comments (2)
(Posted to javablogs, Java and Rants)

Just One More Level of Indirection

9 PM July 9, 2006

Any problem in computer science can be solved with another layer of indirection. But that usually will create another problem.—David Wheeler

My program had Tools. But there was no way for users to create a tool, so I made a list of ToolDefinitions. Now my client wants to read the definitions from disk, which will have to be done by ToolDefinitionFactories, and deployment considerations require a central, definitive list of available factories, which led me to the

Extrapolating present trends, next week will see the unveiling of ToolDefinitionFactoryWranglerManagerManagerManagerManager.

By alang | # | Comments (2)
(Posted to javablogs, Software Development, Java and Rants)
© 2003-2006 Alan Green