the corner office

a blog, by Colin Pretorius

# Grouping classes

I was looking at some sample code today, and found a Java file with about 5 classes in the file - one public, and another 4 default-scoped classes. Although it's perfectly legal, my experience is that you hardly ever see this in production code. You'll see enough inner classes, member and static, often a healthy dose of anonymous inner classes (and almost never a local class), but bundling a number of classes into a Java file? It just doesn't happen.

I wonder why that is. I suspect it has a lot to do with how people work with IDEs. In the old days when crazy people coded Java in Notepad or vi, it might have made sense (and been more convenient) to have multiple classes in the same file (it's common enough in C++ code). With an IDE like Eclipse, and using something like the Package Explorer, files are the top level of abstraction within a package, and I think developers make an easy file = class equivalence.

Arguably, multiple classes in a file allows an extra level of organisation, logically grouping related classes. Whenever I want to do that, though, I favour inner classes. I can scope the classes more tightly, and associations are more explicit. The down side is you can lose some encapsulation. To be honest, I just never think about anything other than class-per-file with inner classes as needed. So is there a place for multiple classes in a file? Is this a useful but much-neglected feature in Java, or does it hurt readability for developers who don't expect to see it? Not sure...

File under: java : {2008.05.28 - 01:37} : Comments (0)

# Hardy Heron

After my previous Linux installation broke and I barely noticed because I was spending most of my time in Windows playing Eve, I got around to reinstalling Ubuntu on my laptop recently, and I'm now running Hardy Heron. I don't know why, but I just couldn't get my fonts looking good in Gnome again. I'm not a fan of Gnome, but since the two apps I spend most of my time in (Firefox and Eclipse) both only have Gtk bindings, I was never too compelled to try alternatives.

With the font problem, I decided to take the plunge and try Xubuntu. I've fiddled with Xfce once or twice before, never done much more than poke around. This time I think it's for keeps. I'm glad to say that my fonts are displaying as nicely as can be, and I'm much taken by the look and feel. Is it genuinely lighter on memory and CPU than Gnome? I'm not sure, and it doesn't matter that much. It looks good and it feels good (even handling Gtk apps quite gracefully), and I'm chuffed.

Now the job of getting everything set up again...

{2008.05.22 - 23:08} : Comments (0)

# Unseasonal

Jeez, if I wanted clear blue skies and hot summers I could have stayed in Joburg.

It's been insanely hot here the past 2 weeks. It's also a little more humid here than the Highveld. Not as bad as KZN, but muggy nonetheless.

What surprised me last week, was how people here get into summer so quickly. I left work last Friday, and the lawns outside the office buildings were packed with people out enjoying the sun. I don't think I ever remember South Africans out en masse on the lawns of office parks during summer. I guess because glorious (yaaay) weather is rarer here, people appreciate it more.

Now some extended rainy spells, please.

File under: personal : {2008.05.13 - 23:21} : Comments (0)

# SpringSource Application Platform

The name isn't catchy enough, but the SpringSource Application Platform is interesting. Essentially, it's OSGi meets Spring, a modular application server; a comment on the TSS thread says that it's trying to do for servers what Eclipse RCP has done for clients.

What does that mean right now? I don't see this replacing ye olde containers just yet, but it is another indication that OSGi is taking off. As I've said before, I'm somewhat ambivalent about OSGi. It's a powerful way to put together large and complex applications (like IDEs and application servers), but I'm not so sure if the effort is justified when building smaller applications where a few jars and config files will do. So the appeal of things like the SSAP (or whatever the hell it ends up being called) comes down to just how much of the additional drudgery is necessary for business-as-usual apps, and/or how much can be made to go away with good IDE tooling.

{2008.05.04 - 23:52} : Comments (0)

# CXF, log4j, silly mistakes

If you were using CXF, and wanted all the logging output to be handled by log4j, you'll probably have Googled for an answer and come across this excellent post which explains how to configure CXF to use log4j. And you might duly create the necessary file in src/main/webapp/META-INF or the like and then spent a lot of time debugging CXF's LogUtils class trying to figure out why it isn't picking up your config change.

Only then might you realise that the post in question is indeed correct, and explains exactly what you need to do: put the string org.apache.cxf.common.logging.Log4jLogger into a file named META-INF/cxf/org.apache.cxf.Logger in the classpath. In the classpath. And then you'll go doh! Muppet! A web app's META-INF directory isn't in the classpath, and your mind is making a connection which isn't there. You should be putting the file into src/main/resources directory, or whereever else in your classpath. Classpath dammit, classpath. And you might feel embarassed at having made this silly mistake, but you'd only be human. And I think Donald Norman would be on your side.

File under: techie : {2008.05.01 - 23:54} : Comments (3)

# Ken v Boris

So we got to vote today. In the UK. Not something I'd expected to be able to do, being a lowly immigrant and all, but there you go. Being a member of the Commonwealth is worth something, after all, at least at local government level.

How different elections are here. We arrived at the polling station with our polling letters. Thank you, says dude. Don't you need our ID, says we? No, says dude, just your letter, please, and could you confirm your name? Thanks, dude. Wanted to say 'but I could be an imposter! I could be a crook! I could be voting at 15 other stations! Take my ID! But no, they're trusting, like self-checkout at Sainsburys and the postal service. So we made our ticks (3 forms, one with choice 1 and 2, which half the city thinks is a democratic travesty because it's too complicated, and the other half thinks it's symptomatic of the decline of the British Empire because people are too stupid to handle a simple first/second choice ballot paper), and put 'em in the boxes, and left.

No invisible ink, no ID, just a letter. So civilised. And rather nice to think, there's the off chance that the chap I voted for for might actually win, that my vote might've made a difference.

File under: personal : {2008.05.01 - 21:57} : Comments (0)

meta

-home-
about
contact
disclaimer
articles
code
tech blog

style: [?]
[plain.dark.blue]

Categories

java
linux
music
notes/domino
personal
politiek
studies
techie
thee_blog
world

RSS Feeds

rssfeed all posts
rssfeed all cmts
rssfeed tech posts
rssfeed tech cmts

Archives

2010.09
2010.08
2010.07
2010.06
2010.05
2010.04
2010.03
2010.02
2010.01
2009.12
2009.11
2009.10
2009.09
2009.08
2009.07
2009.06
2009.05
2009.04
2009.03
2009.02
2009.01
2008.12
2008.11
2008.10
2008.09
2008.08
2008.07
2008.06
2008.05
2008.04
2008.03
2008.02
2008.01
2007.12
2007.11
2007.10
2007.09
2007.08
2007.07
2007.06
2007.05
2007.04
2007.03
2007.02
2007.01
2006.12
2006.11
2006.10
2006.09
2006.08
2006.07
2006.06
2006.05
2006.04
2006.03
2006.02
2006.01
2005.12
2005.11
2005.10
2005.09
2005.08
2005.07
2005.06
2005.05
2005.04
2005.03
2005.02
2005.01
2004.12
2004.11
2004.10
2004.09
2004.08
2004.07
2004.06
2004.05
2004.04
2004.03
2004.02
2004.01
2003.12
2003.11
2003.10
2003.09
2003.08
2003.07
2003.06

© Colin Pretorius