Archive for the 'Uncategorized' Category

Uncategorized

When private isn’t.

On Friday I was getting a crash course in the JBoss/Spring/Velocity combination that we’re experimenting with at work. We started with a trivial class, something like this:

public class Person {
  private String firstName = "Peter";
  private String lastName = "Penguin";
  public String getFirstName() {
    return firstName;
  }
  public String getLastName() {
    return lastName;
  }
}

The template did something like this:

<p>Name: $Person.getFirstName() $Person.lastName</p>

We used both the getFirstName() getter method and the lastName variable to demonstrate that it worked both ways. But I didn’t really understand how, since lastName is private. I vaguely remembered some way around this security restriction but couldn’t remember the details. Not that it mattered, since it was unlikely that the technique was being used in Velocity, or even that it would work in a web environment.

So what’s going on? I renamed getLastName() to getLname() and the template stopped working. Ah ha! Turns out that the template engine sees the lastName variable and makes a reasonable stab at the getter method’s name. That’s a handy technique to keep in mind.

But what about this security restriction workaround that I thought I’d seen? Was I out of my mind? Amazingly, no! In “Subverting Java Access Protection for Unit Testing” Ross Burton writes about something that I’ve been wondering for some time: how to do decent unit testing in Java without making all my variables and methods public or subverting my design just to make them available to test code in the same package.

The Java Reflection API allows the program to introspect arbitrary classes at runtime, accessing members at will. Most competent Java programmers should know this much, but what many don’t know is that the security layer preventing you from accessing private members is only optional, and can be turned off. This allows the system code to be written without explicitly planning the unit tests, and if the unit tests really do need to access a private or protected member, they can.

Excellent. This makes proper unit testing so much easier, as you aren’t restricted to “black box” testing of just public methods. Wonderful. Maybe reading the fine print in the API documentation is worthwhile, after all.

Uncategorized

Aaagh! I have free time!

Don’t worry, I don’t actually have anything of the sort. But I can relate.

Uncategorized

Quick Links

I really have to set up a linkblog.

Uncategorized

Perl Advent

The 2003 Perl Advent Calendar is here.

Uncategorized

Doctor Who webcasts.

I’ve finally got around to watching the animated Doctor Who episodes on BBCi. What terrific fun. The animation’s not great, but effects never were the best on the show, so in a way it’s fitting. And besides, the webcast episodes feel like Doctor Who, and that’s what matters. They’re good stories. They make for good audio-only presentation.

It’s been a long, long time since I’ve watched Doctor Who. Even longer since the heyday of my involvement in the local fan club, the now defunct Whoniversity of Minnesota. (Oh god.) Right around the time that Sylvester McCoy started playing the Doctor (or at least the time when those episodes first aired here in the US), I stopped watching TV and fell out of touch with the program.

Since I’ve got a long weekend and a project with hellish deadlines looming over me when I return to work on Monday, and since I’m none too thrilled with the idea of going to see a parade tomorrow, I’m enjoying the heck out of this time spent watching the new stories and exploring the BBC’s Doctor Who site. There’s some really good stuff there!

Uncategorized

Holidazzle Hell.

I have this horrible feeling that I’m going to be suckered into watching the Holidazzle Parade tomorrow. Owen’s thankfully not too interested in parades yet, but the visiting five-year-old nephew is. I’d accept that excuse were it not his in-town aunt who’s pushing hard to see the parade.

I don’t know what it is about the Holidazzle in particular that sets my teeth on edge. Maybe it has something to do with the fact that it interferes with my bus schedule for a month, making me run late more often than not. Maybe because a bunch of bright, happy lights and dancing & singing Disney characters are not welcome at a time of day when I want nothing to do with anything cheery. Or maybe it’s that watching it involves standing in the cold for an hour. Could just be that I’m not a huge fan of this holiday season in general, and my reaction is just general curmudgeonly behavior.

Yep, that about sums it up. Sigh.

Update: Of course, I’m not the scrooge I once was, and I really do enjoy watching the nephew react to stuff like parades, so I know it won’t be that bad. I just have such a visceral reaction to the Holidazzle that it’s easy to start off complaining about it. I’m such an ass.

Uncategorized

Happy Thanksgiving.

This is for you, Chris.

Owen's turkey hand

A little something that Owen worked on. Mom said you’d understand. Sorry you can’t be here today.

Uncategorized

Blog This.

They’ve probably been there awhile, but I just noticed the “Blog This” links on some O’Reilly Network articles. For instance, the recent (and enlightening!) Panther Maintenance article sports the new link, right alongside the print, discuss, and email links. They include some suggested text and HTML to add the text to a weblog, along with the trackback URL.

I was at first taken aback by the presence of suggested blog text, but then I realized that a certain department weblog that I know of would have benefitted from just that sort of thing, as the blog maintainers didn’t always come up with good summary text. Actually, good titles were usually the problem. No help there.

Are there “Blog this” links on other web sites? This is the first time I’ve seen them, but I’m not always the most observant of fellows. It demonstrates a certain cluefulness amongst the folks at O’Reilly, as it’s one easy way to promote links to their site.

Uncategorized

Dreamweaver MX 2004 FTP problem.

At work we tried to upgrade to Dreamweaver MX 2004, but had to stop the rollout because of problems with FTP. One of our servers has this weird issue where it does not return a filepath in response to a PWD command, which is supposed to return the current directory name. I think it’s something to do with permissions: access to the system’s getcwd is denied on certain slices. When users connect with older versions of Dreamweaver (even MX), the transaction goes something like this:

Server: Okay, you’re authenticated.
DW: PWD (what directory am I in?)
Server: 550 (Action not taken: file unavailable.)
DW: CWD /www/htdocs (Fine, then, just change to /www/htdocs/)

That is, Dreamweaver just barges right past the failing PWD, moving on to more important matters. Yes, I’d rather that the server respond correctly, but since things have worked fine I didn’t press the issue with the sysadmin. Hell, I don’t even want to be using FTP: I’d much rather use SecureFTP or scp, something where passwords aren’t passed in the clear (I care even though FTP access is restricted). But apparently that’s not an option.

Letting it slide was probably a mistake. Because Dreamweaver MX 2004 doesn’t make it past the failing PWD. After successful authentication, the transaction goes something like this:

DW: PWD (What directory am I in?)
Server: 550 (Action not taken: file unavailable.)
DW: PWD (Ahem. What directory am I in?)
Server: 550 (Action not taken: file unavailable.)
DW: QUIT (Fine, then, screw you too. Goodbye.)

Unless it gets a response to PWD, MX 2004 just disconnects. Thus making it useless for most of our users.

I’m of two minds on this. On the one hand, I shouldn’t fault MX 2004 too much: after all, the server ought to be responding properly. It’s just a system administration quirk that I’m sure can be resolved (says the guy who’s not a Solaris sysadmin). Besides, I’d rather not use FTP at all. On the other hand, this strikes me as a rather odd change in Dreamweaver’s behavior, and based on the discussion on Macromedia’s forums, it’s a problem for a lot of people.

So unless I can convince folks to stop using FTP, or Macromedia releases a fix, or (dare I dream?) the interminable search for a CMS produces something, the upgrade’s dead in the water. Oh well.

Uncategorized

Microsoft shares Office XML schemas

Microsoft is offering its XML schemas for Office 2003 under a royalty-free license. Good move, because it’s good news for developers.

« Prev - Next »