November 21, 2007
Return Triumphant, Or Not At All

Returning None is Evil. I agree. I've always subscribed to the Samurai Principle myself. If you allow nulls to float around you inevitably end up with NPEs. These can be hard to diagnose properly; not only do you not know if null is actually invalid, but if it is, it's often non-trivial to work out where it came from.

Posted by Simon Brunning at 10:28 AM | Permalink | Comments (3)
November 01, 2007
Coverage Tools

Julian and I have been asked to put together some unit and functional test coverage figures. We've not actually been given any time in which to do it, though, so I wouldn't hold your breath.

Looks like some work was put into using Emma to provide these figures, but it's not finished.

Over in the Python world, there's been some discussion over on c.l.py about Ned Batchelder's coverage.py, which looks like a fairly nifty module.

OTOH, I think you have to be a bit careful with metrics such as those provided by these coverage tools. Ned himself points out many of the problems with taking your coverage figures at face value (though Emma's block-level approach fixes some of them).

I'd add one more issue - gaming. People can start to see good coverage figures as an end in and of themselves. If the coverage isn't at, oh, say 80%, the tests must be crap. If they are at 100%, they must be great. It's not just that the figures can be meaningless, they can actually lead people astray.

Now, for an approach to coverage testing that actually makes sure you are testing that your code does the right thing, check out Jester & Pester.

Posted by Simon Brunning at 06:26 PM | Permalink | Comments (3)
October 30, 2007
Leopard

Leopard looks like it's got some good stuff in it - Time Machine and Spaces especially look good, and the new Terminal looks like it might replace iTerm.

But it looks like they've done the Dock no favours. The Finder changes don't sound to great either. I use Quicksilver and Path Finder, though, so I'm not too bothered about them, and I have a feeling that going forward, I'm going to have to upgrade to get any of the latest toys working.

But anyway, until they fix Java, I can't upgrade, so that's that. Early adopters around the office have found that Eclipse is totally broken on Leopard at the moment, and that's a show-stopper.

Update: Lifehacker on the new Terminal. Also, Richard and Jeff on why it doesn't matter that Java's broken on Leopard. It does matter, though - if Java won't run on Leopard, I won't upgrade to it, and I won't buy a new Mac, either. My loss, but Apple's loss too. I'm a consultant - I don't always get to choose the platform I work with, and many of my clients choose Java.

Posted by Simon Brunning at 09:51 AM | Permalink | Comments (5)
October 16, 2007
Jython 2.2.1

Jython 2.2.1 is out. It's fabulous to see Jython really making strides again. I used Jython 2.1 for years, and it worked just fine, but somehow if people don't see an OSS project making regular releases they somehow assume that they should steer clear, regardless of the quality of the existing software.

And I must say that while the missing new Python features were never a show stopper, it'll be nice to have them.

Posted by Simon Brunning at 02:09 PM | Permalink | Comments (1)
February 27, 2007
London Java meetup tonight

I'll be at Jez's London Java meetup this evening. I've not been to one for ages - not since September - so I'm really looking forward to it.

Provided, that is, that they won't talk about bloody Groovy all night. I've still yet to be convinced that Groovy has anything that Jython didn't have nearly ten years ago. Apart from closures and inelegant syntax, that is. ;-)

A new venue this time - it's at The Crown Tavern, EC1R 0EG.

Update: Seems Jython was around exactly ten years ago.

Posted by Simon Brunning at 10:10 AM | Permalink | Comments (6)
February 08, 2007
QCon London

I don't think I'll be able to make QCon, London this year - my current employer doesn't really see the point of conferences. Which is a shame, 'cos it could have been designed for us. There are an uncanny number of speakers relevant to us: Jeff Sutherland ('cos we Scrum), Gavin King ('cos we use Hibernate), Rod Johnson ('cos we use Spring), and Alex Russell ('cos we use Dojo), plus movers and shakers like Martin Fowler, Werner Vogels, Kylie, and Dave Thomas. I might be lying about one of those, though.

Never mind - there's always PyCamp!

And who knows - I might win a ticket. ;-)

Posted by Simon Brunning at 11:54 AM | Permalink | Comments (9)
October 26, 2006
Interregnum interrupted

They've shortened the interregnum - we'll be sprinting again from tomorrow. Which is a pain, 'cos I'm up to by neck in a real beauty of a bug. I'm getting a ClassCastException from one of our domain objects - but only if the back end is MySQL. Running against PostgreSQL or SQL Server, it's all fine. This is deep into the domain layer; we should have left all the database stuff far behind - and besides, we are using Hibernate, so our database engine specific code is zero.

Naturally we discovered this bug at the last minute, during the demo run-through. Our functional test box runs on SQL Server, and on my machine where it was developed I run PostgreSQL, so it all looked fine, but our demo server runs MySQL. Lucky Tulna did a demo run-through, or it would have fallen over in front of the BSDs...

Update: Got the bugger last night in the pub. It turns our that MySQL's timestamp has somewhat less resolution than the other database engines that we were using. This meant that our domain objects's compareTo() method was finding two timestamps equal, so it resorted to lower order keys - one of which was an ArrayList. Now, for some reason, ArrayLists don't implement Comparable, so when Commons Lang's CompareToBuilder tried to cast them into Comparables, we got our ClassCastException!

The fix was simple - write a little ComparableList class, sub-classing ArrayList, and use that instead. Sorted.

Posted by Simon Brunning at 03:04 PM | Permalink | Comments (2)
October 17, 2006
Java Profiling

Can anyone recommend a good tool for performance profiling Java web applications? (Hibernate, Spring, on Tomcat. you know the kind of thing.)

I've been playing with JiP, but I can't seem to get anything useful out of it. The remote control seems to do nothing at all, so I have to start up the server with it on, which takes a while - then I seem to get no output most of the time. Small runs - no problem. Big runs - which is where I get my performance issues - nothing. Irritating to get no output after waiting several hours for a big test run to complete!

Update: Or, perhaps the fact that Tomcat is still running an hour after I've asked it to shut down indicates that JiP is trying to do something? Who knows?

Posted by Simon Brunning at 03:48 PM | Permalink | Comments (9)
October 13, 2006
Merge tools

If you are going to be doing a lot of merging working with Subversion (or, I'd imagine, CVS), you are going to need good a good merge tool. And believe me, you are going to be doing a lot of merging.

Subversion itself doesn't provide a merge tool - and nor should it. It's a cross-platform command line driven tool, and besides, I suspect that most developers have their own favourite - or need to find one quickly.

If you are working on Windows, you'll probably have Tortoise installed, 'cos it's really good for simple stuff. Tortoise does come with a merge tool, but it's horrid, really nasty. Aside from just how damn ugly the thing is, it's also almost totally incomprehensible. All those colours - what do they mean?

But that's OK. There are alternatives, and they are easy enough to integrate into Tortoise. The first thing I came across was WinMerge. WinMerge is very good for showing diffs, but it doesn't (as yet) do three way merging - so that's out. Another, more powerful alternative is KDiff3. By the time I came across this, I'd already made my happy move to the Mac, so I've not used it myself, but my Windows-victim colleagues report that it works fine.

So the trick is to use the tool with diff in the name for merging, and the tool with merge in the name for diffing. ;-)

Tortoise also provides tools for making and applying patches, but they seem to use fully-qualified path names, so you can't apply patches from one machine to another unless it happens to keep everything in the same place. So, it's best to use Subversion to make your patches with svn patch > whatever.patch to make your patches (or svn st | awk '/^\s?[MAD]/ { print $NF } ' | xargs svn diff > whatever.patch if you've made the same externals mistake that I did), and to use unxutils' patch to apply them.

In the Mac, there's a natural solution - FileMerge, part of the XCode suite. It's very nice to use, if not perfect. (A few more keyboard shortcuts would be nice, for example, Apple, Just 'cos it's GUIfied and beautiful doesn't mean I should be reaching for the mouse all the time.) Integrating it with command line Subversion would be non-trivial but for Bruno De Fraine's lovely Using FileMerge as a diff command for Subversion - he's done all the hard work for you. Thanks for that, Bruno.

Oh, SubClipse also provides a merging tool, but I've never really used it. It's nice to have SubClipse around - the fact that it decorates all your files showing you their status against the repository is nice, and I often use it to add files - quicker than an svd add if you are in the IDE already. But IDE/version control integration is far less crucial than it used to be in the bad old VSS days when you couldn't edit a file without checking it out, so I do most of my Subversion tasks from the command line.

I'd be interested to know what all you *nix types use - especially anything console based.

Have I missed anything cool?

Posted by Simon Brunning at 08:27 PM | Permalink | Comments (16)
December 14, 2005
London 2.0rc1

I was off yesterday. I was feeling a little under the weather. Can't think why. Perhaps I had a dirty glass on Monday night.

I met a lot of nice, interesting people, some for the first time, many not - more on that later.

The night ended with Chris, Edward and I at the Roadhouse. What a flea pit! I was home at four...

Posted by Simon Brunning at 10:32 AM | Permalink | Comments (1)
December 08, 2005
Brunning's 1st Law of System Hassle

All IT systems have roughly equal hassle rates. Should you improve the quality of your software (by means of thorough automated testing and so forth), other components of the system (such as the RDBMS, or the hardware) will take up the slack by failing more frequently.

Posted by Simon Brunning at 01:39 PM | Permalink | Comments (8)
November 25, 2005
Bugger

There goes our crowd for London 2.0.

Update: Just to be clear - London 2.0 isn't off by any means. It's just that I'm concerned that many of our potential attendees will go the the Backstage meetup.

Posted by Simon Brunning at 05:04 PM | Permalink | Comments (2)
November 23, 2005
London 2.0rc1

This is getting out of hand. December the 12th now appears to be a combined Python/Django/TurboGears/Ruby/Rails/Java/Spring/Hibernate/the million other things you need to build a Java web app these days/Perl/Catalyst/Maypole/Groovy/Grails Christmas party, and Jez is trying to get the Geek Girls on board too. Though that may be just wishful thinking on his part. ;-)

So, we really need another name. Jez suggested London 2.0, which is just so zeitgeist. Me, I'm more London 0.9, but I'll go with it...

Let's just hope the Perl guys don't have a punch up.

Posted by Simon Brunning at 01:14 PM | Permalink | Comments (10)
November 22, 2005
London Python/Django/Ruby/Rails/Java Christmas party

Not content with a Python/Django/Ruby/Rails meetup, Sam, Jez and I have teamed up to throw a Python/Django/Ruby/Rails/Java Christmas party this year. (For "party", read "bunch of nerdy blokes, many with beards, standing around drinking beer and chatting about computers".) It's at The Old Bank of England, Fleet Street on the evening of December the 12th.

Do leave a comment if you fancy coming - we have a room booked, and but we can change it to a bigger one if we need to. I anticipate a lot of interest, what with combining the Java crowd with the dynamic language people, and possible extra interest due to last week's London Web Frameworks Night.

Anyone want to demo TurboGears? ;-)

Update: Thanks to Dave and Dave, it's now a Python/Django/TurboGears/Ruby/Rails/Java/Perl/Catalyst/Maypole Christmas party. That has to be every web nerd in London, right?

Son of Update - This Time it's Personal: See London 2.0rc1.

Posted by Simon Brunning at 12:36 PM | Permalink | Comments (27)
November 03, 2005
I'm going to feel it in the morning...

Very good lunch at The Gulshan this lunchtime with my mate Neil. I had a couple of dishes that I'm not familiar with - a Chicken & Mushroom Rizoti, and a Badami rice - and a couple of Cobras. Very good food, clean and pleasant surroundings (once we'd been moved away from the smokers), and not too pricey. (Not as cheap as The Halal, true, but not too far off.) Recommended. I may be going there again on Monday with Jez.

Speaking of Jez, now I'm off to the London Java Meetup. Looks like a bit of a quiet one - but it's the quality that counts, not the quantity, yes? Well, OK, I'm going. But apart from that, it'll be quality, OK? I hope to see a few of you there.

And if I have to look at one more user story...

Posted by Simon Brunning at 04:50 PM | Permalink | Comments (1)
November 01, 2005
Busy Month

It's going to be a busy month for nerdy stuff.

Firstly, there's Jez's London Java meetup on Thursday. Always a good night.

Then, next Monday, we have the London Python/Django/Ruby/Rails meetup. It's looking like we might get a good turnout for that - including my Technical Director! Gulp - I'd better be on my best behavior.

Then again, naaah.

On the 17th, there's the London Web Frameworks Night. Looks fascinating - demos of many of the happening web app frameworks back to back. Given the noise and drunkeness I don't tend to take much detail in during the Python/Django/Ruby/Rails meetups, so it'll be interesting to see more formal demos. Let's hope I'm quick enough to book a seat...

And lastly, there's the Einstein vs. Newton debate at the Royal Society on the 23rd. A different kind of nerdy, but nerdy nevertheless. Not to be missed.

Update: If you want to go to the London Web Frameworks Night, sign up now.

Posted by Simon Brunning at 10:28 AM | Permalink | Comments (2)
October 12, 2005
Selenium

We've not automated our functional tests in the past - I know, I know - but we are really trying to pick up our game in our currenty project, so manual functional testing is another of our bad habits that we are consigning to the dustbin of history. With a bit of a steer from Sam, I looked at a number of functional test tools, but Selenium really stood out from the rest. It's just powerful enough, it's really simple, and it runs in your browser, so you can test browser compatability. Take a look at the demos to see how simple it all is.

In essence, your test script is just an HTML table, each line of which is either an action or an assertion. There's even a tool to record your actions to give you a hand building regression tests.

Now I just need to work out how to integrate it all with Cruise Control. Anyone done this?

Oh yes, and I need to find a way of testing our web services, too. Is there no end to the array of tools that you need to build a web application these days?

Posted by Simon Brunning at 04:59 PM | Permalink | Comments (4)
September 27, 2005
Nerd Day

Friday's Nerd Day went pretty well. Steve started the day knowing Java itself, but nothing else, and by the end of play we'd covered Ant (which we used to do all our building and deploying), Tomcat, Eclipse, Servlets, JSPs and JSTL, Postgres and JDBC, and we'd written code to display the contents of a database table on a web page. Not in a lot of detail, true, but still, that's a lot of ground for one day. Steve seems pleased, anyway.

Mark had touched most of this before, but not for a good while, so I hope it was valuable to him too.

Loads more to cover, though - I'd like to expand on what I've already covered, and put a bit more meat on the bones, and there's still Spring and Hibernate to look at. So, we'll be doing another day or two before too long. Still, both my victims test subjects pupils feel up to coming along to the next London Java meetup.

Plenty of things went wrong, mainly due to my general incompetance and lack of planning. In a funny kind of way, though, this was a good thing - it gave us a change to diagnois and fix the problems. Knowing where the logs are is often half the battle.

Posted by Simon Brunning at 05:17 PM | Permalink | Comments (2)
September 22, 2005
Nerd Day

Right. I'm off to Haslemere to meet Steve to drink beer. Then, tomorrow is the long planned Nerd Day, during which I'll be showing Steve how to build a web application in Java. Mark will be coming down for it too; I gather that he's a bit sick of VB now.

I'm a rubbish trainer, so wish me (and them) luck. No need to worry about this evening, though; I'm good at drinking beer.

Posted by Simon Brunning at 04:38 PM | Permalink | Comments (7)
September 07, 2005
Java/Flickr Meetup

Last night's Java Meetup was great fun.

El Presidente was a little disappointed - he'd come along hoping to talk to some people about XP. (We are adopting it at work, bit by bit, and while we can all see the problems inherent in Big Design Up Front, we are also having difficulty working out how to do without it.) There are usually a few ThoughtWorkers around, but not this time, and no one else had any real XP experience. They'd all read the book, though. ;-)

It wasn't a total waste for him, though - He, Tulna and Darren formed a mini digital photography and Flickr sub-meetup. There were some good photos taken: (See here, if the permalink gets fixed, or find them from here otherwise. Darren also posted some of them to his blog, and set up a London Java Meetup Flickr group.) Darren had a particularly nice lens - even I managed to take a decent photo with it.

El P and Tulna were pleasantly surprised by the absence of wierdos, I think, but they both left fairly early.

Late in the evening I had a conversation about the lovely Spring framework with Rob Harrop and Rick Evans. This is most unusual - Jez has specified Spring as the topic of the month, and I never talk about Jez's topic.

Anyway, thanks to Jez for another good night. It would be rather churlish to blame him for my hangover, wouldn't it?

Posted by Simon Brunning at 03:29 PM | Permalink | Comments (6)
Google London

The big news from last night's Java Meetup is that Google is settting up a London office. It's to be focused on mobile devices, and new Google employee Ian Sharp was there to spread the news. They will be looking for people with Java skills, so have a go if you think you are hard enough.

Posted by Simon Brunning at 02:53 PM | Permalink | Comments (4)
August 31, 2005
Roadkill

I've been getting on fairly well with Roadkill, my nice new Powerbook, but it's been a bit of a learning curve. The pretty Mac front end stuff is a piece of cake on the whole, with one major exception - undo, cut, copy and paste are Apple-z, x, c, and v respectivly, instead of Ctrl-z, x, c, and v as they are on Windows. I've been using those shortcuts for so long now that they are embedded in muscle memory. I've hit the wrong shortcut before my brain (such as it is) has had a chance to overrule them. Getting over that is going to take a while.

Getting some of the command line driven stuff - Ant, Subversion and Tomcat - working was a bit more of a challenge. Easy once you know how, but you keep being tripped up by things that I didn't know about.

I had installed Java 1.5, but the installer didn't tell me where it had been put, so I had to go and look for it. I found it in /System/Library/Frameworks/JavaVM.framework/Versions/1.5/ in the end.

There was already a version of Ant installed in /Developer/Java/Ant, probably as part of the XCode tools install, but it was the wrong version, and in any case I wasn't able to add 3rd party tasks to it, so I needed to use my own version.

Both of these problems involved setting environment variables, and I gather that it's recommended that you don't muck about with global environment variables, so I set up some shell scripts to start and stop tomcat and to run ant scripts with the environment variables set correctly. I was even smart enough to put the shebang line at the top (though finding the bloody '#' key took a while) and to mark them as executable wwith chmod. But I still couldn't run the bloody scripts. The shell was claiming that tey wen't there, though I could see them with ls.

It turns out that your current working directory isn't on your path by default. Arrrgh! That one took me hours, literally. Prefixing the script names with ./ does the trick there.

I still can't resolve any of the other boxes on my network by name, only by IP address. Irritating, but no show stopper. I can always add them to /etc/hosts, but for the moment I'm just using the IP addresses.

Still, I managed to get past all that, and my current web application is building and running on Roadkill happily enough now, after fixing a couple of minor Windows-isms in our build file. ;-)

Next on my list; installing PostgreSQL, and getting my app to work with it, and working out this whole multiple Python versions on one machine thing, and working out where the insert and delete keys are...

One other thing - what do you, uh, we Mac users use to read Usenet? Entourage seems to have trouble getting at Gmane - this fix, uh, doesn't.

Posted by Simon Brunning at 01:52 PM | Permalink | Comments (17)
Java Meetup next week

Pop along to next week's London Java Meetup on Tuesday the 6th. I'll be there - and I'm bringing Tulna and El Presidente with me this time. Perhaps Steve, too.

This month's topic is Spring, but as usual, off topic nerdyness of any kind seems to be welcome. For instance, I happen to know that Tulna (nerd in denial) will be interrogating Darren about shooting RAW, since she has a shiny new Nikon D70s.

I've dropped the ball a little recently with the Python meetups, but I'll probably organise one for October. I can't afford one this month - I spent over £100 last time!

First post from roadkill!

Posted by Simon Brunning at 01:05 PM | Permalink | Comments (5)
July 14, 2005
Spring: Bold as Love

I am having trouble getting Spring and Axis to play nicely together.

I've been getting along famously with Spring. We are using Spring's MVC framework, and everything was fitting together as smooth as silk. Our DAO's are coded using HibernateDaoSupport, instantiated as beans wrapped in HibernateTransactionManagers, and injected into our actions and controllers. With this lot set up, Spring and Hibernate between them do all the heavy lifting in terms of database work, and our code needs to know almost nothing about it. And using jMock in our unit tests to mock the DAO, we had close to 100% coverage.

Then I was asked to introduce web services. Axis looked to me to be the de-facto standard, so that was what I've been using so far. In most ways, it's a thing of beauty - I particularly like happyaxis.jsp - but I can't work out how to get it to play happily with Spring. Spring isn't instantiating the service objects, so it doesn't get an opportunity to inject the DAOs.

In order to unit test at all, I've created given the service objects setters and getters for the DAOs they need. The getters lazily initialize the DAOs from Spring in required. In our unit tests, we just call the setter with a mock object, so the lazy initialization never gets used.

public CurrencyDAO getCurrencyDAO() {
 
    // Lazy initialisation. If the DAO hasn't yet been set, we'll get it
    // from Spring. I doubt we'll be able to cover this in testing.
    if (this.currencyDAO == null) {
        this.logger.debug("Lazy initialisation of currencyDAO");
        final ApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext());
        setCurrencyDAO((CurrencyDAO) applicationContext.getBean("currencyDAO"));
    }
    return this.currencyDAO;
}
 
public void setCurrencyDAO(final CurrencyDAO currencyDAO) {
    // This will probably ony be needed for test purposes.
    this.currencyDAO = currencyDAO;
    this.logger.debug("currencyDAO set to " + String.valueOf(currencyDAO));
}

(How do I get the servletContext? In the real code, I grab hold of it with a ServletContextListener, and keep it in a Borg.)

This works, but it feels inelegant. Worse, much of the getter is impossible to unit test. Is there a way to get Spring to instantiate my Axis service objects? Is there a cleaner way of getting beans from Spring? Is there another web service framework that plays nicer with Spring?

Posted by Simon Brunning at 04:52 PM | Permalink | Comments (4)
June 23, 2005
Instant Messaging

Mum is looking to do a spot of Instant Messaging with her Amida Buddhism chums. (My, look at all those blogs! All down to Mum's example.)

I've been looking at IRC recently, and it's really nice for techies. I've been using Bersirc as a client and Freenode as a server, and it's dead good. I've had some really useful help with Spring on #spring, and #python is cool too. (Say "Hi" if you are around there - I'm on as "small_values".)

But is it good for non-techies? If not, what should I recommend to her instead? Trillian? Miranda? Using what protocol? ICQ? (Anyone mentioning MSN can bugger off. These people are Buddhists, and need to keep their souls pure.)

Posted by Simon Brunning at 01:03 PM | Permalink | Comments (16)
June 09, 2005
Signing off

I'm off to CenterParcs with the kids, and my Mum, sister, brother in law and nieces next week, so Small Values will be even quieter than usual.

Blogging has been sporadic at best recently 'cos I've been so busy, mainly with a new Java web-app that we've been working on, using Spring and Hibernate running over a legacy database. It's been hard work, but I think we are over the hump now.

The other thing that's been keeping be busy is doing the Python URL. It's hard work - but it seems to be going down well. If there's one next week, though, it probably won't come from me...

Anyway, have a good week all. I might possibly post next week if there's a 'net café around, but don't count on it. I should have loads of photos by the 20th.

Posted by Simon Brunning at 01:24 PM | Permalink | Comments (5)
June 02, 2005
Doh!

Note to self - when copying files with Ant, never apply a filter to JAR files. They break.

If you do do this, try not to spend ten bloody hours working out what's gone wrong.

On a similar note, jMock is lovley, but don't get too carried away and mock the object that you are actually trying to test. You won't find any bugs, and your EMMA stats will suffer.

Posted by Simon Brunning at 01:56 PM | Permalink | Comments (3)
May 24, 2005
Hibernate Support

I take it all back. Hibernate support isn't as great as all that after all. After a very good start, I've had no help whatsoever on several issues. One I managed to work out for myself - One-to-many relations with composite natural keys.

I'm still having problems with a couple of issues, though. Firstly, I can't work out how to do data cleansing with Hibernate. It falls over on the first dodgy data it sees. I want to get a list of all the problematic data, and I can't work out how to do it.

The other problem that I'm having or with a complex relationship between a couple of entities; both one to many and one to one. I've got company definitions and currency definitions with a bog standard parent-child relationship - one company has a number of currencies defined for it. But the company also has a reporting currency - a foreign key back to the currency file. I can see that this relationship is slightly problematical in relational terms, but it makes perfect sense in business terms. Anyone have any idea how to write this relationship in Hibernate? (In fact, I can think of two workarounds. I could make the reporting currency code available as a property rather than relating back to the current table directly. Retrieving the currency object would then be the client code's job. Or, perhaps I could try building the company to currency link as a one to many. I'm not even sure that that would work. Besides, I really want to fix this problem properly, for one and for all. I'll probably come across a lot of this kind of relationship as I map more of my legacy database.)

I wonder if the problem is that Hibernate uses a forum rather than a mailing list? It's much easier to ignore forum threads that it is to ignore emails in your inbox.

Whatever the issue, I do know that questions like mine do get some kind of answer on c.l.py, Just about any inquiry gets some kind of response, even if it's just a request for more info, or a URL to follow up.

Posted by Simon Brunning at 10:01 AM | Permalink | Comments (3)
May 11, 2005
Hibernate and my legacy database

Before I start, a big thank you to Max over at the Hibernate User forum for helping me out. The quality of the code is only ever half the reason why open source tools are the best way to go. The other half of the reason is Max, and people like him, ready to help out a complete stranger. Thanks, Max. ;-)

Anyway, what I've been busy with over the last few days is building some mappings from Hibernate to an existing legacy, err, sorry, I mean a vintage database. Hibernate is lovely. Lovely lovely lovely. But I think it's fair to say that there's a lot more work involved in mapping to an existing database than there is if you are able to just let Hibernate get on with its thing and create its own schema.

The, err, vintage database is a quarter of a century old, most of it. It's not in bad shape - I've worked with a whole lot worse - but obviously it's not put together with modern best practices in mind. Loads of natural composite keys. Sigh. Also, the data types available at the time the system was first build were quite limited. There were no booleans or datetimes available, for instance, so these are stored as CHAR(1) and DECIMAL(7,0) columns respectively, so I've had to put together my own custom user types for these. Just to make life that little bit more painful, not are the only are the dates stored as seven digit numbers (in CYYMMDD format, where a C value of 0 is for last century, 1 for this - common practice on a '400), but they can also hold all zeros or all nines!

It's an iSeries (a.k.a AS/400) DB2 database, which Hibernate supports up to a point, but what I'm going to do when I come up against platform specific things like multi-member files I don't know. I'm sure I'll think of something.

There are also a few tables with no unique keys. That's really no unique keys - it's valid for there to be multiple identical records. I'm pretty sure I'll have to go back to plain old JDBC for those tables. Thankfully, this isn't common. Even twenty five years ago it was obvious that that was a bad idea!

I'm off to work out how to do a one-to-many relation where both sides have composite keys...

Posted by Simon Brunning at 02:01 PM | Permalink | Comments (8)
April 29, 2005
Passwords and Ant

A number of Ant tasks require passwords - server deployment, verson control, that kind of thing. How do you deal with them? I'm not happy about keeping them in properties files - not too secure - but I can't find any way of persuading Ant to prompt for them. Obviously, this problem has been solved long since, but I can't seem to track down the solution.

Posted by Simon Brunning at 05:44 PM | Permalink | Comments (13)
April 13, 2005
A rather unfortunate decision

Tonight's London Python Meetup at The Stage Door will be the last one organised via meetup.com, due to a rather unfortunate decision of theirs. If you want to be informed of future London Python meetings, you'll need to join the Python UK mailing list - or just subscribe to this blog.

It occurs to me that a moin page would do everything that we need - new events could be entered there, and people could subscribe to the page to be kept up to date. Perhaps I'll install a moin instance here on SVoC - or perhaps I could just add a page to the Python Wiki?

Oh, and don't forget the London Java meetup on April the 20th. I'll be there!

Posted by Simon Brunning at 11:02 AM | Permalink | Comments (4)
April 06, 2005
JSR Groovy

It's still not showing any signs of tempting me away from Python/Jython, but congratulations to James, Jez et al on getting the Groovy JSR 01 release out of the door.

Posted by Simon Brunning at 10:35 AM | Permalink | Comments (3)
March 18, 2005
Jolt 2005 awards

Congratulations to the Jolt 2005 award winners (PDF). I've read, used or will use a number of the winners:

But where's Spring?

Posted by Simon Brunning at 09:39 AM | Permalink | Comments (1)
March 17, 2005
Books

Oooh, a nice big pile of books has just arrived:

The first two are mine, but I managed to convince the company to spring for the rest. ;-)

Posted by Simon Brunning at 04:05 PM | Permalink | Comments (3)
March 07, 2005
Spring or Struts?

My company is deciding on the toolset that we'll be using for our next generation of web applications. Java was a shoe-in after my Python suggestion was shot down early in the discussion. :-(

But deciding upon Java is only the first step - you need a whole bunch of stuff to go along with it. One of our recent projects was intended to be a pilot, and I was fairly happy with the toolset that we used for that, so mostly we'll be updating that list.

In the end, though, we ended up not using Hibernate and not using Struts - we wrote our own. This time, I'd like to use frameworks for these layers rather than building our own workable but time consuming and frankly far inferior versions.

Hibernate looks by far the front runner for the persistence layer, but selecting the MVC framework isn't so easy. Struts is certainly the de facto standard here, but I'd like to be using Spring for other things in any case, and I gather that its MVC component is really good, so I lean towards using that too.

Good idea? Bad idea?

There are a few other additions to the original toolset:

  • Log4j
  • We'll be using JSP (and JSTL) for our View layer. Unfashionable, I know, but since JSTL came along and removed the need for virtually all of those nasty scriptlets, I find JSP to be rather nice.
  • EMMA for unit test code coverage reporting
  • iText if we need any PDFs generated
  • Joda Time
  • jMock
  • displaytag

Anyone think that we shouldn't be using any of this stuff? Anything essential that I'm missing?

Posted by Simon Brunning at 10:45 AM | Permalink | Comments (21)
March 01, 2005
Yesterday's London Java Meetup

Coming in to work on a badly overcrowded and very slow running tube with a nasty hangover is no fun, I can tell you.

But last night was a good one.

It looked like it might get a bit nasty at one point. We used a back room that had been booked by a bunch of performance poets. Java nerds versus poets - what a rumble that would have been.

In fact, we just moved to the front of the pub, where I remained undefeated on the pool table.

Oh, and don't forget the Python meet up next week...

Posted by Simon Brunning at 04:54 PM | Permalink | Comments (1)
February 28, 2005
London Java Meetup tonight

Turnas out that I can make the London Java Meetup this evening. But since I still can't see Haloscan, I can't tell Jez about it...

Anyway, see you there.

Posted by Simon Brunning at 01:48 PM | Permalink | Comments (2)
February 23, 2005
The real problem with Java

I've realised what the real problem with Java is, for me. It's not the fact that my productivity is much lower with Java than it is with Python. After all, it's my management that decide that I should be using Java, and if they want to make me less productive than I could be, it's their prerogative.

And it's not the vast raft of tools, libraries and frameworks that a modern Java application uses that bothers me. It's a problem for a lot of people - c.f. Bruce Tate's superb Better, Faster, Lighter Java (on which more later), but I like learning new stuff, so I'm happy.

No, the problem is that Java coding is just no fun...

Posted by Simon Brunning at 12:54 PM | Permalink | Comments (33)
February 10, 2005
Weird Eclipse error

I've come across the error message "The import somepackage cannot be resolved" loads of times - I'm sure that we all have. It usually means that you are missing a JAR file from your project's build path. But I'm getting it under strange circumstances this time...

The package that Eclipse is objecting to at the moment is in the current project! If I remove the import, and do an "Organise imports", Eclipse will replace the import, then claim not to be able to find it. If I hit F3 on the import, Eclipse takes me straight to the correct class.

Anyone got any ideas as to why Eclipse is claiming not to be able to resolve the import?

I have this problem running Eclipse version 3.1M4 and version 3.0.1, all on Windows 2000, with Java 1.4.2_1.

(I've also posted this to the eclipse.tools.jdt newsgroup - see Import cannot be resolved - for a class in my project!. You'll need a password before accessing this newsgroup.

Thanks in advance for all your recommendations that I switch to IntelliJ IDEA. ;-)

Posted by Simon Brunning at 01:17 PM | Permalink | Comments (41)
February 02, 2005
You are in a maze of twisty classes, all alike

Steve Rose is a very bad man. Vodka and Baileys is no drink for a man, but if (much against your will) you do drink it, you get very pissed indeed.

Anyway, we had a look at his code. He's fallen afowl of Java's laberynthine java.io. Now, I need a FileInputStream, an InputStreamReader and a BufferedReader to read a file, right? Or is that a FileReader and a BufferedReader? I've done this loads of times, and I still can't remember. It's hardly surprising that Steve can't work it all out. There really ought to be an openTheGoddamFileAlready() method somewhere...

Update: Here's how you do it in Python. Less is more.

Posted by Simon Brunning at 11:10 AM | Permalink | Comments (4)
January 28, 2005
Putting it all together

Tell me what to do, please.

I've most often come across this issue building Java web applications. There are just so many pieces to stitch together, and to find places to put; your your build script, your business objects, your tests, your JSPs (or whatever), all your 3rd party JARs, your persistence stuff, your MVC stuff, your IoC stuff, about a gazillion configuration files to make all this lot work together, it just goes on and on. It takes a while, and if you get it wrong, well, everything still works, mostly, but you'll have maintenance nightmares for life.

In fact, it got so out of control that Matt Raible came up with the wonderful AppFuse. Appfuse is great - it builds a project structure for you, using your choice of frameworks, so you can hit the ground running. I only hope that Matt learns to slow down a little!

Perhaps that's what Python needs - not Rails, but AppFuse.

Update: Matt's site seems to be down at the moment. But do try later - AppFuse really is worth a look

Posted by Simon Brunning at 02:24 PM | Permalink | Comments (9)
January 20, 2005
Special Cases

Very interesting London Java Meetup last night. It was nice to see Darren and Steve along for the first time, and I had a very interesting chat with James about Sun's new interest in dynamic languages, and Groovy, his baby. (Jez is also working hard on Groovy at the moment.)

It's interesting to see the differences and similarities between the philosophies of Groovy and Python. One thing that James and (channelling) Guido agree on is that simplicity is good. They disagree on what constitutes simplicity, though.

Take functions for a moment. In both Python and Groovy, functions and methods are 'first class', which means that they are objects in their own right, and can be passed around like any other object. They differ in how that's done, though.

In Python, a function is called by putting parenthesises after its name:

>>> def spam():
...  print "spam's been called!"
... 
>>> spam()
spam's been called!

If you want to refer the function object, you just leave the parenthesises off:

>>> spam
<function spam at 0x0117CDB0>

This makes it easy to pass the function around:

>>> eggs = spam
>>> eggs()
spam's been called!
>>> def chips(a_function):
...  a_function()
... 
>>> chips(spam)
spam's been called!

To me, that's nice and simple. No special cases. As Tim put it, "special cases aren't special enough to break the rules". A function is an object, names are bound to objects, using the base name refers to the bound object.

"Ah!", says James, "but 99% of the time when a newbie leaves the parenthesises off, it's a mistake. That want to call the function." This is probably true. So in Groovy, if the function takes no arguments, you can call it without parenthesises. If you want to refer to the function object, there's a special syntax for that. (Perhaps James or Jez would care to give an example here?) The 'normal' case gets the normal syntax, and the unusual case gets the special syntax. So, is this simpler?

Another example - self. Python requires all methods to take an explicit self argument. After all, a method is just a function belonging to an instance really, and it's simpler to pass that instance explicitly. No black magic, and it makes injecting new methods into classes and instances at runtime simpler. But you always need a reference to the instance, though, so in Groovy it's is available implicitly. It's not like you need to dynamically add methods that often, is it?

To me, having all this implicit stuff is more complex than doing everything explicitly. But to James, keeping the common case simple to write is simpler. Who's right? Who knows. I like Python's approach myself, but it's not obvious to me that James is wrong.

I'm also sad to say that James is starting to understand what it must be like to be Guido, attacked every time you propose a change. Bloody nice chaps, both of them, so this is a real shame.

Oh and where were you, Sam?

Posted by Simon Brunning at 01:52 PM | Permalink | Comments (13)
January 14, 2005
London Java Meetup

The next London Java Meetup is next Wednesday, the 19th. Nerds of all persuasions and ranks welcome.

Predicted topics of conversation: Jez and James will tell you that Groovy is the future, I will be unconvinced, Sam will tell us all about build pipelines until our brains fall out, then we'll either talk about how cool the Huygens probe was, or, should it go tits up, how sad it all was. Everyone will show off their cool iBooks, and I'll be jealous.

Shall we try and talk Jez into going to The Poet again? It's much quieter than Smiths of Smithfield...

I've ordered some Ubuntu release disks, both x86 and PowerPC flavours. With luck, I'll have them in time to give them out.

Oh, and don't forget the 20th and 27th...

Posted by Simon Brunning at 01:24 PM | Permalink | Comments (1)
December 09, 2004
Dynamic Languages Summit at Sun

Dynamic Languages Summit at Sun, involving Guido, Samuele Pedroni, Larry Wall and James Strachan, to name but a few. Cool!

Jez was telling me about this at last night's Java Meet, but he asked me to keep it under my hat. But I suppose that if Tim Bray is blogging it, it's pretty squarely in the public domain!

Update: Ted Leung - Dynamic language support on the JVM - cross your fingers!

Posted by Simon Brunning at 12:05 PM | Permalink | Comments (2)
December 08, 2004
London Java Xmas Party This Evening

Don't forget The London Java Xmas Party this evening. Nerds of any stripe welcome.

Posted by Simon Brunning at 11:14 AM | Permalink | Comments (2)
November 24, 2004
Ho Ho Ho

London Java Xmas Party. Be there, or be square. Or, as empirical evidence shows to be not uncommon, both.

Posted by Simon Brunning at 01:29 PM | Permalink | Comments (1)
November 11, 2004
Nerd Pride

Orpington, day three. Sigh. Still, I'm writing some kick-ass SQL. All standard stuff, too - none of your nasty vendor extensions here.

Anyway, I do hope to be able to make tonight's London Java Meetup. Do try and get along, London based nerds.

Posted by Simon Brunning at 09:53 AM | Permalink | Comments (2)
October 12, 2004
The Good, The Bad, and the Nerdy

London Java Meetup - 18 Oct 2004.

Posted by Simon Brunning at 04:03 PM | Permalink | Comments (1)
September 28, 2004
Nice People

Are Python people really nicer than Java people? Hmm, well, it seems to be that case that c.l.py is unusually good natured. But I have to say that I've found Java people to be really nice too. People are ridiculously helpful over on the iText mailing list. And last night's nerd-crawl was a pleasure as always.

Posted by Simon Brunning at 01:16 PM | Permalink | Comments (0)
September 27, 2004
Night of the Crawling Nerds

The inaugural London Java pub-crawl is tonight. Not the last, I hope. Nerds of all ranks and persuasions welcome.

Posted by Simon Brunning at 01:10 PM | Permalink | Comments (1)
September 16, 2004
iText

iText - it's just so easy! I may be seeing it through rise tinted spectacles, scared as I am by my recent run in with StyleReport, but I'm just loving using this. I've finished the tutorial, and I'll get started on the real deal tomorrow.

Posted by Simon Brunning at 04:56 PM | Permalink | Comments (3)
September 13, 2004
Result!

Goodbye StyleReport, goodbye Inetsoft. I have the go-ahead to rewrite our PDF reports in iText.

:-)

Posted by Simon Brunning at 01:31 PM | Permalink | Comments (8)
September 10, 2004
Rotten Statics

We had rather an obscure issue today.

Rather against my advice, we have a class to keep all our string constants in - Constants.java. I wanted to keep these strings either in the classes to which that naturally belong, or in a configuration file if they were likely to change.

What can I say? I was outvoted. ;-)

Anyway, Constants.java consists of nothing but a bunch of lines like this:

public static final String PRINCIPAL_SESSION_ATTRIBUTE = "principal";

At the last minute before going live, the value of one of these strings changed. We ran our dist target, and installed.

One of our classes, let's call it Skippy.java, refers to this string - and we were finding that it was picking up the old value. We were, to say the least, perplexed. We removed the web application completely from Tomcat, and deleted WARs and classes from all over the shop before reinstalling the app. No dice - it still picked up the old value. We bounced Tomcat, which didn't help. We rebooted the server, ditto.

We even decompiled Constants.class. It contained the new value.

In the end, I tried decompiling Skippy.class. Lo and behold, there it was - the old value. WTF was it doing in there? It should have referred to the value in Constants.class, shouldn't it? Why did it have its own copy? And if Skippy.class was supposed to have its own copy of the literal, why didn't Ant recompile it for us?

Anyway, we only had to run ant clean dist, and install the WAR file we got from that, and all was well.

Lessons learned today:

  • Really don't use a bloody constants class.
  • Make your dist target dependent on your clean target.
  • Nobody likes it when you tell them "I told you so". ;-)

Posted by Simon Brunning at 04:40 PM | Permalink | Comments (11)
Bend Over...

From an ongoing dialogue with one of our suppliers:

> From: [Name deleted to protect the, uh, whatever.]
> 
> Simon,
> 
> My name is [Name deleted] and I am an account manager at Inetsoft. My 
> records show that
> your maintenance expired on May 1, 2004. To get support at 
> this point, you
> would renew maintenance as usual, but also would need to pay 
> a $100 penalty
> for the breach in maintenance (This should have been indicated on the
> original quote). As you were operating on the complementary 60-day
> maintenance, a 1-year extended maintenance would be traced 
> back to the date
> of purchase (Mar 2, 2004), giving a renewal date of Mar 1, 2005.
So, as I read this, in order to get serious defects in your product repaired, you want to charge me a year's fee for six month's support, plus a hundred dollar fine on top?
This doesn't sound too reasonable to me...
Cheers, Simon Brunning.

Update: They got back to me:

Please understand without these terms, many customers would decline initial
maintenance, and come back to the sales department and purchase maintenance
only when they run into a problem. This causes problems for our customers,
as they need to produce the funds and process the order all the while
development is on hold because of a bug or issue in the software that does
not allow them to continue their efforts. Comparatively speaking, the
penalty is a small amount and is primarily in place to discourage this
activity.

Ah, so these terms are for our benefit! It all makes sense now!

iText it is, then.

Posted by Simon Brunning at 08:48 AM | Permalink | Comments (9)
September 03, 2004
Mad Hungarian

One for Mark: Hungarian notation: an outdated concept. See, Mark, there's almost nobody left who still thinks that Hungarian doesn't suck.

Posted by Simon Brunning at 01:48 PM | Permalink | Comments (5)
August 18, 2004
Pro Plus for Eclipse

Eclipse rocks - when it's awake. But using it on Windows, I've found that it has a tendency to drop off - if I've not used it for a while, or especially if I've minimised it, it often takes a good twenty or more seconds to start moving again, and even than it takes a long time before it starts to respond snappily.

The KeepResident Eclipse plug-in seems to fix this. It works for me, anyway.

"Windows has a tendency to preemptively swap Java processes out of physical memory, even when there is still plenty of physical memory available." Hmmm. You could almost think that this was deliberate, couldn't you? No, it's not possible - Microsoft would never behave in an underhanded fashion like that, would they.

Posted by Simon Brunning at 05:56 PM | Permalink | Comments (6)
July 29, 2004
Mocking a URL

Tulna's having a bit of trouble with some unit testing at the moment. The lovely Emma has pointed out a few holes in our test coverage, and Tulna is endeavouring to fill them.

She's currently working on building tests for our configuration classes. We use Digester to pull in all our configuration from XML. In real life, it's all as sweet as a nut, but obviously we still want unit tests to ensure that any future breakage is discovered PDQ.

We run digester in a ServletContextListener's contextInitialized(). After setting up our digester, after all that addObjectCreate(), addBeanPropertySetter() shenanigans, the code which actually does the digesting looks like this:

URL configFileURL = context.getResource("/WEB-INF/config.xml");
InputStream configFileStream = configFileURL.openStream();
config = (Config) digester.parse(configFileStream);

Question is, how do we get our test data into configFileStream? The context object is a mock, so we can do anything we like there - but how do we mock URL? It's a final class, so we can't sub-class it...

Posted by Simon Brunning at 05:12 PM | Permalink | Comments (7)
July 28, 2004
IBM's new Eclipse toys

IBM has released some cool looking new Eclipse plug-ins: Eclipse Web Tooling Platform Contribution - IBM. I particularly like the look of the Data Tools, the Server Tools and the Structured Source Editing.

Posted by Simon Brunning at 02:38 PM | Permalink | Comments (1)
Soft-coding the class's name

Ever since I started using log4j, it's irritated me that I'veneed to hard-code the package name in my Category log = Category.getInstance("package.name.here") statements, once in every class. Well, it turns out I don't; Pretty Log4J shows how to avoid hard-coding. ClassName.java lets me do Category log = Category.getInstance(ClassName.getPackageName()) - much nicer.

Posted by Simon Brunning at 02:18 PM | Permalink | Comments (5)
July 20, 2004
EMMA

Sam pointed me at EMMA, (a Java test coverage tool,) and I've recently found the time to implement it.

Well, it was either that, or struggle with StyleReport Pro. What you you rather do? ;-)

Anyway, EMMA's output is really rather nice. It's structured and informative - you get a good high level overview, but you can you can drill down to reports on individual line coverage. Getting it running with our existing test suite took me a couple of hours of fiddling - but perhaps that's another post...

Posted by Simon Brunning at 01:50 PM | Permalink | Comments (1)
Taking the back off the radio

Inetseft's StyleReport Pro is the bane of my life at the moment. We need to point our reports at different data sources and even different servers under certain circumstances. StyleReport offers no way of soft-coding these values, so the suggestion is that we have a separate instance of each report definition for each combination of server and data source that we might want to use. Yuck.

But... the report definitions are stored as XML files. Editable XML files. Mwahahahahaha!

Now, StyleReport insists that these report definitions live in the file system. This breaks our J2EE application to a certain extent, because J2EE does not guarantee the availability of a file system. In practise, we are OK; we are deploying to Tomcat, which does give you a file system. We need to keep the application's home directory in a configuration file, which is nasty, but which works. Had we needed to deploy to a sterner J2EE server, though, such as WebSphere, we'd have been buggered.

I wonder how many supposedly J2EE applications need access to the filesystem? Quite a few, I'll be bound. So, does this mean that IBM is being a bit over-strict with WebSphere? Well, no; WebSphere runs on platforms with totally non-standard file systems; the AS/400, no, sorry, iSeries, no, sorry, i5.

Anthony points out that with a bit of work, you can give a J2EE application a file system using Commons VFS. Cool stuff.

Posted by Simon Brunning at 01:05 PM | Permalink | Comments (7)
July 16, 2004
StyleReport

I've spent the last couple of days with Tulna, building PDF reports with Inetseft's StyleReport Pro. It's a piece of shit. My brain is numb.

Posted by Simon Brunning at 04:47 PM | Permalink | Comments (12)
July 14, 2004
Scary Hacks

Hats off to David Shay for Unfinalizer. Light the blue touch-paper, and retire to a safe distance.

Via talios, via Erik.

Posted by Simon Brunning at 02:36 PM | Permalink | Comments (0)
Eclipse: Mark Occurrences

My favorite feature of the new Eclipse release, by far, is something that isn't turned on by default, and took me a long time to discover: Mark Occurrences. This is just so useful...

Give it a bash, if you haven't already; it's great! Basically, it highlights whichever element your cursor is on. This element is highlighted throughout the Java editor, both in the edit area and in the right-hand margin where errors and warnings are shown. (What is that called, by the way?)

And there's more. Put your cursor over a method's return type, and it'll highlight all the method's exit points. Put it over an exception in a method's throws clause, and it'll show you all the places in your method where that exception can be thrown.

Posted by Simon Brunning at 02:17 PM | Permalink | Comments (5)
July 12, 2004
London Java Meetup Tonight

Ooooh, it's going to be an exciting London Java Meetup tonight!

Firstly, we've got Hani versus James and the Groovy boys arguing about Groovy. Despite what Sam says, I'm not against Groovy as such, but I have my own favorite, and with religious wars, you often get a with-us-or-against-us kind of thing going on. ;-)

Then, for the 2nd act, you'll have the Thoughtworkers having a full and frank exchange of views with Hani, who's been dissing them and their Guru.

Should be fun.

Posted by Simon Brunning at 02:11 PM | Permalink | Comments (2)
Test Coverage: JXCL

Our unit test suite isn't all that it could be. For one thing, it wasn't run at all while I was away - that's two months! Sigh. Naturally, running Ant's test target resulted in a smoking ruin...

Still, we've got all but a couple of the tests working again, usually by changing the tests to reflect changed functionality, but often by fixing the bugs that the tests should have been making plain.

Now I'd like to see what our test coverage is; I'm sure that it's far below 100%, and I'd like to start moving it in the right direction. Has anyone used JXCL and UCovered? Any good? Or is there something else I should be looking at?

Aside from "run your bloody unit tests", there's one other lesson learned; some of the code breakage resulted from changes to our database definitions, which for some reason were never kept under source control, so it's not possible to establish who made a change, when, and most importantly, why. The database change might have been made for a good reason, so you just can't remove it - especially if your unit tests are spotty.

I gather that keeping your database definitions under source control isn't trivial when you are using SQL Server, but it must be possible. We'll do it next time; if I can't manage to convince the team to move away from SQL Server, we'll just have to work it out.

Posted by Simon Brunning at 01:42 PM | Permalink | Comments (11)
July 08, 2004
About Time

Via Managability's Top Ten Truly Obscure But Useful Java Projects, I find the suddenly essential Joda Time. Not quite mxDateTime for Java, but almost.

Some other interesting recent Java links:

Posted by Simon Brunning at 02:03 PM | Permalink | Comments (0)
July 05, 2004
So Long Angel

Also in my hectic social calendar in the next couple of weeks, So Long Angel, the thinking man's pub blues band, will be at The National Theatre on Wendesday the 14th. They are well worth a listen; they are better at music than they are at web site design, trust me. ;-)

And don't forget the London Java Meetup next Monday, now featuring A-list Java blogger Hani.

Posted by Simon Brunning at 04:04 PM | Permalink | Comments (2)
I Rule!

Robocode is a blast, but I've been having trouble getting a robot which does even the simplest things. I wanted to code up, just to give myself a starting point, a 'bot which can circle around a given point, but my trigonometry wasn't up to it. :-(

Besides, I'm more into strategy games than I am into shoot-'em-ups, so perhaps CodeRuler will be more my speed...

See Conquer medieval kingdoms with CodeRuler.

Posted by Simon Brunning at 03:51 PM | Permalink | Comments (1)
Fail Fast

This one's for the team: Null is bad.

Null is bad because it allows errors to float around the system for quite some time before you get any symptoms (like bloody logging code falling over), and well behaved code fails fast, near the source of the problem. Mike gives some other nice examples of fail-fast code, like building stub test cases containing a single Assert.fail("Test not yet implemeted."), so you can't forget to build the test case, and having unimplemented methods in your mock objects throw runtime exceptions, so it's obvious if they get called.

Posted by Simon Brunning at 03:21 PM | Permalink | Comments (3)
July 01, 2004
JSTL and instanceof

I'm working on a JSP page. I'm using JSTL's c:forEach to iterate through a collection, and I want to display each item.

Thing is, the collection is heterogeneous; that is to say, it contains objects of different types. Each object might be a String, in which case I want to show it as-is. It night be a Date, in which case I want to use JSTL's fmt:formatDate tag to format it for me. Lastly, it might be a BigDecimal which again I'll want to format, this time using fmt:formatNumber.

The question is, how can I tell what type of object I have? JSTL's EL seems to lack an instanceof operator. Will I have to write my own taglib for this?

Posted by Simon Brunning at 02:33 PM | Permalink | Comments (7)
June 28, 2004
A Groovey Java meetup

London Java Meetup - 12 July 2004. This meetup's topic is Groovy, James Strachan's dynamic language for the JVM. I've had my say on this before - what does it have that Jython doesn't have? The main answer seems to be that Groovy has a Java-like syntax. Since I prefer Python's syntax, this isn't a big win for me. ;-)

Groovy's other big plus points are either shared with Jython (transparent access to the Java API, ability to create real Java classes) or pretty minor (Groovy has closures).

Python offers me the advantage that I can use (pretty much) the same language for COM scripting, Windows API madness, you name it. Can't do these with Groovy!

Anyway, as I said last time, I like the people, and we never manage to stay on-topic anyway, so I'll be there.

Oh, and a big thanks to Jez for organising these.

Posted by Simon Brunning at 10:50 AM | Permalink | Comments (3)
June 23, 2004
JSP 2.0

ONJava is running a nice series of articles on JSP 2.0 (as supported by Tomcat 5.x): JSP 2.0: The New Deal, Part 1, Part 2, Part 3 and Part 4.

We are still on Tomcat 4.1.x at my shop, and hence on JSP 1.2. But there's a new project coming up soon. I fancy adding AppFuse, Spring, Hibernate, XDoclet and JSP 2.0 to our toolkit this time around....

Also: get shot of your web.xml taglib directives.

Update: Oh yes, I'd like to use the display tag library, too.

Posted by Simon Brunning at 01:42 PM | Permalink | Comments (1)
June 22, 2004
JDBC Drivers for SQL Server

We are using Microsoft's own JDBC Driver for SQL Server. It seemed like the natural thing to do. It's not given us any trouble so far.

If it does, I'll bear jTDS in mind: jTDS is 100% JDBC 2.1 compatible, supporting forward-only and scrollable/updateable ResultSets, multiple concurrent (completely independent) Statements per Connection and implementing all of the DatabaseMetaData and ResultSetMetaData methods. A number of JDBC 3.0 features (such as retrieval of generated keys) are also implemented. It also claims to be the most stable and fastest available complete JDBC driver for SQL Server.

(About using SQL Server in the first place; yes, yes, I know. Not my decision. I registered my dissent, but it was out of my hands.)

Posted by Simon Brunning at 04:40 PM | Permalink | Comments (7)
June 14, 2004
I could really use a beer

And as luck would have it...

Posted by Simon Brunning at 01:38 PM | Permalink | Comments (0)
June 09, 2004
BeanUtils type conversion

Six Sides To A Box - BeanUtils, Digester, and Type Conversion. Useful stuff.

Posted by Simon Brunning at 05:54 PM | Permalink | Comments (2)
5250 fans aren't Luddites

Well, not all of them, anyway. ;-)

One of our biggest recent projects was a new Java front end to an old 5250 green screen application of ours. The majority of users were more than happy with the pretty new front end, but some were not. These users were finding that the GUI slowed them down.

Mouse considered harmful: "Have you ever watched an experineced heads down data entry clerk do thier job? With a green screen system they rarely look at the keyboard and in most cases ignore the screen. They are responding to audible feed back (key press clicks, console beeps, etc) with thier eyes focused on the data to be input. They remember key sequences (press 1, A, down arrow 2 times, F2 to save) to navigate. A mental model of the screens become engrained in thier head. They "SEE" the application in thier head and that vision is updated realtime. They know the system because it's predictable."

What's more, if the 5250 user gets ahead of the system, it doesn't matter - the 'dumb' terminal will just buffer their keystrokes, and play them back when the application is ready for them. So, they can enter data as fast as they can hit the keys.

I heard a story, probably apocryphal, about a salesman trying to sell what IBM calls a 'refacing' tool, and what the rest of the industry calls either a screen-scraper or a 'lipstick-on-a-pig' tool. He demonstrated how easy it was to slap a new front end on the 5250 app. The head of the data entry department then snipped off his mouse with a pair of scissors, and asked him to enter some data. "It costs us a penny every time one of our data entry people takes their hand off the keyboard," he explained.

Anyway, I've implemented a keystroke buffer for a Java app once before, and I know it's pretty much top of our to-do list for our pretty new front end. Perhaps then we can wean the last of our 5250 users onto it...

Via James Robertson.

Posted by Simon Brunning at 01:45 PM | Permalink | Comments (3)
June 07, 2004
A Glimpse of Light

I was back in the office on Friday, and I got to fix a Java bug! (Someone who should have known better had put a bunch of logging code into the application, and he used toString() all over the place, so we were getting superflous NullPointerExceptions.

I'm back on site wading through RPG again today. :-(

Posted by Simon Brunning at 04:52 PM | Permalink | Comments (2)
June 02, 2004
Night of the Living Geeks

London Java Meetup - 14 June 2004.

Since I seem to be turning into a full time RPG programmer these days, I wonder if they'll stop letting me come?

The notional subject for discussion this time is J2EE meets .NET. This isn't especially interesting to me, but since I like the people, and we never manage to stay on-topic for more than a few minutes anyway, I'll not let this put me off. ;-)

Update: Sam might be demoing Naked Objects. Naked Objects looks fairly interesting; it's in its early days, but it might just turn into a Synon/2 for the 21st century.

Update June 14th: It looks like Sam's objects will be remaining fully clothed, unfortunately.

Posted by Simon Brunning at 03:23 PM | Permalink | Comments (0)
Omniscient Debugging

Omniscient Debugging. I find it hard to believe that you can do this - it's just plain black magic so far as I'm concerned. Cool beyond words, though.

Via Moazam.

Posted by Simon Brunning at 03:08 PM | Permalink | Comments (5)
May 28, 2004
Log it all! Mwahahahahahaha!

The artful logger.

Logging settings changes? What a good idea! When it comes to logging, less is not more; less is, in fact, less - more is more.

We use log4j to log everything in sight, with a DailyRollingFileAppender to keep from taking up too much space. We do get some pretty hefty log files, though, so we use Tail for Windows to keep an eye on them in real-time, or Python (what else!) to trawl through them if we are looking for something in particular.

Via Joe Grossberg.

Posted by Simon Brunning at 12:30 PM | Permalink | Comments (3)
JSP 2.0 Tag Files

Creating JSP 2.0 Tag Files

Via Erik.

Posted by Simon Brunning at 12:14 PM | Permalink | Comments (1)
May 27, 2004
Eclipse Tips

Startup Performance, and Semantic highlighting.

Posted by Simon Brunning at 04:43 PM | Permalink | Comments (2)
Find Bugs with FindBugs

FindBugs looks terrifically useful. Shame it doesn't work on RPG, but hey, they can't keep me here for ever.

Can they?

Posted by Simon Brunning at 03:22 PM | Permalink | Comments (1)
May 24, 2004
Eclipse 3.0 M9

Eclipse 3.0 M9 - nice new toys, including code folding. I use jEdit's code folding all the time when coding Python, and it's great. I wonder if I can train them to use the same key bindings...

Posted by Simon Brunning at 01:52 PM | Permalink | Comments (4)
May 20, 2004
There Can Be Only One

Why separate bin and src distributions?

Good point - but I don't want the docs in a seperate download, either. How about having a batteries-included download with all three; binaries, source, and documentation? That's what I want.

If this ends up being really big, you could have a light binary-only download available too.

Posted by Simon Brunning at 01:44 PM | Permalink | Comments (2)
May 19, 2004
Software Patents

Oh, shit: EU votes through software patent changes. This is bad.

Update 21st May: The Computer Weekly coverage is good: European Council approves 'controversial' software patent draft directive.

Via perfect.

Posted by Simon Brunning at 04:02 PM | Permalink | Comments (10)
A Rose By Any Other Name

A rose by any other name might well be bloody confusing. Naming is important. Sam writes about this in The importance of naming. I thought I'd point out Hacknot's fabulous Naming Classes - Do It Once And Do It Right.

Posted by Simon Brunning at 02:04 PM | Permalink | Comments (3)
May 14, 2004
JProbe Freeware

JProbe Freeware now available - get it while it's hot!

Via Javaworld.

Posted by Simon Brunning at 02:11 PM | Permalink | Comments (4)
May 11, 2004
The Nerds are Back in Town

London Java Meetup - 17 May 2004

Posted by Simon Brunning at 12:40 PM | Permalink | Comments (1)
May 06, 2004
Build GUIs with the Eclipse Visual Editor project

I've not built a GUI in Java since I learned about Eclipse's GUI builder - it's been web apps all the way. Still, Build GUIs with the Eclipse Visual Editor project is a good page to keep note of; I'm bound to need to build a GUI again at some point.

Posted by Simon Brunning at 02:05 PM | Permalink | Comments (0)
May 04, 2004
Bray on Jython

Groovy is, uh, groovy, but I still don't see what it brings to the game that Jython doesn't already have. Except, that is, for the Java-like syntax - and since I prefer Python's syntax to Java's, that's not really an advantage. ;-)

I must admit that I was a little concerned that Groovy, flavour of the month that it is, might totally eclipse Jython. Well, I'm glad to see that this isn't happening. If anything, Groovy has refocused people's attention on dynamic languages in general, to Jython's benefit. There've been lots of new high profile Jython articles recently, and now we find Tim Bray, Sun's most famous new employee, bigging up Jython, too.

Alan picked out a good summary: "It’s faster to write software in dynamic languages, and the (real) benefits you get from an anally type-sensitive compiler can be had more cheaply with modern testing disciplines. But the theory doesn’t matter, because the action is in the practice, and a whole lot of programmers out there have noticed that, in practice, they can get the job done quicker in Perl or Python or Ruby or whatever". This is pretty much exactly what Bruce Eckel has said already: Eckel on typing Java and Python.

But Bray does add "The best thing for the Java ecosystem would be for both Jython and Groovy to move along, grow and prosper; there’s plenty of room in here". Quite right.

Posted by Simon Brunning at 01:55 PM | Permalink | Comments (6)
April 29, 2004
Don't Return References to Mutable Objects

Don't Return References to Mutable Objects, says Adam Kolawa.

Absolutely right - but for the wrong reason, I think. The security concerns he cites are not the real problem - as Ted Neward points out, if somebody's running code in your VM, you are already dead. No, the problem with returning references to mutable objects is that it's a pistol. It's all to easy for someone else to hose your object by accident. What's more, if this happens, it's a really hard problem to diagnose. You can look at your classes code all day, and put as many breakpoints in there as you want to, and you'll never see where it goes wrong.

Trust me, I know. ;-)

See also Joshua Bloch's Effective Java (which I can't recommend too highly) and Java Practices: Immutable objects.

This is as pertinant to Python as it is to Java, BTW, as is much of Effective Java.

Posted by Simon Brunning at 01:07 PM | Permalink | Comments (5)
April 26, 2004
Quote of the day

Why Python is better than Java: What it comes down to is not just that Java places too high a cognitive load on the programmer... it's that Java's just a pain in the ass.

You try RPG, mate. ;-)

Posted by Simon Brunning at 04:23 PM | Permalink | Comments (6)
April 23, 2004
jvmstat

There are never performance issues with any of my systems, so I'm not remotely interested in jvmstat. Honest. ;-)

Posted by Simon Brunning at 12:49 PM | Permalink | Comments (2)
April 22, 2004
Getting started with Hibernate and Spring

I've been meaning to look into Hibernate and Spring - they seem to be the Java tools de jour, and I'm assured by some clever people that they are very good. I've just read Object-relation mapping without the container, Develop a transactional persistence layer using Hibernate and Spring, and I think I'm beginning to see the light. Certainly looks a good deal less hastle than coding your own DAOs!

I'm still a bit worried about using LGPL software in the context of a commercial Java application, though...

Posted by Simon Brunning at 12:59 PM | Permalink | Comments (11)
April 21, 2004
End of Jython hiatus

Things are happening in Jython land again. Firstly, there's a new alpha release. It's not ready for the real world yet, it's true, but it's nice to see concrete progress.

Also, there have been a number of Jython related articles and blog postings recently; The Way You Develop Web Applications May Be Wrong, Fun with Jython, Introduction to Jython, Part 1: Java programming made easier and Part 2: Programming essentials, and Simplify Web development with Jython, Spring and Velocity.

Which brings me on to Spring. I'm always a bit suspicious when something looks too good to be true, (after all, why settle for snake-oil then you can have the whole snake,) but Sam assures me that Spring really is as good as it claims to be, so I'm tempted to give it a bash.

Update: A couple more good recent Jython articles: Use Jython to Write Ant Tasks and Learn how to write DB2 JDBC tools in Jython.

Posted by Simon Brunning at 12:32 PM | Permalink | Comments (9)
April 14, 2004
London Java Meetup - 19 Apr 2004

It's Nerd Pride night once again - London Java Meetup - 19 Apr 2004. London based Java nerds shouldn't miss this. Thoroghly bloody nice bunch of chaps.

(Yes, all chaps. Funny that...)

Posted by Simon Brunning at 01:42 PM | Permalink | Comments (5)
Using Digester and BeanUtils

Back in the old days when I was a Java developer (sigh), I made extensive use of several Jakarta Commons packages. Lang and Math are pretty much self explanatory, but I found the BeanUtils and particularly Digester a bit harder to get into. Jason Menard has put together a couple of very nice introductory articles: Touring the Commons - part 1 (discussing BeanUtils) and part 2 (discussing Digester). I wish I'd had these when I was learning my way around these packages!

If you aren't using these packages, take a look. They are all really useful.

The other package that I had to fight my way into was Collections. Any nice tutorials out there for this?

Posted by Simon Brunning at 01:26 PM | Permalink | Comments (1)
Jenny - The Database Code Generator

Back when I was looking at building some Java DAOs, I had a good look around for something which would build them for me. I never found Jenny, which is a pity, because it looks like almost exactly the sort of thing that I was looking for.

Via Gregg Bolinger.

Posted by Simon Brunning at 01:10 PM | Permalink | Comments (1)
April 13, 2004
WinGuiAuto.java

Brian Edwards has put together Java port of winGuiAuto.py. Little does he know that I've been cleaning this up over the last week or so, a version 1.0 release is just days away, and he'll have to do it all over again. Mwahahahahaha!

Seriously, Brian, cool stuff. BTW, you use Coroutine for Java, and say that you are looking for an open source alternative. Well, I gather that there's a Java port of Thomas Heller's fabulous ctypes module in the works: ctypes-java. You might want to take a look.

Also, did you do any of the Python to Java conversion automatically? (It certainly looks like it.) What did you use?

Posted by Simon Brunning at 05:10 PM | Permalink | Comments (6)
A language comparison: postcode splitting in RPG and Python

As you might have guessed from my last post, I've got some postcode parsing to do. The requirement is pretty simple; I have to parse a postcode into an outcode and (optional) incode. The good new is that I don't have to perform any validation - I just have to chop up what I've been provided with in a vaguely intelligent manner. I can't assume much about my import in terms of formatting, i.e. case and embedded spaces. But this isn't the bad news; the bad news is that I have to do it all in RPG. :-(

Nevertheless, I threw a little Python function together to clarify my thinking. I often do this when I'm coding something nasty in Java. It's worthwhile to make sure that the algorithm that I'm using works before grappling with Java, and Python is perfect for this. And given RPG's awkwardness, it's worth prototyping even the simplest algorithm - you don't want to spend all that time cutting code only to find that it doesn't work even in principal!

Anyway, the Python function:

def parse_uk_postcode(postcode):
    postcode = postcode.replace(' ', '').upper()
    if len(postcode) <= 4:
        return postcode, ''
    else:
        return postcode[:-3], postcode[-3:]

(A syntax highlighted version with unit tests here: postcode.py.)

Then I put the RPG version together: postcode.rpg. It's much longer and ugler, but it seems to work.

This is a very tolerant way of dealing with postcodes. It will accept just about anything. In my case, that's what I want; I'm pulling data in from a big SAP database. If that's inaccurate, it's definitively inaccurate. ;-)

In other cases, you might want to validate the postcode. Even here, you have more than one choice. One approach is to make sure that the postcode follows the rules as specified at the Universal Postal Union and the UK Govornment Data Standards Catalogue. I've coded this up: postcode_strict.py. This might even be useful to someone! (I didn't bother with an RPG version of this; I don't need one, and life's too short for writing this kind of thing in RPG if you don't really need it.) The other approach would be to validate against a list, should you have one. Duncan Gough steered me towards Brainstorm's downlaodable postcode lists, but these contain outcodes only.

Oh, BTW, any suggested improvements to any of these functions in any of these languages would be gratefully recieved, as would Java versions for comparison.

Update 14th April: Alan Green's done a Java version of the simple version. Thanks, Alan!

Also, I've spotted a bug in the strict version, which I'll fix at lunchtime. Basically, I'm using the list of characters valid at the 4th position to check characters at both the 3rd and 4th positions. This is incorrect; there's a different list of valid characters for the 3rd position. :-(

Another update 14th April: It's fixed, it works now, and I've even added a docstring or two. Look at postcode.py, or download a zip file containing postcode.py.

Posted by Simon Brunning at 04:57 PM | Permalink | Comments (18)
April 05, 2004
Eckel on typing Java and Python

Bruce Eckel (of Thinking in Java fame) has been posting recently on his increasing disillusionment with Java's typing scheme, and how's he's finding that what he calls "Latent" typing is better, in practice if not in theory. (Eckel's "Latent" typing is what a Pythoneer would probably call "Dynamic" typing and a Ruby-head "Duck" typing.) The whole set of posts are worth a read: Generics Aren't, About Latent Typing, How to Argue about Typing and I'm Over It.

Posted by Simon Brunning at 02:10 PM | Permalink | Comments (2)
March 30, 2004
Why Do Java Developers Like to Make Things So Hard?

Why Do Java Developers Like to Make Things So Hard?

"Imagine if the Perl cafe and Javahut were across the street from each other. You walk into Javahut, and ask to sit down. "I'm sorry," says the person at the door. I'm not actually the hostess, I'm a Factory class that can give you a hostess if you tell me what type of seat you want." You say you want a non-smoking seat, and the person calls over a NonSmokingSeatHostess. The hostess takes you to your seat, and asks if you'll want breakfast, lunch, or dinner. You say lunch, and she beckons a LunchWaitress. The LunchWaitress takes your order, brings over your food, but there's no plates to put it on because you forgot to get a CutleryFactory and invoke getPlates, so the Waitress throws a null pointer exception and you get thrown out of the place."

This is so true it hurts.

Still, could be worse. Working with RPGIV, there are no restaurants. Nor are there any supermarkets; you have to grow your own food. And make your own cutlery.

Via Ian Bicking.

Posted by Simon Brunning at 01:06 PM | Permalink | Comments (12)
March 22, 2004
Karmic feedback

I'm getting a spot of Karmic feedback for taking the piss out of Mark for his burger flipping VB6 programming - I'm starting on a six week RPGIV project at a client site next week!

This is bad: in decreasing order of love, my used-at-work programming languages are:

As you can see, RPGIV isn't high on the list. Sigh.

Still, I'll be working with one or two people I know and like, so it isn't all bad.

Posted by Simon Brunning at 04:29 PM | Permalink | Comments (9)
March 19, 2004
JSTL Quick Reference

Bill Siggelkow of Jade Cove Solutions has written a superb JSTL quick reference (PDF).

Combined with IBM developerWorks' A JSTL primer; Part 1: The expression language, Part 2: Getting down to the core, Part 3: Presentation is everything and Part 4: Accessing SQL and XML content, it's all the JSTL documentation you'll ever need.

Posted by Simon Brunning at 12:43 PM | Permalink | Comments (6)
March 16, 2004
megg

Jez had a nice little thingamajig to show off last night - megg, sorry, megg. "megg is a tool for lazy developers" - that's me!

Basically, it builds Java projects for you, including ant build files, template tests, and so on. It's similar in intent to AppFuse, but much simpler.

Posted by Simon Brunning at 01:40 PM | Permalink | Comments (2)
I, Robot

Last night's London Java Meetup was great fun. Robocode is a blast, and StaggerLee.java will definitely be making an appearance at the next event. I've already got a few ideas for strategy...

One of the high points of the evening for me was the code for Jez's robot, LNE - and specifically the fact that the member variable for his robot was called i. I Am Robot - geddit?

How nerdy am I? Sigh...

BTW, RoboWiki looks like a very interesting site to pick up some advanced Robocode ideas - but I'll put StaggerLee.java version 1.0 together on my own first.

Posted by Simon Brunning at 01:26 PM | Permalink | Comments (2)
March 15, 2004
London Java Meetup

There's a London Java Meetup this evening. Be there, or be square. Or quite possibly, both.

Could be a fun one tonight - it's Robot Wars night!

Posted by Simon Brunning at 11:09 AM | Permalink | Comments (1)
February 27, 2004
DAO testing

A good indication of when you are really starting to get to grips with a subject, I find, is when you start to know the right questions to ask. (Knowing the answers to these questions comes much later. That's expertise.) Once you are at this point, you can really start to take off: if only because once at this point, Google can usually help you out.

Well, when it comes to JNDI, I'm nowhere near this point. I'm out of my depth here, and I know it.

I'm putting together the unit tests for my DAOs. (Yes, yes, I know I should have written the tests before writing the DAOs themselves. Let's face it; I'm a bloody amateur.) The DAOs get their connections from a pool, like so. This clearly isn't going to work in my unit tests unless I sort out the context stuff beforehand - and I haven't a clue how to do this. Putting together a harness DataSource is trivial. It's the InitialContext and Context stuff that I don't understand.

I came across Using mock naming contexts for testing by Simon Brown, which looks like it ought to get me going - but my brain just isn't making the leap. Sigh.

(Simon's a lovely chap, BTW. I've met him a couple of times at the London Java Meetups.)

Posted by Simon Brunning at 01:47 PM | Permalink | Comments (13)
February 24, 2004
Locating the configuration files for my J2EE app

Arrrrrgh! I just can't believe that this is hard! (Or perhaps it's just me that finds this hard. That's not so difficult to believe.)

OK, so, the J2EE application we are working on needs some configuration, so I've monkied up a quick Digester based configuration file reader. That should have been the hard bit, but it's been a piece of cake. Digester is great!

But now I need to get it to read the configuration file from within my J2EE application. So where do I put this file, and how do I tell Tomcat (or whatever) where to look for it?

I've currently got this file in WEB-INF/config.xml, which feels right. But Tomcat can't find it given just this as a file path. I suppose that I need to prepend the document root to this - but how do I find that? (I'm currently trying to read this file in a ServletContextListener's contextInitialized method.)

Naturally, I'd rather not use anything Tomcat specific if I can help it. But I did try this:

final ProxyDirContext proxyDirContext = (ProxyDirContext) servletContext.getAttribute("org.apache.catalina.resources");
final String docBase = proxyDirContext.getDocBase();

But unluckily (or perhaps luckily) this didn't work. It *would* work from a Servlet, I think, but the org.apache.catalina.resources context attribute doesn't seem to exist as the context is initialised.

Arrrrrgh!

Posted by Simon Brunning at 12:49 PM | Permalink | Comments (9)
February 19, 2004
DAO coding

I've spend some time recently putting together the DAOs for my project. Quite some time, in fact. God, they are ugly.

The Transfer Objects, the ones that ones that you end up using outside the persistence layer, seem usually to be coded as beans. So, the class which builds these objects has to set a bunch of properties:

principal.setPrincipalName(result.getString("PrincipalName"));
principal.setAddress1(result.getString("PrincipalAddress1"));
principal.setAddress2(result.getString("PrincipalAddress2"));
principal.setAddress3(result.getString("PrincipalAddress3"));
principal.setAddress4(result.getString("PrincipalAddress4"));
principal.setAddress5(result.getString("PrincipalAddress5"));
principal.setPostCode(result.getString("PostCode"));
principal.setContactName(result.getString("ContactName"));
principal.setContactPosition(result.getString("ContactPosition"));
principal.setTelephoneNo(result.getString("TelephoneNo"));
principal.setFax(result.getString("Fax"));
principal.setEmail(result.getString("Email"));
principal.setPredominantCurrency( result.getString("PredominantCurrency"));

There are similar (but not identical) bits of code all through this class; binding parameters into various bits of SQL, that sort of thing:

final String sql =
    "select "
        + StringUtils.join(MSSqlPrincipalDAO.FIELDS, ", ")
        + " "
        + "from "
        + MSSqlPrincipalDAO.TABLE
        + " "
        + "where "
        + StringUtils.join(MSSqlPrincipalDAO.KEYS, " = ? " + "and ")
        + " = ? ";
final PreparedStatement statement = connection.prepareStatement(sql);
statement.setString(1, principal.getPrincipalNumber());
statement.setString(2, principal.getPrincipalSequence());

To my Python-educated eye, this looks hideous. The field names are repeated all over the place, and putting them into constants isn't any better. The bean-property to SQL column mapping is also repeated several times - very error prone. But in Java, I can't think of a cleaner, less repetitive way of doing it. Am I missing something super-elegant?

Building the Transfer Objects as Maps would be a lot prettier, I know. But then using them would be a bit painful, so I don't want to do that. :-(

Another question; I went through this code replacing all the SQL construction literals (like "select ", for example) with constants. But it seemed to me that this made the code less readable, and no more maintainable. So I'm leaving the literals in. Will the code-police be able to make a good case against me?

BTW, clearly these DAOs could be generated automatically. Are there any good tools for this? (Other than sql2java, which I've tried; I can't get it to work.) If not, I think I feel some Python coming on...

Posted by Simon Brunning at 02:06 PM | Permalink | Comments (19)
Taking exception to Exceptions

Families. Can't live with them, can't legally kill them.

That's exactly how I feel about a lot of Exceptions; can't do anything about them, can't ignore them.

NamingExceptions, for example:

public static Connection getConnection(){
    try {
        Context context =(Context) new InitialContext().lookup("java:comp/env");
        DataSource dataSource = (DataSource) context.lookup("jdbc/FooBar");
        Connection connection = dataSource.getConnection();
        return connection;
    } catch (NamingException namingException) {
        log.fatal(namingException);
        throw new RuntimeException(namingException);
    } catch (SQLException sqlException) {
        log.fatal(sqlException);
        throw new RuntimeException(sqlException);
    }
}

If anything goes wrong here, then my whole application is probably hosed. So, I'm following the Bruce Eckel approach; don't throw errors if your client code has no hope of doing anything to recover. Is there anything more sensible that I can do?

Posted by Simon Brunning at 01:26 PM | Permalink | Comments (7)
February 17, 2004
JSTL resources

I'm having mixed feelings about JSTL. In many ways, it's really nice. But it's a bugger to debug. And I've had trouble locating good docs.

Here's what I've found:

Is there any good stuff I'm missing?

BTW, one of the tings that I like about JSTL is that any class implementing the java.util.Map interface can have its attributes referenced by EL's dot operator. Nice.

Posted by Simon Brunning at 01:40 PM | Permalink | Comments (2)
London Java Meetup

Cameron has some nice pictures of last night's London Java Meetup.

I enjoyed myself very much. It's good to get together with a like-minded bunch of nerds and really geek-out. "Hi" to everyone I meet last night. I'm not going to name names, because I'm dreadful at remembering them, so I've forgotten half of them.;-)

It appears that I'm not going too far wrong with my noddy MVC implementation. I'm not leaving anything out that I haven't already realised that I'm leaving out, nor done anything wrong that I've not already realised that I'm doing wrong.

Posted by Simon Brunning at 10:32 AM | Permalink | Comments (5)
February 16, 2004
London Java Meetup tonight

London Java Meetup tonight - see you there!

Posted by Simon Brunning at 12:08 PM | Permalink | Comments (0)
Wanted: Knoppix with Tomcat

Is there a Knoppix-like live CD available which auto-starts Tomcat? (Preferably one which is fairly easily customised by the dim-witted, such as myself.)

Posted by Simon Brunning at 11:07 AM | Permalink | Comments (6)
February 12, 2004
HTTP Compression for Servlets

Via boncey.org, a fab little little Servlet Filter trick in Two Servlet Filters Every Web Application Should Have.

Posted by Simon Brunning at 03:15 PM | Permalink | Comments (2)
PDF generation

Scope creep; it'll get you every time.

An important part of the system that I'm currently working on is a financial statement. This needs to be printable, and to look good when printed. To begin with, I was confident that CSS styled HTML would do the necessary. But now I find that we need this statement to look exactly the same as the paper one that users currently get, including things like fonts and the location of page breaks. Also, the client now wants cross referencing; "See page 12 for a breakdown", that kind of thing. So, HTML ain't gonna cut it, CSS or no CSS. Sigh.

Naturally at this point, we looked at PDF. We can do all the above and more with PDF. But how to generate it?

Generating PDF is nothing like generating HTML. It's a binary format with all sorts of indexing and cross referencing. You can't just use a template tool like JSP or Velocity. (In fact, it's a sort of wrapped and compressed Postscript. Postscript is actually an executable format.) So, we need a tool to generate our PDF for us. (The tool doesn't have to be for Java/J2EE, though that would help.)

Naturally, I looked at Reportlab. Their RML2PDF tool is exactly what we are looking for; we could easily generate the required RML (an XML dialect) file from a JSP. But, look at the price! RML2PDF is simply way beyond our budget. Sorry, Andy. :-(

Some of the other commercial offerings are rather a lot cheaper. Style Report, for instance, can be driven from Java objects or direct from SQL, and includes a JSP taglib, so it would fit right into our current architecture. Mark is evaluating tis product, along with ReportMill, Formula One e.Report and Crystal Reports. If anyone has used any of these, please let us know how it went!

On the OSS front, iText looked promising, but we aren't allowed GPL software on our products. (No, not even LGPL software; its meaning is ambiguous in the context of a Java application, and we don't intend taking any risks.) The other OSS tools either had the same license issues, or were at too low a level, or both.

So, what does everyone else use?

Posted by Simon Brunning at 03:06 PM | Permalink | Comments (22)
February 10, 2004
MVC the noddy way

Speaking of our noddy MVC framework, it's all coming together now.

The bleedin' obvious stuff: we have a Controller servlet, to which all *.command URLs map. The Controller loads up a Map when it starts up, mapping URLs to Actions. An Action consists mainly of a class implementing an interface; ControllerAction. The Controller instantiates this class, and calls its doAction() method. The request and response objects are passed into this method, giving the Action access to everything that it needs.

So far, so good. But this is where is starts to get a little complex. What happens next?

We need to redirect (or forward) the client on to the View, usually a JSP, at this point. But we'll need to pass some information from the Action to the View. How do we do this? We are just returning a ControllerActionResult object from our ControllerAction.doAction() method, and stuffing this into our session. This is working so far, but I'm worried.

Also, to which View should we redirect? Initially, we were just going to keep this in the Controller's Action mapping, but of course, you might want to redirect to different JSPs depending on what the Action thinks. Do you just have a fixed number of potential target Views? Say, one for a successful Action, another for a used error, and another for an unexpected error? What if you need more options than this?

At the moment, our ControllerAction.doAction() method is passing back the target View as an attribute of the ControllerActionResult object, and we redirect according to this. This works OK, but will it scale?

Oh, BTW, we have decided that we will use JSTL's SQL taglib to present our financial data. To our application, it really is just a bunch of numbers, so building a Model is just unnecessary work. YAGNI. ;-)

Posted by Simon Brunning at 04:45 PM | Permalink | Comments (5)
London Java Meetup

There'a another London Java Meetup on the 16th. I'll be there, boring everyone to tears, talking about my noddy MVC stuff, JSTL, and, err, drinking beer.

Remember: it's newbie friendly!

Posted by Simon Brunning at 04:25 PM | Permalink | Comments (3)
February 06, 2004
What's wrong with J2EE

Mike Clark and Glenn Vanderburg have been pondering J2EE's complexity.

Now, I've been buried up to my neck in J2EE for a while now, and from this position it's easy to loose sight of the big picture. We are using lots of neat toys, each of which helps me out in one way or another, so I'm happy to have them. Since they really do all help, I'm right to be happy.

El Presidente, though, looks upon this huge list with more than a little trepidation. And he's right too; we are using a lot of tools, many of which are fairly complex. By rights, our project is a fairly simple one. What do we need all this stuff for? (And we've kept the list as short as we comfortably can, believe me!)

Well, J2EE is at least part of the problem. A simple 'Hello World' application isn't, well, simple in J2EE. Servlets, JSPs, the deployment descriptor, the WAR file, the context, and so on.

You might argue that this is because J2EE isn't designed for simple applications. And you'd be right; it's designed for complex applications; it scales well. This is true up to a point. But. But if it scaled that well, we wouldn't need all this other stuff, would we? (An MVC framework, a persistence layer, additional taglibs, etc, etc, etc.)

(OK, so, I know that J2EE has its own persistence layer: EJBs. But I've been warned off them so many times I didn't even consider them. Also, The new JSP 2.0 includes the JSTL, removing much of the need for external taglibs.)

But the other side of the problem is Java itself. I think that at heart, Glenn has it right. Java is not amenable to extension, and J2EE extends it well beyond what ESR refers to as its 'functional envelope'.

Python doesn't have a J2EE, but if it did, I suspect that it would be far simpler.

Still, I can't say I'm not having fun with all this stuff, so it isn't all bad. ;-)

Posted by Simon Brunning at 02:01 PM | Permalink | Comments (5)
February 05, 2004
Log4j and J2EE

I've not used log4j in anger before. Now I am, and I must say; it rocks. simple and powerful.

One question, though. Where should you put your log4j.properties file? The usual place seems to be in your /WEB-INF/classes directory, but I have two problems with that.

Firstly, it's not a damn class. OK, OK, I should probably just get over that one - /WEB-INF/classes is your basic runtime class path, whatever it may be called.

Secondly, and more seriously; if you ship your application as a WAR file, you can't get at it to edit it, which is a real problem.

Any suggestions?

Posted by Simon Brunning at 12:45 PM | Permalink | Comments (16)
February 03, 2004
DBTags

Sigh. I was just about to mention how cool and useful the DBTags tag library is, when I find that it's deprecated, and that I should be using the JSTL instead. Bugger.

The JSTL is implemented by Jakarta.

Posted by Simon Brunning at 10:36 AM | Permalink | Comments (7)
January 28, 2004
Busy busy busy...

Phew, it's been a busy few days!

We've now come up with an architecture for our system, so I'll be spending the next couple of days implementing and prototyping it.

We've decided against Struts; instead, we'll be implementing a form of 'MVC lite', using a command servlet to control flow. (Yes, yes, I know, reinventing the wheel. It wasn't my decision.) And we'll use a Filter for our authentication. No cookies allowed, so I'll be putting together a taglib to do our URL re-writing for our session tracking.

Our toolkit:

Java SDK 1.4.2
Ant 1.6
Cactus 1.5
Checkstyle 3.3
Eclipse 2.1.2
J2EE JDBC 3.0
J2EE JSPs 1.2
J2EE servlets 2.3
Jakarta.commons various
Jakarta.taglib various
jEdit 4.2 pre 8
jUnit 3.8.1
log4j 1.2.8
PMD 1.4
Tomcat 4.1.29

We'll be generating XHTML, and formatting with CSS, naturally. ;-)

Not everything that I'd wanted, but not too bad, either.

Posted by Simon Brunning at 05:08 PM | Permalink | Comments (6)
January 23, 2004
Thanks

Thanks to everyone who gave me advice yesterday on the toolset that I should use for a new from-the-ground-up J2EE system. Now for the meetings...

I'll let you know what we end up with.

Posted by Simon Brunning at 01:21 PM | Permalink | Comments (2)
January 22, 2004
Logging

Given that we are starting a brand new project with Java 1.4, is there any reason to prefer log4j or commons-logging over java.util.logging?

Posted by Simon Brunning at 05:50 PM | Permalink | Comments (6)
Checkstyle or PMD?

Err, that's it, really; Checkstyle, or PMD, or both? Or is there anything else in this area that I should take a look at?

Posted by Simon Brunning at 05:15 PM | Permalink | Comments (4)
The London Java Meetups

It's worth pointing out that the London Java Meetups aren't just for gurus; there are many gurus there, certainly, but Steve and I found that they are very clueless-newbie friendly.

You can learn an awful lot talking to the experts, and besides, they are a thoroughly nice bunch of lads, and it's a pleasure to drink with them.

But a 7:30 breakfast meetup? I'm not sure that even I'm that keen!

Posted by Simon Brunning at 04:48 PM | Permalink | Comments (1)
J2EE done right

I've got a new work project, and I'm pretty excited about it. We are to build a J2EE web application. We've got a few of these floating around, but this one is to be done from scratch, and it's been made clear that it's to be done right - no cutting of corners whatsoever.

Music to my ears. ;-)

Our existing projects all either date from back when we really didn't know what we were doing, or are based on them. Our unit tests are patchy at best, our build files are nasty shell scripts with the odd Python script thrown in, deployment is totally manual, wheel-reinvention is rife, you name it. Everything works, but you wouldn't want to start from here.

Not this time.

The toolset I'm thinking of recommending:

You'll note that I'm shooting for current best practice rather than cutting edge here; hence Ant rather than Maven, Struts rather than WebWork, for example. Is there anything that should be on this list that isn't? Anything that is on the list that shouldn't be?

Posted by Simon Brunning at 11:48 AM | Permalink | Comments (23)
January 06, 2004
hsqldb

Jez posted a nice little toy today - box: monitoring RSS/RDF feeds via email/SMS. Since I don't have access to an email/SMS gateway, this isn't really that useful to me. Besides, I subscribe to far too many feeds - I'd be getting hundreds of messages a day! But I can see tremendous use in various parts of this gadget.

Indeed, between the tool itself and Jez's follow up comments, I've learned a couple of useful things. Firstly I'd not heard of hsqldb. It's a fast, lightweight, pure Java RDBMS, a bit like Python's Gadfly.

And secondly, now I know how to tell Java about my firewall - see Write Java apps that work with proxy-based firewalls.

Thanks, Jez!

Posted by Simon Brunning at 12:48 PM | Permalink | Comments (3)
December 18, 2003
Velocity

Velocity: Fast Track to Templating is a nice introduction to the Velocity templating engine.

(See also Start up the Velocity Template Engine, another Velocity tutorial article.)

Posted by Simon Brunning at 03:02 PM | Permalink | Comments (3)
December 16, 2003
Shhhh!

I'm a bear with a sore head this morning. I got caught between Steve and Red Stripe.

Last night's Java meet was good. The Java guys are all very enthusiastic, which is great. And very young.

Jeremy is a thoroughly bloody nice chap, I must say. I've found that he's got good reason for getting up so bloody early - he's not mad after all. We also seem to have arranged reciprocal lunchtime curries, one at hos local, and one at mine.

Sam is a very clever young chap, I must say. I managed to keep up with most of what we was saying, though. I think. I'm not so sure about Steve, though.

Later in the evening, I had a good chat with James Strachan about Groovey and Jython. I was wittering on about the difference between syntax and semantics, but I don't think I got my point across. I suspect that this is because I was almost totally incoherent by this stage.

There were too many people there for me to retain everyone's name, I'm afraid, what with my crap memory and the Red Stripe. So if I spoke to you and haven't mentioned it, that's why. ;-)

I'll certainly go again. A nice bunch of blokes.

Posted by Simon Brunning at 10:48 AM | Permalink | Comments (7)
December 15, 2003
Open Source Profilers for Java

Open Source Profilers for Java. Useful.

Err, useful to other people, that is - my code always performs adequately the first time. Honest. ;-)

Posted by Simon Brunning at 03:30 PM | Permalink | Comments (0)
London Java Meetup

Don't forget the London Java Meetup this evening.

There should hopefully be a few people whose blogs I read there - Steve, Sam, Cal, and James, for a start off.

Posted by Simon Brunning at 02:12 PM | Permalink | Comments (7)
November 28, 2003
London Java Meetup

London Java Meetup - Xmas Party 2003, 15th Dec 2003. I'm not too sure about this Electricity Showrooms place, and I hope I don't end up fist-fighting the Perl mongers, but I'll be there. It'll be interesting to meet Sam, if nothing else.

Posted by Simon Brunning at 10:31 AM | Permalink | Comments (5)
November 24, 2003
Eclipse 3.0 M5

Eclipse 3.0 M5 - New and Noteworthy

More fabulous refactorings: Generalize Type and Introduce Factory. Amongst other things.

Posted by Simon Brunning at 09:56 AM | Permalink | Comments (1)
November 18, 2003
GUI builder for Eclipse

The Eclipse Visual Editor Project has been announced. Building GUIs by hand is a pain in the arse, so this might be nice to have. Except that virtually all my Java is server side these days - web applications rule.

Still, nice to know it's there. We do have Java desktop apps here, and they may well need to grow new dialogs at some point. It'll be interesting to see how layout managers are handled...

Update: Via mgc - a flash demo of the Eclipse Visual Editor. Looks really nice...

Via Newsforge.

Posted by Simon Brunning at 10:08 AM | Permalink | Comments (3)
November 17, 2003
Jython taglib

The Jython taglib allows you to embed Jython code in your JSPs. I'm not suggesting that this is a good idea, but it's there if you want it. ;-)

Posted by Simon Brunning at 03:57 PM | Permalink | Comments (1)
November 07, 2003
Code Kata

Steve's just about getting to the end of Head First Java now. (Which, BTW, he recommends.) He's going to work through Thinking In Java next, which I recommend.

But I've also advised him not to stick too closely to book learning. The best thing to do, I find, is dive off onto real coding whenever you have an idea for something to write. Do as much as you can, then and when you get stuck, go back to the books until you have another brain wave.

Robocode is great for this, if you are learning Java. You can write a simple robot very quickly, but the sky's the limit - as you work through the books, you'll get ideas for all sorts of clever things that you can do.

Another good source of ideas are Dave Thomas's Code Kata. Not just good for newbies, these coding exercises are good practise for anyone. I see Andy and Ian have been using them. I may have a go myself!

Posted by Simon Brunning at 01:54 PM | Permalink | Comments (3)
November 06, 2003
Very Quick Wiki

Very Quick Wiki, a J2EE Wiki.

Via Near to the Barking Seals.

Posted by Simon Brunning at 02:51 PM | Permalink | Comments (0)
Garbage collection

Java theory and practice: A brief history of garbage collection. A good, high-level overview of the subject.

Posted by Simon Brunning at 02:42 PM | Permalink | Comments (2)
JTShut

Is anyone else unable to download JTOpen at the moment, or is is just me? I've been trying on and off for a week or so now...

Posted by Simon Brunning at 01:48 PM | Permalink | Comments (0)
October 13, 2003
Eclipse M4

New Java refactoring goodness in Eclipse M4.

Via Ted.

Posted by Simon Brunning at 12:50 PM | Permalink | Comments (0)
October 08, 2003
Web applications rule the enterprise

Developers show their independent streak, favoring Web-based apps

Actually, legacy applications in COBOL and RPG rule the enterprise in my experience. But in terms of new enterprise applications, I can certainly believe that web based applications are very popular. The advantages are huge, provided that you don't need any UI that a browser based app can't give you. (And as this DHTML widget shows, a browser can give you more than you might expect.)

Posted by Simon Brunning at 02:00 PM | Permalink | Comments (3)
September 25, 2003
Failure and Exceptions

In Failure and Exceptions, James Gosling argues the case for checked exceptions. (Bruce Eckel makes the opposite case in Does Java need Checked Exceptions?).

Gosling's argument seems weak to me. He claims that it's impossible to test every circumstance, especially the unexpected, (which is true), and that exceptions can keep a program working in the face of this. Well, checked exceptions can keep a program from falling over, but that's not the same thing as keeping it working. I'd prefer a program to fall over than for it to keep on truckin', writing crap to a database. This has happened to all of us, I'd imagine, and a clean failure is far preferable.

Besides, in the real world, there often isn't anything you can do in the face of many exceptions, but the compiler insists that you have a catch block for them somewhere anyway. The number of times I've seen them empty...

The workaround in Bruce Eckel's article works fine, but I'd rather have the choice as to how to deal with exceptions, as Python gives me.

Posted by Simon Brunning at 12:38 PM | Permalink | Comments (4)
Pretty Eclipse pictures

I have no idea whether the Creole plug in for Eclipse is actually any use, 'cos it's not available for download yet. But it looks as cool as fuck, I must say, and who's to say that isn't as important as actual utility, eh?

Via Real Life, beta version.

Posted by Simon Brunning at 09:36 AM | Permalink | Comments (4)
September 22, 2003
Java Idioms

Thanks to V S Babu, I found this great Java Idioms page.

There's enough here for a thousand posts. Well, five or six, anyway. ;-)

For starters, see Immutable Value for a good explanation of why value objects should always be immutable, Use Factories To Build Objects to see how and why to avoid the new keyword, Build Interface Implementation Pairs to see how to use interfaces everywhere, and No Null Beyond Method Scope to see how to put an end to those pesky NullPointerExceptions (or at least to make them occur near the source of the problem).

Posted by Simon Brunning at 02:00 PM | Permalink | Comments (0)
Programming Fonts

Most developers spend a huge amount of time looking at code. Obviously, the quality of your VDU is very important, but it's also important to use a good font.

Obviously, you're going to use a non-proportional font for coding. As a Windows victim user, you get a couple by default. Courier New is just too hideous to contemplate. Lucida Console is better, but both these fonts have one big defect in common - it's hard to distinguish between zeros and upper case letter 'o's. Me, I prefer Andale Mono. (You can download Andale Mono here.)

Ned Batchelder points out Tristan Grimmer's programming fonts. Proggy Clean especially looks really nice for day to day code and text editing. Proggy Tiny, is, well, a bit too tiny for editing with, but it might make a good console font. I'll give them a try.

Update: I've had a look, and I think I'll be sticking with Andale for the moment, though Proggy Clean is almost as nice - it just takes up that tiny bit more room. Some samples: Andale Mono, Proggy Clean, and (for Hans) FixedSys.

(BTW, this code snippet arose because a colleague was struggling using a text editor to open a 1.2 gig log file in order to find all the lines containing a specific exception. A slight variation on this code pulled out the required lines, and took 13 minutes on an oldish PC. Another Python convert, I hope!)


Another update: V S Babu mentions Bitstream Vera in passing. There's a non-proportional font in there which looks pretty nice. An example - Bitstream Vera Sans Mono. But again, I think I'll stick with Andale.

Posted by Simon Brunning at 10:37 AM | Permalink | Comments (14)
September 12, 2003
Groovy, man

James Strachan is working on a new dynamically typed scripting language for the Java platform, Groovy.

I can't say that I understand James' motivation here. Why not just use Jython? Jython's quite behind Python though it is the closest to what I want right now, he says. It's true that the most recent Jython release is equivalent to C Python 2.1, two major releases old. But Python 2.1 was great - it's just that Python 2.3 is better. What does he want that Jython doesn't deliver?

Now, J*, that was a good idea.

Posted by Simon Brunning at 11:12 AM | Permalink | Comments (3)
September 11, 2003
Java refactoring with Eclipse

Eclipse sports a number of automatic refactorings, many of which I use regularly, and some of which I probably ought to use regularly. Refactoring for everyone - How and why to use Eclipse's automated refactoring features is a good intro for anyone who isn't familiar with them.

Is there anything like this for Python? I've not seen anything working. Bicycle Repair Man! doesn't look ready yet.

Posted by Simon Brunning at 05:23 PM | Permalink | Comments (2)
September 08, 2003
A rose by any other other name...

... would smell as sweet.

Eclipse may take new name after reorganization, basically because the name pisses Sun off, and so they don't want to join the Eclipse consortium unless it's changed.

Thing is, while I have no reason to object to Sun joining the Eclipse team, I'm not sure what the advantage is, either. So why should Eclipse bend over backwards for Sun, and loose the recognition factor which Eclipse has earned over the last couple of years?

Via architectslobby.

Posted by Simon Brunning at 11:56 AM | Permalink | Comments (3)
Getter and setter methods are evil

Why getter and setter methods are evil explains, uh, why getter and setter methods are evil. Don't ask for the information you need to do the work; ask the object that has the information to do the work for you, it advises.

I hadn't really thought about this, but it strikes me as good advice. Looking through my own code, I see almost no simple setter methods, and few getters. I do use 'is' type getters fairly frequently, though. This feels OK to me.

This isn't the same thing as Python's reason for avoiding getters and setters, BTW. Python's descriptors mean that you can directly access object attributes without breaking encapsulation, making getters and setters very un-Pythonic.

Update September 9th: Having thought about this overnight, I'm a little concerned that this might be a bit too purist, a bit too principle of least privilege. Yes, so long as the designer of the class has anticipated every need that a client of the class might have, it's better to encapsulate firmly, and to prevent anything unanticipated from happening. In the real world, the designer hasn't thought of everything.

Have you ever raged that a method or attribute that you need to access has been marked private, because the designer of the class that you are using didn't anticipate your every need? I know I have.

Still, the designer should provide a named method for everything for which he/she does anticipate a need. Access to an object's attributes, be it via setters and getters. or directly, strikes me as a code smell.

Posted by Simon Brunning at 11:03 AM | Permalink | Comments (2)
September 05, 2003
Sun joining the Eclipse consortium?

Sun Mulls Joining Java Eclipse Effort

Better late than never, I suppose, but what they will bring to the party at this late stage I don't know.

Posted by Simon Brunning at 02:54 PM | Permalink | Comments (1)
August 21, 2003
Test versus Type

Oliver Steele's excellent post, Test versus Type, explores at some length the argument that test driven development makes static typing unnecessary at best, positively injurious at worst.

I leave with you with a quotation from Quinn Dunkan:

"The static people talk about rigorously enforced interfaces, correctness proofs, contracts, etc. The dynamic people talk about rigorously enforced testing and say that types only catch a small portion of possible errors. The static people retort that they don't trust tests to cover everything or not have bugs and why write tests for stuff the compiler should test for you, so you shouldn't rely on only tests, and besides static types don't catch a small portion, but a large portion of errors. The dynamic people say no program or test is perfect and static typing is not worth the cost in language complexity and design difficulty for the gain in eliminating a few tests that would have been easy to write anyway, since static types catch a small portion of errors, not a large portion. The static people say static types don't add that much language complexity, and it's not design "difficulty" but an essential part of the process, and they catch a large portion, not a small portion. The dynamic people say they add enormous complexity, and they catch a small portion, and point out that the static people have bad breath. The static people assert that the dynamic people must be too stupid to cope with a real language and rigorous requirements, and are ugly besides.

This is when both sides start throwing rocks."

Via Ted Leung.

Posted by Simon Brunning at 11:27 AM | Permalink | Comments (0)
August 19, 2003
Python - just say NO!

Java Programmers Unite: Say NO To Python

Jokes apart, I don't think that increasing programmer productivity would increase unemployment, at least not in the long term. I think that part of the problem is that too many company boards have had their fingers burned by large IT projects delivering very poor ROIs. The more IT delivers value for money, the more people will be willing to spend.

At least, that's what I'd like to think. Perhaps we are all doomed.

Posted by Simon Brunning at 01:22 PM | Permalink | Comments (4)
August 13, 2003
Eeek! Scary Java bug

BadMagicNumber's A Java bug worthy of your vote is one very good reason not to use Java 1.4.1. Apparently, one you have 2036 files open, subsequent file opens will actually delete the file that you were trying to open!

Posted by Simon Brunning at 01:37 PM | Permalink | Comments (1)
10 Python pitfalls

Hans Nowak has written an excellent article, 10 Python pitfalls.

Points 2, 3, 7 and 8 apply to Java as well as to Python.

It seems to me that the difference between mutable and immutable objects, which is a crucial one, is not given due prominence in any of the tutorials that I've seen, either for Python or Java.

Update: According to the Java Language Specification, point 3 does not apply to Java, i.e. a = a + b is exactly the same as a += b in all cases. If I'm reading it right, that is. I haven't got time to try this out now, though.

Posted by Simon Brunning at 10:39 AM | Permalink | Comments (3)
August 12, 2003
Processing RSS in Java

Using RSS in JSP pages offers a nice overview of RSS processing in Java.

Now I just have to think of a use for it. ;-)

For RSS processing with Python, see RSS for Python.

Posted by Simon Brunning at 01:56 PM | Permalink | Comments (2)
WebSphere Development Studio Client 5.1

IBM Announces New Release of WDSc, New Software Ships in September.

The new WDSc is based on Eclipse 2.1, which rocks. It's nice to see that IBM are keeping up to date.

The next time I have any iSeries work to do, I'll upgrade.

Posted by Simon Brunning at 11:33 AM | Permalink | Comments (0)
August 01, 2003
Nerd meetings and events in London

NullBlogException posted a list of Meetings and events in London.

I think I'll give one or more of these a bash. The Python booze-ups just ain't happening.

Posted by Simon Brunning at 01:05 PM | Permalink | Comments (1)
July 25, 2003
Java - a Language for the masses?

Java Is a Language for the Masses

Sun do seem a bit nannyish to me. Macros ain't the half of it. What about operator overloading? What about multiple inheritance? Metaclasses? First class functions?

I prefer Python's 'a language for consenting adults' approach.

Posted by Simon Brunning at 01:56 PM | Permalink | Comments (3)
July 24, 2003
Database connection pooling

See Using the Jakarta Commons, Part 3. Lots of cool stuff here, but I'm particularly interested in looking at DBCP, the database connection pool package.

One of my team's apps runs on Tomcat 4.0.x, and we use Tomcat's connection pooling. I'm not sure if it doesn't work how we want it to, or whether we are just using it wrong, but we are having real problems with it. Mainly, the problem is that it seems very keen on throwing connections away. Unless you go to the pool very soon after a connection has been returned, you'll find the pool empty, and have to wait for a new one to be built. Which is, of course, exactly what we are using a pool to avoid. (Note to self - try Evo on Tomcat 4.1.x.)

I also looked into using IBM's AS400JDBCConnectionPool, since it's a '400 that we are trying to get to. But I can't get that going under Tomcat at all.

So, perhaps DBCP is the way to go. Certainly it's worth a look. Unless anyone has any suggestions as to where I'm going wrong with either of the other two approaches?

Posted by Simon Brunning at 10:28 AM | Permalink | Comments (23)
July 23, 2003
AR RAM Disk

Nice little windows utility - AR RAM Disk.

If you develop software, you probably have steps in your build process where you create a lot of temporary files. (For example, a typical Ant build process will compile a lot of Java into class files, then put them together into a jar file). Creating all these transient files would be quicker on a RAM disk, and would fragment your disk less.

If, that is, you have the RAM for it.

Via John Lipsky.

Posted by Simon Brunning at 02:03 PM | Permalink | Comments (6)
July 22, 2003
Packer layout manager

Avoiding the GridBag: The GridBagLayout is kind of the brocoli of the Swing layout managers. It's good for you, there are people who seem to really like it, but it's brocoli. Hmmm - I like broccoli.

Anyway - this reminds me of Tk's pack geometry manager. Which is probably no coincidence.

I've not used Packer, so I may be talking out of my, uh, hat. Let's face it - it wouldn't be the first time. But I think I prefer the approach taken by RelativeLayout, very much a layout manager for the rest of us. I've used Tk's pack geometry manager, and while it worked, it was awkward.

Via Java Today.

Update 23rd July: An SWT port of RelativeLayout.

Posted by Simon Brunning at 03:29 PM | Permalink | Comments (0)
July 21, 2003
Eclipse 3.0 M2 - New and Noteworthy

Eclipse 3.0 M2 - New and Noteworthy

Eclipse just keeps getting better and better.

I particulary like the duplicate code fragment finder in this build.

Posted by Simon Brunning at 12:16 PM | Permalink | Comments (1)
July 14, 2003
Using the Jakarta Commons

Using the Jakarta Commons

I've used a lot of stuff from the Jakarta project - Tomcat, Ant, and Velocity, mainly. But I've not really had a look at Commons.

Some of the stuff in Commons looks really handy. Covered by the article, CLI, Lang and Collections look like they should be in every Java coder's back pocket. I'll be taking a look at Pool, too - this could come in handy for me in the near future...

Posted by Simon Brunning at 02:41 PM | Permalink | Comments (1)
toString - just say no!

Java tip of the day - a must for newbies (are you reading this, Steve?), and a valuable reminder to the experienced: Kasia's The abuse and over-use of toString().

I was working on other people's code last week, and I wish they had read this! The debug code was using toString() all over the place, and NullPointerExceptions were frequent.

To sum up, the rules with toString() are: always override it, and never call it (directly). Instead, use String.valueOf() at all times.

Via Erik.

Posted by Simon Brunning at 10:55 AM | Permalink | Comments (9)
July 07, 2003
Online Java resources

Steve mentioned Java Ranch to me at the weekend. He's in the throws of learning Java right now, and he says that he's found it a very helpful site. Bravo them!

While the Python community remains peerless, I have found a number of good Java online resources. I thought that I'd mention my list of irreplaceable sites...

The Java world is a fast moving one. If you want to keep up, these sites are worth a visit every now and again. Or daily, if you are as sad as I am. ;-)


  • Erik's weblog. Regularly updated, this is Erik's take on what's important in the world of Java.

  • java.blogs. This aggregator covers hundreds of Java weblogs. A bit hit and miss, 'cos many people havn't set up a Java specific feed, so there's really too much non-Java related stuff here. Nevertheless, worth a look every now and again - especially the Popular Entries section.

There are a few very good Java books available, and bloody hundreds of rubbish ones. A list of good Java books is really another post altogether, but a couple of book related online resources require a mention.

A few places publish regular short, specialised articles on various Java subjects. I look at these sites every now and again to see if there's anything I'd like to learn about. I also search them if I need to do something I've not done before, 'cos if there is an article on the subject, it can save a ton of time.

Sun themselves have a couple of interesting new sites. The jury is still out, but they are worth watching.

Lastly, there are a couple of sources of software that you should keep in your favorites list. There are loads of places to go, but frankly, 90% + of the OSS software that I use comes from one of these places.


  • IBM Eclipse. My IDE of choice.

  • The Jakarta Project. Tomcat, Ant, Velocity, the list goes on and on. Without Jakarta, the Java world would be a poorer place by far.

  • JUnit. Unit testing the XP way. You know it makes sense.

  • JTOpen. Steve will want this, even if most don't. It's IBM's iSeries library. Not cool, but it works.

And don't forget Usenet - comp.lang.java and subgroups are a rich lode.

Which other essential sites am I missing?

Posted by Simon Brunning at 12:07 PM | Permalink | Comments (4)
July 01, 2003
Eclipse 3.0 M1

So many new toys today! Eclipse 3.0 M1 News

Check out the method call hierarchy, the new Quick fixes, the code generation improvements and the new style checks - these all look cool to me. I'll be doing some Java work in a couple of days...

Oh, and good luck jEdit! You've got my vote.

Posted by Simon Brunning at 12:45 PM | Permalink | Comments (1)
Java 1.4.2

Java 1.4.2

Another new version of my day-to-day workhorse. I've not upgraded yet, but when I get the time...

Posted by Simon Brunning at 10:26 AM | Permalink | Comments (0)
June 13, 2003
Sun and Zend push scripting for Java - so?

Sun & Zend push scripting for Java

Is this related to JSR 223: Scripting Pages in JavaTM Web Applications (Via Aaron Johnson)?

My question is, what does this add to what Jython already gives us? You can already use Java classes in Jython, or subclass them, use Jython classes in Java, write taglibs and servlets in Jython, you name it.

See jPublish for a nice example of what you can do.

Posted by Simon Brunning at 12:14 PM | Permalink | Comments (1)
May 30, 2003
What is an object?

A post over at c.l.py steered me towards this - Building user interfaces for object-oriented systems.

It has some interesting, if perhaps somewhat controversial, things to say on the nature of object orientation.

You may have read in a book somewhere that an object is a data structure of some sort combined with a set of functions, called methods, that manipulate that data structure. Balderdash! Poppycock! First and foremost, an object is a collection of capabilities. Very true, this. The important thing about an object is what is does, not what it has. The latter is an implementation matter.

Classes are irrelevant -- they're just a convenience provided for the compiler. Also true. This was pointed out to me while looking at JavaScript recently. Its rather, uh, idiosyncratic OO model does away with 'classes' as such. Instead, you just define a construction function, and add methods to its prototype. Look, Ma, no classes. (I don't really like this approach much - it makes subclassing rather clumsy if nothing else. But it does work after a fashion.)

All data is private. Period. (This rule applies to all implementation details, not just the data.) get and set functions are evil. (They're just elaborate ways to make the data public.) I like Python's approach here. No data is really private (see The principle of least privilege for why), but you can intercept any references to this data if you want. So, you just refer to object.attribute, and it's the object's business whether that just accesses the data attribute or calls a method. No need for get and set methods here.

All objects must provide their own UI. What? Is he serious? The presentation object should always be separate from the business object! Some business objects don't need any presentation layer, and some may need several. (The persistence layer should also be separate.)

Posted by Simon Brunning at 10:43 AM | Permalink | Comments (9)
May 28, 2003
Writing good exceptions

Cameron Laird on how to use exceptions - Writing good exceptions. Not how to use them in terms of syntax, but rather in terms of semantics. The examples are in Python, but the advice is applicable to any language supporting exceptions.

We have a lot of classes in one of my current Java projects (written by a cow orker) in which every method has a catch-all exception handler which logs any unexpected error, and then tries to keep on going. Me, I prefer the RuntimeException approach.

Posted by Simon Brunning at 01:45 PM | Permalink | Comments (2)
May 16, 2003
Escher Web Sketch

Rather groovy Java applet - The Escher Web Sketch.

Via Wry Writer.

Posted by Simon Brunning at 02:53 PM | Permalink | Comments (1)
March 21, 2003
JSR-666: Rich text identifiers

Further suggestion for JSR-666.

Previous JSR-666 recommendations:

JSR-666: Rich text identifiers

As is so often the case, Microsoft is leading the way here.

Remember back in the bad old days of DOS and Windows 3.x? 8.3 filenames? Yuck! With Win9x came long file names, and better still, embedded spaces. I don't need to tell you how useful this is.

Lets have this in Java. And why stop there? Let's go for full rich text! my button could be different from my button, and my button different again. (After all, mybutton and myButton are already different, so it's not so great a leap. my exception might be more serious than my exception.

I'm sure that there are some parsing issues to sort out, but they are (waves hand) pretty trivial, I'd imagine...

Update: See also JSR-666: i18n, misspellings and homonyms.

Also, see the wonderfully excentric colorForth. Clearly, there's no such thing as a new idea...

Posted by Simon Brunning at 05:21 PM | Permalink | Comments (3)
March 19, 2003
Java Extreme Programming Cookbook

O'Reilly's Java Extreme Programming Cookbook is out. Wort a look, I reckon.

The jUnit chapter is online, and had already given me some things to think about in terms of test naming standards and multi-threaded code testing.

One of the other chapters discusses GUI testing, so that'll be worth looking at too. One of my team has had a look at jfcUnit, but hasn't feed back to the team yet. My current project is very GUI heavy, being partly a pretty front end to a dog ugly (5250) green-screen application. Our current inability to auto-test our GUIs is causing us to spend a lot of time checking stuff manually, and inevitably, problems slip through anyway.

Posted by Simon Brunning at 11:01 AM | Permalink | Comments (1)
March 13, 2003
jEdit 4.1

jEdit is my text-editor-of-choice, and the new version, 4.1, is out.

I've not come across much new in it, but it's very pretty. ;-)

Not that I use it for coding - for that I use Eclipe (2.1 RC2 out recently), and PythonWin. But there are endless other text files to hack on, and jEdit is just perfect. Its XML handling is particulary good.

Posted by Simon Brunning at 02:21 PM | Permalink | Comments (1)
February 28, 2003
Mad in Madrid

I'm being packed off to Madrid next work, to help a client patch something into their software. Which I've never seen, so this might be a piece of cake, or it might be a nightmare.

Naturally, they want estimates. :-) I'm not giving them any. Not yet, anyway.

I wonder if I'll have any time to see anything of Madrid? I've never been before. Any suggestions? I'm flying out on Sunday night, and coming back on Friday at the latest. Hotel looks nice, anyway.

Note to my imaginary readers: I have no idea what 'net access I'll have, if any, so don't be surprised if it goes a bit quiet next week.

Update: Aside from the suggestions you see below, my mate Jay recommended the Prado. I'm a big fan of Goya, and The Naked Maja and Saturn Devouring His Son are among my favourites, so this is a must. If I'm out of the office in time, that is. (Jay introduced to to Python, so I'm eternally in his debt.)

Steve suggested that I shouldn't go out drinking before ten, or I'll find myself alone. Sigh. I'm usually in bed by ten!

Posted by Simon Brunning at 01:54 PM | Permalink | Comments (6)
February 21, 2003
Sun's marketing department are losing the plot

Why on Earth are Sun using Lee Hurst (a relatively famous, and indeed relatively funny comedian) in this advert (found attached to this week's Computer Weekly? There is, so far as I can see, nothing funny about this at all - they just used him as a model.

Or am I mistaken? Is it not him at all?

Posted by Simon Brunning at 03:32 PM | Permalink | Comments (1)
February 07, 2003
Typing: Safety causes Bugs

Alan Green: Typing: Safety causes Bugs.

Hmmm. Well, I've been using a mixture of Python and Java for some time now, so here is my personal conjecture:

I don't think that the extra typing required by 'safety' features actually cause bugs - they just don't stop them. Or rather, the ones that they stop are balanced by the additional ones that they introduce. For every time Java saves me from using a String as an int, I'll get a runtime error casting something around in order to get to a method that I know damn well it has, even if the bloody compiler doesn't.

In Python, if an object has a method, I can just call it. Thank you. If this isn't going to work, I'll find out while testing.

Ah yes, testing. That's where you stop bugs. Static typing might have pointed you at a few bugs a little earlier than your testing would have, but your testing would have picked them up soon enough. And if you don't test properly, your stuff is going to be buggy anyway.

The so called 'safety' features are only going to catch a subset of problems, and you would have found these problems eventually anyway. So if they add too much work at the coding stage, they are a net time loss.

Cameron Laird and Kathryn Soraiz's Syntax Checking the Scripting Way is interesting on this. And I'm reminded of a quotation:

The static people talk about rigorously enforced interfaces, correctness proofs, contracts, etc. The dynamic people talk about rigorously enforced testing and say that types only catch a small portion of possible errors. The static people retort that they don't trust tests to cover everything or not have bugs and why write tests for stuff the compiler should test for you, so you shouldn't rely on only tests, and besides static types don't catch a small portion, but a large portion of errors. The dynamic people say no program or test is perfect and static typing is not worth the cost in language complexity and design difficulty for the gain in eliminating a few tests that would have been easy to write anyway, since static types catch a small portion of errors, not a large portion. The static people say static types don't add that much language complexity, and it's not design "difficulty" but an essential part of the process, and they catch a large portion, not a small portion. The dynamic people say they add enormous complexity, and they catch a small portion, and point out that the static people have bad breath. The static people assert that the dynamic people must be too stupid to cope with a real language and rigorous requirements, and are ugly besides.

This is when both sides start throwing rocks.

Quinn Dunkan, 13 Jul 2001

Posted by Simon Brunning at 03:14 PM | Permalink | Comments (1)
February 06, 2003
Java 1.5 features

An interesting set of stuff:

It looks like Java is reacting to the competition!

Of course, type-safe enumerations in Java are already pretty easy once you know how to do them, but it isn't obvious.

Via SlashDot.

Posted by Simon Brunning at 05:17 PM | Permalink | Comments (13)
February 05, 2003
Fine-tuning garbage collection

Fine-tuning Java garbage collection performance

More than you need to know. Well, more than I need to know, for sure. Bookmarking for future reference...

Posted by Simon Brunning at 01:26 PM | Permalink | Comments (1)
Dave Thomas has a blog

Dave Thomas (co-author of The Pragmatic Programmer) has a new weblog - PragDave. One for the aggregator!

If you've not read The Pragmatic Programmer, you should. Well, if you are a programmer, that is. Not a lot in it for accountants, for example. (Or maybe there is - 'No broken windows', anybody? Still, there is certainly a lot of techie stuff in there.)

Via Ned Batchelder.

Posted by Simon Brunning at 12:07 PM | Permalink | Comments (1)
February 04, 2003
JSR-666: Programmability Enhancements

JSR-666: Programmability Enhancements.

Is this a conscious reworking of Python's PEP 666: Reject Foolish Indentation?

Via Charles Miller.

Posted by Simon Brunning at 01:47 PM | Permalink | Comments (1)
VSS for Eclipse - updated

Marcus Nylander's VSS Plugin for Eclipse has been upgraded to to COM automation - it's much faster now.

Funnily enough, I've had to do some VSS automation myself, in Python. VSS's object model is a bit nasty, but it's easy enough to write an OO wrapper while clutching the documentation. Then you can use the wrapper, and forget all about the ugly stuff underneath.

I'll probably clean this VSS stuff up and post it at some point.

Posted by Simon Brunning at 10:03 AM | Permalink | Comments (4)
January 27, 2003
TN5250j

TN5250j is a 5250 terminal emulator for the AS/400 written in Java, which allows Python scripting!

(Well, Jython scripting, to be precise.)

This is going to be so useful...

Via Daily Python-URL

Posted by Simon Brunning at 01:39 PM | Permalink | Comments (2)
85 of 101 Reasons, Rebutted

Ted Neward's 85 of 101 Reasons, Rebutted is a very thorough and non-partisan response to Carlos Perez's 101 Reasons Java is better than Dot-Net.

As I think I've said before, I'd like Java to stay better than .NET, but it's only going to do so by recognising where .NET has advantages, and stealing them. If Java can also steal good ideas from other arenas, then so much the better.

Via Dave Johnson

Posted by Simon Brunning at 01:03 PM | Permalink | Comments (3)
Opening Microsoft File Formats to Java

Want to read and write Word and Excel files from Java? Opening Microsoft File Formats to Java tells you how. Or at least some of how.

This article tells you how to use Apache POI to read the OLE 2 Compound Document format, which both Word and Excel use, but it doesn't tell you how to read the application specific structures.

Actually, I have always used Python for this kind of work. And since Word & Excel are installed on all the machines that I want to run my utilities on, COM automation (at which Python excels) was the obvious solution. Worked, too.

Posted by Simon Brunning at 12:26 PM | Permalink | Comments (0)
January 24, 2003
Anthony Eden on Scripting Java Applications with Jython

Anthony Eden is giving a presentation on Scripting Java Applications with Jython at the upcoming Python UK Conference 2003. I, for one, am really looking forward to this.

Other people that I'm looking forward to: Marc-André Lemburg, Alex Martelli and Andy Todd.

And, of course, Guido himself. We are not worthy.

Update: I forgot to mention - Anthony has blogged about this before.

Posted by Simon Brunning at 01:25 PM | Permalink | Comments (0)
The Future of Java?

More heat than light, as usual, over at Slashdot.

Still, the Salon editorial, Is there hope for Java? is an interesting read, covering the history of Microsoft's attempts to kill Java off.

TIOBE's Programming Community Index is total rubbish, though. RPG on the way up? I'm a iSeries (a.k.a AS/400) developer, and I know that this is way wrong. Python on the way down? Far from it. Where did they get these figures? What did they google on?

My take on the future of Java is that it's bright, so long as the competition from .NET is taken seriously. A bit of healthy competition never does any harm, and Sun needed a bit of a kick in the arse - Java has been static for too long. C# fas some nice features, and Java needs to steal them.

Posted by Simon Brunning at 12:55 PM | Permalink | Comments (0)
January 17, 2003
Caching with SoftReferences

We use SoftReferences for Caching in an an app which I'm currently working on. Bob Lee points out some interesting things about caching with SoftReferences.

We are certainly not getting the performance that we'd hoped for - perhaps this could explain why?

Or perhaps SortReferences just aren't working at all...

Posted by Simon Brunning at 04:39 PM | Permalink | Comments (0)
January 13, 2003
Concurrency utilities for Java

Concurrency made simple introduces Doug Lea's util.concurrent package, which includes must-haves like work queues and thread pools.

Brian Goetz's point about reinventing the wheel is also well made.

Also from developerWorks recently - Introduction to the Thin Client Framework.

Posted by Simon Brunning at 02:52 PM | Permalink | Comments (1)
Erroneously Empty Code Paths

Ned Batchelder on Erroneously Empty Code Paths. Wise words.

Posted by Simon Brunning at 12:59 PM | Permalink | Comments (1)
January 10, 2003
.NET viable on non-Windows platforms?

Ted Neward thinks that .NET is viable on other platforms.

Is it just me, though, or are his points one and two somewhat contradictory? He says that WinForms, ASP.NET, ADO.NET, etc. won't be available off Windows. If you start leaving this sort of stuff out, how valuable is .NET anyway?

J2EE is indeed separate from, J2SE, but it's every bit as cross-platform, and every bit as free (i.e. free as in beer, but not free as in speech).

Posted by Simon Brunning at 11:19 AM | Permalink | Comments (0)
January 07, 2003
Bean Scripting Framework moves to Jacada

The Bean Scripting Framework is now part of the Jakarta project. When did this happen?

Via Ricardo.

Posted by Simon Brunning at 05:36 PM | Permalink | Comments (2)
December 20, 2002
Eclipse 2.1 M4

Eclipse 2.1 M4 - New and Noteworthy. Oooh, cool!

Posted by Simon Brunning at 12:59 PM | Permalink | Comments (0)
December 19, 2002
Encapsulation gotchas

The mutable return value gotcha mentioned in Avoid these simple Java encapsulation gotchas certainly isn't specific to Java - the same would apply to Python, and (I think) to C#.

Now, as a Python-head, I'm not big on enforcing encapsulation - see The principle of least privilege. But you certainly don't want to break encapsulation by accident, and mutable return values are an accident waiting to happen.

Posted by Simon Brunning at 04:09 PM | Permalink | Comments (0)
December 13, 2002
Maven

I've heard a lot about Maven, but I've never worked out what it actually does. It seems that Charles Miller is in the same boat.

James Strachan explains why he uses Maven, and what it does for him. Problem is, this sounds like what Ant does, and I know Ant isn't the same thing as Maven, so I'm still in the dark...

Update: James explains further. Maven doesn't do anything which Ant can't do - it saves you from a lot of the work. That's got to be a good thing.

Posted by Simon Brunning at 01:39 PM | Permalink | Comments (0)
December 12, 2002
Really don't Use System.out.println!

Don't Use System.out.println! was Tuesday's hot story at Java.blogs, believe it or not.

Using System.out.println is worse than I thought, though - David Johnson points out that it can really slow your system down. Yuck!

One other thing to consider - if there is any possibility, any possibility at all, that you might want to run something as a Windows service, then you can't use stdin, stdout, or stderr at all. (BTW, if you do need to run Java as a service, check out jsrvany.)

Posted by Simon Brunning at 12:40 PM | Permalink | Comments (1)
December 10, 2002
Extending Java

The discussion goes on.

In the frame now - should Java get macros, or is there no place for macros in Java?

Well, macros would make implementing James Strachan's J* pretty trivial. But if everyone was able to create their own flavour of Java, how would we read one other's code? Would macros be Java's own Tower of Babel?

Posted by Simon Brunning at 05:34 PM | Permalink | Comments (0)
Java multiple inheritance

Multiple inheritance - good or bad? The only good answer to this is 'it depends'.

There are a number of programming language facilities which can very easily be abused, but which when not abused can be very powerful. Multiple inheritance is one of these. Another which springs to mind is operator overloading.

The designers of Java decided that the danger of including these was greater than the benefit.

The designer of Python decided to trust the programmer to know what he or she is doing. Is this a mistake? I don't think so, but then I've never had to work on a large Python project alongside incompetent developers. Of course, incompetent developers can screw up in any language, so I can't see Python making anything worse.

Anyway, I digress. One of the main good uses of multiple inheritance is 'mixins'. To my understanding, these are classes created specifically to be multiply inherited, and which provide specific behaviours which might be useful to any class. A good example of this in Python is found in ZOBD, an object database. To allow an existing class to have its instances stored in the database, all you have to do is to inherit from the ZODB.Persistent mixin class in addition to whatever your class is already inheriting from.

Java as it stands won't allow anything like mixins, but there is a Java extension, Jam, which does.

A recent developerworks article, Diagnosing Java code: Killer combo -- Mixins, Jam, and unit testing, shows how mixins could be used to simplify unit testing in some circumstances. I'm not sure that this is a killer-app for Jam - unless I'm missing something, AspectJ might be a better approach here. Interesting, nevertheless.

Posted by Simon Brunning at 04:57 PM | Permalink | Comments (1)
Easy Struts

Easy Struts is a Struts plug-in for Eclipse.

Lomboz, a J2EE plug-in, including JSP facilities, is also interesting.

BTW, Programming Jakarta Struts came recently. I haven't started it yet - I'm still working through Java Development with Ant. But I'm already wondering if I've got the wrong book - Struts in Action looks good, and reviewed very well.

Ah, well, I'll give the O'Reilly book a chance. It's not like they've let me down before.

Posted by Simon Brunning at 02:14 PM | Permalink | Comments (0)
Classes, interfaces, and factories

There has been a bit of a storm in the Java blogging world recently about the naming convention, if any, to use for interfaces. A storm in a teacup, perhaps? Anyway, I tend to agree with Charles' opinion on this.

We had a good blazing row discussion about this at work. We were never going to agree - there are fans of hungarian here! (And not just here, either!) Me, I hate hungarian. I'm a Python man at heart - it's the signature that counts, not the type, so hungarian is emphasising the wrong thing.

More interesting to me, though, is the notion of avoiding use of the 'new' keyword, except when used from within factory methods. Makes a lot of sense to me.

Posted by Simon Brunning at 01:17 PM | Permalink | Comments (1)
Don't Use System.out.println!

Don't Use System.out.println! is a nice intro to Log4j.

Via Erik.

Posted by Simon Brunning at 12:50 PM | Permalink | Comments (2)
November 28, 2002
Moving Java forward

James has more thoughts on Extending the Java language.

If all of these proposals, I think that foreach is the killer. Of course, anything which moves Java closer to Python gets my vote.

Hell, let's just use Python. ;-)

The Java Three Wiki is fascinating, too. I'm not sure that I want to see closures, I must say. It seems to me that classes and generators do all that is needed here. Or am I missing something?

Posted by Simon Brunning at 01:09 PM | Permalink | Comments (1)
November 27, 2002
AspectJ Now Supports Bytecode Weaving

Found in ::Manageability:: - AspectJ Now Supports Bytecode Weaving

This means that you will be able to weave aspects into existing code to which you do not have the source. Groovy!

For more about AspectJ, see the AspectJ web site, this developerWorks article, and these JavaWorld articles.

Posted by Simon Brunning at 05:01 PM | Permalink | Comments (0)
java.blogs

java.blogs is here.

Already pointed me towards the new release of AspectJ. About which more later...

Posted by Simon Brunning at 04:52 PM | Permalink | Comments (1)
November 26, 2002
J2EE vs. NET, Java vs. C#

Yet another J2EE vs. NET, Java vs. C# article. Worth a read though, this guy really knows what he's talking about.

It's also significant to note that several new C# features have already been proposed and will be implemented soon, making C# one of the freshest and quickly evolving languages on the market. The Java language, on the other hand, had a strong initial start and then essentially stagnated after Java 1.1.

I couldn't agree more - Java needs to move if it isn't to be left behind. In terms of features, James Strachan's J* proposal would be a good place to start, I think. In terms of the process, I think that Sun should free Java.

I make use of the JGL library (written by Graham Glass, author of the article) for sorting and filtering. Excellent stuff. I notice that version 4.0 is out, but that you have to pay for it. We are using 3.1.0, which was free (as in beer).

Update: Oh yes - 10 more things to go into Java 3.

Posted by Simon Brunning at 01:08 PM | Permalink | Comments (6)
Java Access to AS/400 Data

Java Access to AS/400 Data

We are sticking to JDBC at the moment on my projects. Since the prospect of our running the database on anything other than a '400 is just about zero for the foreseeable future ('cos we are interfacing with a rather old, but very capable and very large system), perhaps record level access shouldn't be ruled out?

Program Call Markup Language (PCML) is worth bearing in mind for some things, too.

Posted by Simon Brunning at 11:45 AM | Permalink | Comments (1)
November 15, 2002
Out-of-the-Box

Out-of-the-Box™ is a distribution of over 50 (and counting) Open Source projects targeted mainly at Java developers

There is a lot of stuff out there - even if you don't get Out-of-the-Box itself, the Out-of-the-Box contents page gives you a good overview of what's out there.

Via dsuspense.

Posted by Simon Brunning at 01:36 PM | Permalink | Comments (1)
November 12, 2002
J*

James Strachan is putting together a wish-list for a fictional Java pre-processor.

Generics & properties would be cool. Foreach would be just like Python's for, and everyone who is anyone knows how cool that is.

Better to roll these changes into Java proper than to use a preprocessor, though. How does one propose changes to Java? JSRs, I think.

Posted by Simon Brunning at 04:57 PM | Permalink | Comments (4)
November 08, 2002
Persistence

The deeper I look into persistence, the more confused I get.

In the old days, it wasn't too hard. We wrote our SQL, muttered a swift prayer to Codd, and away we went. In the even older days, we used native access methods, but there was still an RDBMS underneath.

In fact, the first systems that I worked on used flatfile, tapes, and DB1, all under PL/I. But my memories of that time are lost in the mists of Guinness.

But now, it's all very different. It isn't just data that we want to persist, it's objects. And from what I can tell, there isn't a generally accepted right solution to this.

One approach is to map objects onto tables in an RDBMS. Castor JDO can do this, as do Entity EJBs. In fact, there are many such frameworks. The advantages of this are obvious, especially to those of us who are comfortable with SQL. (My friend Steve used to whistle The Ride Of The Valkyrie when I was doing SQL updates.)

But it isn't very OO, is it? Not very twenty-first century.

Then there are OODBMSs. Java has Ozone, about which I know nothing, and Python has ZODB, which I've used, and is pretty funky.

Somehow, though, I can't see OODBMS replacing RDBMSs. Perhaps it's just that I've not got used to them. But when I first learned about RDBMSs, a light went off in my head - I knew that they were just right. I get no such flash of light from OODBMSs. But then, what do I know?

I suppose that there is always pickle. For Python, at least...

Update 11th November: A couple of approaches I neglected to mention. You can persist to XML. Castor does this, in addition to being able to persist to an RDBMS.

Then there is the Prevayler/PyPerSyst approach - keep everything in memory. Which is OK for small data sets, I suppose...

Posted by Simon Brunning at 01:44 PM | Permalink | Comments (5)
Struts 1.1

Learning the New Jakarta Struts 1.1

Cripes, I had better get a move on! My knowledge of Struts is almost entirely theoretical (a few prototypes aside), and they are upgrading it already!

Programming Jakarta Struts is on order...

Posted by Simon Brunning at 01:12 PM | Permalink | Comments (2)
November 07, 2002
Eclipse 2.1

Eclipse 2.1 M2 - New and Noteworthy

Whoooo! New refactorings!

Via A cup of joe.

Posted by Simon Brunning at 02:01 PM | Permalink | Comments (1)
November 04, 2002
J2EE Performance

J2EE Performance looks OK to me, dodgy benchmarks not withstanding.

Posted by Simon Brunning at 02:08 PM | Permalink | Comments (0)
Spam, Spam, Spam, Spam, Spam, Spam, Spam.

Java's Casts of Thousands

More than any other programming language Java forces programmers to embed hard-coded knowledge throughout their code about the types of data items. The numerous explicit cast operations in a typical program, not only annoy the programmer but also contribute greatly to the unreasonably high cost of maintaining Java software.

Posted by Simon Brunning at 01:12 PM | Permalink | Comments (2)
WebFacing into Tomcat does go!

They said it should work, and it does. So, can anyone tell me why a WebFacing user needs WAS?

Posted by Simon Brunning at 01:03 PM | Permalink | Comments (1)
November 01, 2002
Sun thinks that J2EE is the way to go

Shocking, I know, but there you are. The Top Five Reasons to Choose J2EE as Your Application Server Platform.

The reasons are:

1. Integration
2. Compatibility
3. The J2EE Programming Model
4. Web Services Support
5. Open Standards: Safety and Freedom

Via TheServerSide.com.

Posted by Simon Brunning at 01:43 PM | Permalink | Comments (1)
File renaming - Java vs. Python.

See the Python (imperative) version, and the Java version.

Now, this is totally unfair to Java - this is exactly the sort of job that you shouldn't use it for. What it does demonstrate is the importance if picking the right tool for the job.

As to the functional version of the Python script, well, it looks ghastly to me. But that's probably more to do with the fact that I'm not used to fuctional programming than anything else - I'm sure that Alex's code is fine, and that a functional style is appropriate to the task. But if you haven't grokked functional programming yet, it just looks wrong.

Posted by Simon Brunning at 01:14 PM | Permalink | Comments (1)
Using the 'final' keyword

Is that your final answer? Guidelines for the effective use of the final keyword.

Posted by Simon Brunning at 01:06 PM | Permalink | Comments (0)
O'Reilly Struts article

Jakarta Struts: Seven Lessons from the Trenches

Programming Jakarta Struts is going to be a must. ;-)

See also JSPs, the MVC model, and Struts.

Also, a series of articles on the JSP Standard Tag Library - parts one, two and three.

Posted by Simon Brunning at 09:31 AM | Permalink | Comments (2)
October 31, 2002
OpenSymphony

OpenSymphony looks pretty interesting. It's a set of J2EE components, possibly the most interesting of which is WebWork. WebWork defies one sentence explanation, but basically, it's a tool for building highly dynamic websites.

WebWork doesn't come with a tutorial, so WebWork - Gaining Core Competency was a good find (found at Pushing the envelope).

Posted by Simon Brunning at 04:25 PM | Permalink | Comments (0)
Java Launcher

The Marner Java Launcher. Launching Java applications via an exe.

Combine with Inno or Nullsoft, and Windows users need never know that you are shipping a Java app.

Posted by Simon Brunning at 01:31 PM | Permalink | Comments (4)
Aspire

For Tomcat Developers, Aspire Comes in a JAR

Utility for Data Access, Configuration, Logging, and Factory Needs.

Via Erik's Weblog.

Posted by Simon Brunning at 12:49 PM | Permalink | Comments (0)
October 29, 2002
J2EE or .NET?

Don't be REASONABLE

Good points on both sides, I think, but I tend to lean towards Russ's viewpoint, but that could well be 'cos I'm a knee-jerk Microsoft hater.

Russ certainly sparked a lot of debate...

Posted by Simon Brunning at 01:08 PM | Permalink | Comments (0)
October 25, 2002
Java on the desktop

Rethinking the Java GUI

Perhaps the death of Java on the desktop has been exaggerated? I use (SWT using) Eclipse and (SWING using) jEdit every day. Certainly, Eclipse feels much snappier, and looks better, so I'd chose SWT over SWING where possible, but both are quite usable.

Via vsbabu.org.

Posted by Simon Brunning at 12:48 PM | Permalink | Comments (0)
October 23, 2002
WDSc's Visual Editor

Comparing WebSphere Studio Application Developer with VisualAge for Java -- Part 3: Using the New Visual Editor

VaJ is dead, long live Eclipse!

I'll get to play with WDSc soon, but I'll probably keep vanilla Eclipse around too - WDSc is based on Eclipse 1, so the Java Editor isn't going to be as good as the one in Eclipse 2. Also, many plug-ins target Eclipse 2.

Posted by Simon Brunning at 01:52 PM | Permalink | Comments (1)
Java Persistence Frameworks

Java Persistence Frameworks, again

Sheesh, this all looks complicated!

I'm looking for a persistance framework for a project if my own in the near future. David's post just makes me realize how little I know....

At work, we are using raw JDBC. I've been an RDBMS man for over a decade now, so JDBC 'fits my brain'. But it's time to learn to do persistance the OO way, if only so that I can make informed decisions. But which framework to choose?

Posted by Simon Brunning at 01:39 PM | Permalink | Comments (3)
October 18, 2002
Running Tomcat with Apache on Win32

How to Run Tomcat with Apache on Win32.

Instructions for using mod_jk to run Tomcat with Apache on Win32. I need to do exactly this soon, to this is very useful info.

Via Sanjay.

Posted by Simon Brunning at 01:00 PM | Permalink | Comments (0)
October 16, 2002
Java Best Practice

Collected Java Practices. Very good resource, this.

Via dsuspense.

Posted by Simon Brunning at 12:27 PM | Permalink | Comments (1)
October 11, 2002
Commons Lang

Commons Lang 1.0. The standard Java libraries fail to provide enough methods for manipulation of its core classes. The Lang Component provides these extra methods.

Via Jakarta News.

Posted by Simon Brunning at 03:38 PM | Permalink | Comments (1)
Teaching Java the Extreme Way

Teaching Java the Extreme Way - a good intro to test-first programming.

Java examples and tools are used, but the technique is applicable to any environment.

Posted by Simon Brunning at 01:19 PM | Permalink | Comments (0)
October 09, 2002
Primitive types and objects

The Fishbowl's Java Peeves.

I totally agree with, uh, whatever The Fishbowl's author's name is on the primitive types and objects issue. This is being fixed in Python. I can't see Java changing so fundamentally in the near term, though.

Exceptions haven't caused me too much of a problem, but I can see his or her point. Still, it's just another one of those lots-of-boilerplate things that irritate me about Java.

Closures? Hmmm, well, useful at times, but you'd get most of the same benefit if methods were to be first class objects.

Also recently at The Fishbowl: The StringBuffer Myth and Six Rules of Unit Testing. Both worth a read.

Posted by Simon Brunning at 01:15 PM | Permalink | Comments (2)
October 08, 2002
Digester

Digester is a component for building live Java objects from XML. As Darren says, dead handy for config files.

Posted by Simon Brunning at 02:44 PM | Permalink | Comments (0)
October 07, 2002
Scripting Java Applications

Anthony Eden has some interesting things to say on the subject of scripting Java applications.

Naturally, there are loads of options available for scripting Java apps, and choosing the right one can be difficult. Unless you are a Python bigot, like me, in which case the answer is obvious. ;-)

The Bean Scripting Framework (BSF) looks fascinating, though. BSF is a scripting framework which allows you to use any one of a number of languages to script your Java app, of which Jython is only one.

We are hoping to get Anthony over to talk at Python 2003 on scripting Java applications with Jython.

JPublish looks interesting, too.

Posted by Simon Brunning at 02:01 PM | Permalink | Comments (1)
PyPerSyst

I have mentioned Prevayler before. Now Patrick K. O'Brien is building a Python version - PyPerSyst.

I remain a little dubious about the approach used by Prevayler (and PyPerSyst), but I'll be very interested to see the results.

Posted by Simon Brunning at 12:51 PM | Permalink | Comments (4)
October 04, 2002
A whole bunch of Java articles...

Plenty of new stuff today:

Posted by Simon Brunning at 12:48 PM | Permalink | Comments (1)
October 02, 2002
Quantum Eclipse Plug-in

My friend Jay Graves pointed out Quantum to me. It's a nice simple database access plug-in for Eclipse.

Built-in iSeries support!

Posted by Simon Brunning at 02:55 PM | Permalink | Comments (1)
October 01, 2002
JDK 1.4 Class Diagrams

JDK 1.4 Class Diagrams. Nifty!

Via Erik.

Posted by Simon Brunning at 01:48 PM | Permalink | Comments (1)
September 30, 2002
Axion

Axion is an open source JDBC compliant database in pure Java from Tigris.

Needs a DB-API compliant interface for Jython...

Via James Strachan.

Posted by Simon Brunning at 02:10 PM | Permalink | Comments (1)
System tray icons in Java

Windows Tray Icon.. Java Implementation!

Via All Things Java.

Posted by Simon Brunning at 01:59 PM | Permalink | Comments (3)
September 27, 2002
JellySwing

JellySwing looks very interesting. It's an XML based GUI generator (Like Thinlets or the Java Gui Builder), but it generates its GUIs at runtime, and supports embedded expressions, custom tags, iteration over SQL and beans.

Via Sanjay.

Posted by Simon Brunning at 02:07 PM | Permalink | Comments (1)
September 26, 2002
Write Once Run Anywhere

Charles Miller installed JIRA, an J2EE based issue tracker on an iSeries, and it worked first time. Cool!

Posted by Simon Brunning at 01:14 PM | Permalink | Comments (0)
September 25, 2002
Class.forName() is evil...

Class.forName() is evil...

I guess I'll be looking at a couple of my things again...

Posted by Simon Brunning at 02:05 PM | Permalink | Comments (2)
J2EE Container Shootout

J2EE Container Shootout Summary

Don't access the database directly from Servlets and JSP, use EJB intead. EJB caches data for web applications very well and can be ten times faster than ordinary database access.

Via rebelutionary.

Posted by Simon Brunning at 01:55 PM | Permalink | Comments (0)
Physics applets

I really don't know which category to put these physics applets under.

Science and Technology 'cos they are for science education, Toys 'cos they are fun, or Java 'cos that's what they are written in? Bah, who cares, just enjoy!

Via FARK.

Posted by Simon Brunning at 01:20 PM | Permalink | Comments (2)
September 24, 2002
jsrvany

jsrvany is a Java package (plus a native JNI invoker) which uses the Java event model to implement the win32 Service Control interface in Java. This allows any Java application to be run as a service on Windows NT 4 and for the application to respond to all the events triggered by the win32 Service Control Panel - start, stop, pause, continue, terminate and interrogate.

Guess what - I'm struggling to run a Java application as a service at the moment - this could be just what the doctor ordered.

In fact, running the Java application as a service isn't the problem - stopping the bastard is the trick. And I can't see what is going on, 'cos NT is dropping stdout and stderr on the floor.

Posted by Simon Brunning at 05:04 PM | Permalink | Comments (1)
September 23, 2002
Dynamic Proxies in Java

Dynamic Proxies in Java

We make heavy use of proxies in my current project, and it involves a lot of boilerplate.

I knew how to avoid boilerplate in Python, but not in Java. This is worth investigating...

Posted by Simon Brunning at 01:36 PM | Permalink | Comments (1)
September 20, 2002
Resin

Resin: The Instant Application Server

I have downloaded Resin, as a response to worries about Tomcat, but I haven't had a chance to play with it just yet - Tomcat hasn't caused us any problems yet!

Posted by Simon Brunning at 01:49 PM | Permalink | Comments (1)
Java layout managers

Java layout managers are a total pig - I can't tell you the hours I've wasted fiddling, trying to get my GUIs to look just right.

Of course, things might have gone more smoothly if I knew what I was doing. ;-)

In the end, I ended up writing my own layout manager. But I don't think that I'd have had to had this been available at the time - RelativeLayout, a Constraint-Based Layout Manager.

Posted by Simon Brunning at 01:27 PM | Permalink | Comments (3)
September 18, 2002
The "What Sucks" Index

The "What Sucks" Index - PHP comes out well, with Python coming in second. VB sucks big-time, C++ sucks bigger-time, and Perl and Java suck a bit.

All very scientific, I'm sure. ;-)

Via c.l.py.

Posted by Simon Brunning at 04:57 PM | Permalink | Comments (0)
Java, Language of Tomorrow?

Miles Nordin is obviously having a really bad time with Java - he's totally pissed off with it, by the sound of it. Still, Java, Language of Tomorrow debunks a lot of hype.

I can't say that I love Java - it's not Python. But we rub along together well enough.

Via Babu.

Vattekkat's 'buzzword compliance' point is certainly a good one. Better than just asking about the technologies, interviewers should ask about techniques - "What does "Model-View-Controller' mean to you?", "What are tag libraries good for - how can they improve the quality, and particularly maintainability, of your code". That sort of thing.

Posted by Simon Brunning at 04:24 PM | Permalink | Comments (0)
The End of Inheritance

The End of Inheritance: Automatic Run-time Interface Building for Aggregated Objects is a fascinating new recipe on the Python Cookbook.

Knowing both Python and Java has made me think about the relationship between types, interfaces, inheritance and classes a lot more than knowing just one would have done, I think. It certainly seems to me that the central concept is the interface - what roles can the object take. This is quite a separate thing from inheritance - that's about behavior, what an object actually is.

A good example here is the Python concept of a 'file'. Any object which follows the file 'protocol' (or the required subset of that protocol which is actually used) can be used anywhere that a real file object can. You could do this in Java quite easily, by implementing 'file' using an interface, but people usually seem to use inheritance instead.

This recipe allows you to build a class composed of other objects (with a 'has-a' relationship), but to automatically implement the behaviors of the contained objects.

You can do something similar with Java's Dynamic Proxy Class API, as as Java 1.3.

Via the Python Daily URL.

Posted by Simon Brunning at 02:07 PM | Permalink | Comments (0)
September 17, 2002
SQuirreL SQL

SQuirreL SQL - SQuirreL SQL Client is a graphical Java program that will allow you to view the structure of a JDBC compliant database, browse the data in tables, issue SQL commands etc.

Looks really cool.

Via Sanjay's Journal of Coding Tips, via Babu.

Posted by Simon Brunning at 01:28 PM | Permalink | Comments (1)
September 13, 2002
Simple JSP Custom Tag in Jython

One recipe which didn't make it into the Python Cookbook is Simple JSP Custom Tag in Jython.

How to Create Custom JSP Tags is a good intro to custom tags. Nicer in Jython, though!

Another good Jython for J2EE recipe, A simple Jython servlet did make the cut.

Posted by Simon Brunning at 03:32 PM | Permalink | Comments (1)
September 12, 2002
Java Gui Builder

The Java Gui Builder auto generates Java GUIs based on XML.

I'll definitely give this a bash next time I have to build a GUI - doing it by hand is a total pain, especially if you are a bit of a perfectionist. (I ended up writing my own layout manager - that's how much of a perfectionist I am!)

If the example is anything to go by, this it should be pretty simple. I wonder if it supports AWT?

Via Cafe au Lait.

Posted by Simon Brunning at 05:35 PM | Permalink | Comments (7)
Is Tomcat Crap?

Mike Cannon-Brookes' Is Tomcat Crap?, and the follow up Bashing the Cat are worth a look it you are a Tomcat user.

We are currently deploying to Tomcat, and we don't seem to be having a problem. But then, we haven't rolled out to any of our larger clients yet, so time will tell...

I'm not too concerned, because the problem seems mainly to be with Jasper, Tomcat's JSP component. Since we are using Tomcat mainly as a servlet container, this won't effect us. Besides, Tomcat 4.21 is out, with a totally new version of Jasper, so the problem may have been solved.

We are also using Tomcat to serve static content, and I think that we might need to look at this - an Apache/Tomcat combination might perform better here, and give us more fine grained control over caching.

Still, I'll keep Resin and Orion in mind if we have any scalability problems.

See also Using Tomcat in Production.

Posted by Simon Brunning at 01:58 PM | Permalink | Comments (1)
September 11, 2002
Java, J2EE and/or Eclipse related weblogs

There seem to be a fair number of people blogging on the subjects of Java, J2EE and/or Eclipse.

Many of them can be found via Mike Cannon-Brookes' java.blogs page. Mike's weblog, rebelutionary, is worth a read. I'll touch on some of his writing elsewhere...

See also:

A disproportionate number if these are Radio weblogs. I wonder why?

Also well worth reading for J2EE news - The Server Side.

Update 13th September: Pushing the envelope is another interesting Java related blog.

Posted by Simon Brunning at 05:20 PM | Permalink | Comments (3)
JRockit

BEA WebLogic JRockit 7.0 is a high-performance Java Virtual Machine (JVM).

It's a specialised server-side JVM, providing a management console. It features advanced garbage collection options and lighweight threads. It's free as in beer, but not as in speech.

Might well be worth a look.

Posted by Simon Brunning at 04:52 PM | Permalink | Comments (0)
Crossbar reporting framework

Crossbar is an open source server-side reporting framework.

It can pull data from any JDBC accessible database. Ad-hoc queries, simple SQL based reports and more complex model-based reports are all handled by the same presentation layer.

Also, I came across iText, another Java based PDF generator - another is PJ Classic. I'll compare these if and when I need to generate PDF.

Posted by Simon Brunning at 11:49 AM | Permalink | Comments (0)
Struts plug-in for Eclipse

The Improve Struts Configuration File Editor for Eclipse includes a graphical view of your Struts actions and JSPs, and includes a struts-config file editor.

If you are using JSPs, you need Struts.

Improves' plug-it makes use of the SolarEclipse plug-in for JSP editing.

Another interesting Eclipse plug-in is CompleteClipse - an enhanced auto-completion widget. Looks interesting.

I'll have a play with both of these at some point.

Oh yes, a couple more interesting ones - XML buddy features syntax highlighting and DTD driven auto-completion, and the Sysdeo Eclipse Tomcat Launcher plug-in, uh, launches Tomcat, but also gives you integrated servlet debugging (with JSP debugging to come), and creates & deploys WAR files.

There are now a huge number of Eclipse plug-ins available - 133 as at the time of writing, according to Eclipse-plugins.2y.net. Looks like Eclipse's promise as a framework for all manner of development tools is starting to come true.

Posted by Simon Brunning at 11:37 AM | Permalink | Comments (7)
September 10, 2002
Eclipse news

A couple of Eclipse items today.

Eclipse unveils modeling framework - I'm not sure what the EMF will actually do. Will it provide functionality out of the box, or is it infrastructure for plug-in builders? Ah well, time will tell. It's not out yet - www.eclipse.org/ems is still 404 compliant.

IBM to shine light on new Eclipse - Eclipse, which released a test version of the new framework in June, will release a final version on Sept. 18. Huh? I didn't realise that I was using a test version. Am I? Again, time will tell...

Update: The SolarEclipse plug-in features, amongst other things, HTML and JSP syntax highlighting. JSP code assist/completion planned. Cool.

Further update: the EMF URL was wrong - it's www.eclipse.org/emf. Found via the Eclipse Wiki page. It's a framework rather than usable product (hence 'modeling' - doh!), and will be available (looks at watch) any time now.

UML modeling is already available, but hooo, it's expensive.

Posted by Simon Brunning at 12:46 PM | Permalink | Comments (0)
September 09, 2002
VSS plugin for Eclipse

Using Eclipse? Stuck with VSS for source control? Then you need Marcus Nylander's VSS Plugin for Eclipse.

Seems to work pretty well. The initial refresh from VSS takes an age, which is inevitable, but after that it's all really smooth, and much more convenient than swapping between Eclipse and VSS Explorer and navigating down to whatever it is that you want to check out or whatever.

BTW - some useful Eclipse options here, including -vmargs, which allows you to pass arguments to the underlying VM.

An end to OutOfMemory errors, perhaps? Just shove -vmargs -Xmx128m on the end of your Eclipse shortcut, and off you go. (See java - the Java application launcher for available VM arguments as at Java 1.3).

Posted by Simon Brunning at 03:47 PM | Permalink | Comments (2)
Open Source a threat to Java?

Sun's CEO Scott McNealy contends that Open Source is hurting Sun (and J2EE) in its fight against Microsoft (and 'NET).

In Sun's J2EE Standard Needs JBoss, Marc Fleury, JBoss founder, contends this.

O'Reilly's William Crawford has some interesting reflections on all this in J2EE Open Source.

VB and Java the only successful languages of the last two decades? Hmmm. Well, it really depends upon how you define successful. In terms of market share, I suppose that he's right, but people are successfully using Python, Ruby, Haskell, Objective C, PHP, Tcl and especially (shudder) Perl to develop useful tools, to name but a few. None of which detracts from his essential points.

It is certainly true that Java isn't really delivering revenue for Sun. But then, as Joel points out (Headline: Sun Develops Java; New "Bytecode" System Means Write Once, Run Anywhere), a hardware company developing a system which effectively makes hardware a commodity was always rather an odd decision. I'm not sure that you can pin the blame on Open Source!

Posted by Simon Brunning at 10:21 AM | Permalink | Comments (0)
September 04, 2002
Java hits obstacle with cell phones

Java hits obstacle with cell phones

So much for Evo on mobile phones...

Posted by Simon Brunning at 01:24 PM | Permalink | Comments (0)
C# vs. Java

A Comparison Of Microsoft's C# Programming Language to Sun Microsystems' Java Programming Language

Some interesting stuff here.

Java desperately needs a foreach statement, properties and variable length argument lists. Especially foreach.

C# isn't cross platform, and exception handling looks weak.

Naturally, Python has all this. God, Python programmers are spoiled!

Update September 13th: A Comparative Overview of C#, another C# vs. Java comparison.

Posted by Simon Brunning at 11:48 AM | Permalink | Comments (2)
JSPs, the MVC model, and Struts

Java Server Pages (JSPs) can easily tempt you into what Bitter Java refers to as the Monolithic JSP antipattern.

The solution to this is the Model-View-Controller (MVC) pattern. The Struts framework exists to help you implement this.

Struts, an open-source MVC implementation is an excellent introduction to Struts and the MVC pattern. It also covers tag libraries - J2EE's way of avoiding the ugly mixture of HTML and Java which can easily result from JSP development.

The example shows a typical Monolithic JSP refactorerd into three simple components, only one of them Java code. Beautiful.

Struts and Tiles aid component-based development covers updates to the Struts framework between versions 0.9 and 1.1.

Posted by Simon Brunning at 09:19 AM | Permalink | Comments (0)
September 03, 2002
Eclipse Workbench

Eclipse-Workbench.com is a site dedicated to the Eclipse open-source community.

It links to articles and plug-ins, and has an FAQ.

Also worth a browse - the Eclipse Wiki. The JDT Key Bindings, Remote Java Debugging and Interesting information got by Martin Möbius
pages are all worth a look.

BTW, Eclipse 2.0.1 is out. I used the Software Update feature to update automatically, and it worked fine - as smooth as silk. The same cannot be said for a couple of my colleagues - it didn't seem to do anything for them.

Ah well - Mark has never got on with Eclipse. It just doesn't like him. I think that it's 'cos he's a VB man at heart - Eclipse resents it. I've recommended to him that he stick to Notepad. Or EDLIN.

Posted by Simon Brunning at 02:06 PM | Permalink | Comments (0)
September 02, 2002
Java roundup

Java bits & bobs.

Update:

Posted by Simon Brunning at 09:12 AM | Permalink | Comments (0)
August 27, 2002
Effective Javadoc

Java theory and practice: I have to document THAT?

Put your hands up, this is the code police. We know that you haven't been including package descriptions in your Javadocs. Are you going to come quietly, or do I have to wear earplugs?

Posted by Simon Brunning at 05:16 PM | Permalink | Comments (0)
August 23, 2002
Object-relational data binding using Castor

Get started with Castor JDO - the basics of working with Castor JDO, an open source data-binding framework in 100 percent pure Java.

Posted by Simon Brunning at 02:09 PM | Permalink | Comments (0)
PDF generation

Cameron Laird and Kathryn Soraiz's Yes You Can talks about generating PDF, specifically from Python.

It lead me to Etymon™ PJ Classic, though, an open source Java library for PDF generation.

Posted by Simon Brunning at 01:54 PM | Permalink | Comments (1)
August 21, 2002
Using Tomcat in Production

Interesting discussion on Slashdot - Who is Using Tomcat or Jetty in Production?

No one recommending Websphere, I notice.

We are using Tomcat for our latest product, but we haven't rolled out to our largest clients yet...

If we end up with scalability issues, there are some alternative J2EE servers mentioned here which we can look at.

I've been looking at JBoss anyhow. Tomcat gives you Servlets and JSPs, but not EJBs. JBoss gives you the whole J2EE stack.

Posted by Simon Brunning at 09:38 AM | Permalink
August 15, 2002
UML modeling in Eclipse

Rational XDE is a plug-in for IBM's Eclipse based Websphere Studio allowing round-trip visual UML modeling.

It includes pattern wizards, database modeling, J2EE support, and loads of groovy stuff.

Very cool. But $3595! Don't think I'll be getting it...

There is a Visual Studio.NET version too.

Posted by Simon Brunning at 12:22 PM | Permalink | Comments (1)
August 13, 2002
SuperWaba 3.0

SuperWaba 3.0 is out.

SuperWaba is a Java Virtual Machine for mobile devices.

MobileCreator 1.3 is an IDE for SuperWaba.

See also Galmast - an interesting looking strategy game for Palm.

Posted by Simon Brunning at 05:30 PM | Permalink | Comments (0)
JTOpen

JTOpen is the open source version of IBM's Java toolbox for iSeries. JTOpen--The Right Tools for the Job is a nice introduction.

I am using JTOpen in my current project - mainly the JDBC driver.

Posted by Simon Brunning at 04:00 PM | Permalink | Comments (0)
August 07, 2002
Java 3?

10 Reasons We Need Java 3.0.

Via SlashDot.

Posted by Simon Brunning at 01:29 PM | Permalink | Comments (0)
August 06, 2002
Weak, Soft and Phantom references in Java

Reference Objects and Garbage Collection By Monica Pawlan.

See also O'Reilly on the WeakHashMap class, and an implementation of SoftHashMap, which is missing from the Sun library.

Weak references exist in Python, but unfortunately soft references do not. Which is a shame, 'cos they are very useful for eliminating memory leaks from data caches.

Posted by Simon Brunning at 01:51 PM | Permalink | Comments (1)
July 24, 2002
Mastering Regular Expressions, 2nd Ed

Mastering Regular Expressions, 2nd Ed, is out. The author explains What's New with Regular Expressions.

Python and Java coverage much expanded, apparently.

Update August 30th: Order placed with Computer Manuals.

Posted by Simon Brunning at 01:50 PM | Permalink | Comments (0)
July 23, 2002
Working the Eclipse Platform

Working the Eclipse Platform describes the basic structure of the Eclipse platform and how it operates.

Posted by Simon Brunning at 02:39 PM | Permalink | Comments (0)
July 19, 2002
Running an iSeries Command from Java

iSeries Toolbox for Java: Running an iSeries Command.

There is a bit more to it than you'd think, but it's all covered here.

Posted by Simon Brunning at 03:58 PM | Permalink | Comments (0)
July 15, 2002
Bitter Java

Bitter Java is available for free download.

I have heard good things about this book, so I'm looking forward to having a look.

I prefer dead-tree books, though, so if it is good, I'll almost certainly buy it. I have before.

Update 23rd July: It is good, and I did buy it.

Two main threads to my feelings. First, it is a great book for learning about patterns, if you are a J3EE developer, because it is so practical and hands-on.

Secondly, I get a bad feeling about my current project, because we have fallen into so many of the traps written about in this book. (We are not pooling connections, and our caching will leak memory.) Still, at least I know how to fix it!

Posted by Simon Brunning at 02:04 PM | Permalink | Comments (0)
PyUT

PyUT is a UML class diagram editor with Python and Java round-trip support.

Or it will be...

It's going to be good, though - see the features list and screenshots.

Posted by Simon Brunning at 01:15 PM | Permalink | Comments (1)
July 04, 2002
Some fab online Java games

At Hexatron.

Posted by Simon Brunning at 01:46 PM | Permalink | Comments (0)
July 01, 2002
Connection Pooling with Tomcat

Connection Pooling with Tomcat is just what I have been looking for - I've been trying to work this out for hours!

Dive into connection pooling with J2EE is a good follow-up read, but it doesn't have a simple step-by-step guide to getting started.

Posted by Simon Brunning at 02:21 PM | Permalink | Comments (0)
Eclipse 2.0 final released

Get it here.

(It's a bit slashdotted, so be patient.)

See also the Slashdot coverage.

Nothing to report myself as yet - I'm still downloading!

Update: Downloaded & installed. I can't see anything different, but that's only to be expected, since I've been running a release candidate for a while.

Posted by Simon Brunning at 09:46 AM | Permalink | Comments (1)
June 28, 2002
Open source web application servers.

Open-source servers today discusses a number of interesting web app platforms.

I use Apache and Tomcat at work. Java is my company's platform of choice, and we are doing a lot of servlet stuff. Seems to work beautifully. Small footprint too - WebSphere is a monster.

JBoss and Enhydra I will look at further - I'm just reading up on J2EE now. (Java for the Web with Servlets, JSP, and EJB. Good. A big book, but that's 'cos it covers a lot.)

I have mentioned Zope before.

(Via Daily Python URL)

Posted by Simon Brunning at 01:29 PM | Permalink | Comments (1)
The case for static types

The case for static types at developerWorks is an interesting counterpoint to Cameron Laird and Kathryn Soraiz's article.

I'm beginning to think that the thing that I dislike most about Java is not the static typing. I think it is mainly down to the fact that you cannot override the built-in operators ('+', '-' and so forth).

This, combined with the fact that the common data structures (Vectors, Hashtables and so on) are not built-ins, but come as part of the standard library. It seems to me that 80% plus of my code involves these data structures. Due to the fact that every operation requires an explicit method call, the code is very verbose. They don't call Java 'Object Oriented COBOL' for nothing!

In Python (You knew I was going to get on to Python, didn't you!) you can override operators, and high level data strictures are built-in. So you can iterate through any sequence with a simple:

for item in sequence:
item.whatever()

Lists and files are both sequences, so both can be iterated with this syntax. And because you can override operators, you can make sequences of your own simply by overriding a couple of methods, and then process them with this syntax. Beautiful.

Posted by Simon Brunning at 11:50 AM | Permalink | Comments (0)
June 27, 2002
Stargate Eclipse - iSeries Development Update

The dawn of Eclipse.

My boss and I attended the Stargate event at IBM yesterday. There we were shown the new version of the WebSphere Development Studio Client. This comes in a bewildering variety of versions, and consists of an equally bewildering array of subcomponents. All of the versions of WDSc, and all of the subcomponents were referred to by acronym, and all the acronyms began with W, and we were thoroughly confused.

But anyway, the long and the short of it is that if you are an iSeries shop, you get the lot.

The new version of WDSc is based in the Eclipse framework. As anyone who has used Eclipse will know, it is just beautiful.

Eclipse is basically a framework for building IDEs, and other things. It ships with a plug in which makes it into a Java IDE, which as I said, is superb. Tools vendors other than IBM are also basing tools on Eclipse.

WDSc consists of a number of plug-ins to Eclipse to enable iSeries development. It has tools to navigate libraries and objects on the iSeries - think of a cross between PDM and Windows Explorer, but with filtering options more powerful than either. You can edit and compile RPG, DDS and so on, with any one of several powerful editors. SEU is ancient history now.

There are also some powerful tools for developing Java based web applications possibly involving iSeries components, though not necessarily. The tools for building JSPs, beans of various types (including EJBs) and so on are powerful. There are also tools to building wrappers around iSeries based RPG modules and turning them into beans and/or web services.

All great stuff, and for iSeries development it is going to be wonderful.

It is missing one crucial set of tools, though, as far as I am concerned. There are no tools for refactoring RPG. All these clever tools which IBM provide are meant to work on nice modular systems, where your presentation and business logic are nicely separated. Our legacy system isn't like this - it consists of large programs (5000 to 15000 lines) with the business and presentation logic thoroughly mixed. There are no separate callable modules implementing business functions, and that is what much of the new tooling requires.

Now, obviously there is no way to automate the modularise of a large program - it is inevitably a manual job, and a big one. But there are tools which can help - or there could be.

The Java development tools which ship with Eclipse include a number of powerful refactoring tools. For example, you can highlight a block of code and extract into a separate function (method). All inputs to and outputs from the selected code are automatically worked out, and turned into parameters (arguments). If large RPG systems are to be modernised, this is the sort of tool which we need.

I brought this up at the event. IBM have no plans to build this sort of thing into WDSc. Eclipse is totally modular and extensible, though, so anyone could do it. It was suggested that this might be an opportunity for my company! We are not a tools vendor, though, so it isn't going to happen. There were a number of tools vendors present, though, and a couple were interested enough in the idea to come and talk to me...

The latest version of WebFacing was also demoed - on which more later.

Update: Eclipse Forces Developers Across the Java Divide at the iSeries Network.

Update 02 July 2002: See Welcome to the Dawn of Eclipse by Phil Coulthard and George Farr, the guys who presented Stargate. Plenty of screenshots, and lots about the RPG tooling.

Posted by Simon Brunning at 11:50 AM | Permalink | Comments (1)
June 25, 2002
Eclipse 2.0 Gold Master Candidate online

According to the Master Schedule, Eclipse 2.0 will be online on Friday. GM2 is already up, so they seem to be on schedule.

The GMn drops seem to be pretty much like release candidates.

Posted by Simon Brunning at 04:25 PM | Permalink | Comments (0)
Stargate Eclipse - iSeries Development Update

Tomorrow, I'm going to IBM's Stargate Eclipse - iSeries Development Update event. Should be interesting.

No updates tomorrow. ;-)

Posted by Simon Brunning at 01:38 PM | Permalink | Comments (1)
June 20, 2002
The truth behind programming languages

Brainfuck, Mueller: "I wasn't aware of the existence of Perl". ;-)

More about Brainfuck.

Posted by Simon Brunning at 03:07 PM | Permalink | Comments (1)
June 14, 2002
Developing for the J2EE Tomcat Platform

Developing for the J2EE Tomcat Platform is a J2EE tutorial from masslight.

This could not have come at a better time - Java Tools For Extreme Programming turns out to assume a lot more J2EE knowledge that I currently have.

(Via diveintomark)

Posted by Simon Brunning at 12:57 PM | Permalink | Comments (0)
June 13, 2002
Platform dependent bugs

developerWorks' Java Zone has an interesting column - Platform-dependence "gotchas".

We have really got to do some cross platform testing!

See also Java optimization techniques.

Posted by Simon Brunning at 03:10 PM | Permalink | Comments (0)
June 12, 2002
New release of omniORB

A new version of Duncan Grisby's CORBA ORB for C++ and Python, omniORB, has been released.

I saw Duncan speak at this year's Python UK conferance. He sold me on CORBA, I must say, but I haven't put it to use yet. I wouldn't be surprised if I used CORBA with Java first.

Posted by Simon Brunning at 03:32 PM | Permalink | Comments (0)
Software installation with Ant

A good introduction to Ant at O'Reilly onJava.

(Via Babu)

Java Tools For Extreme Programming finally turned up, after going to the wrong address at first. I'm not far into it yet - I'll write more when I am. Just going from the introduction, though, Ant looks wicked powerful. The source control (including VSS) and web application integration make it a must-learn.

Posted by Simon Brunning at 01:13 PM | Permalink | Comments (1)
June 07, 2002
Eclipse community projects and plugins

There is a new community projects and plugins page on the Eclipse site.

Jalopy and CheckStyle look interesting on the Java side. Still nothing Python related though. :-(

Posted by Simon Brunning at 01:17 PM | Permalink | Comments (4)
June 06, 2002
Robocode

IBM alphaWorks' Robocode is sweeping the net.

Basically, the idea is that you write the code for a program which controls a virtual robot. An armed-to-the-teeth robot. Looks like excellent fun. I must give it a go.

See also this article on developing Robocode with Eclipse.

It's not the only game in town, though - see also intergalactics. I'm generally more of a strategy man anyway, so this looks even more interesting, if rather harder.

Posted by Simon Brunning at 04:31 PM | Permalink | Comments (0)
Using Swing with Jython

Useless Python has an article on Jython and Swing.

Other good tutorials and code snippets here too. Worth exploring if you have some time while you are waiting for the Python Cookbook.

(Or you could always look at the cookbook online.)

Posted by Simon Brunning at 02:09 PM | Permalink | Comments (0)
Eclipse F2 is out.

Eclipse F2 - get it now!.

Other Ecllipse news:

New version of WebSphere Development Studio to be based on Eclipse.

QNX Releases Eclipse-based IDE.

Posted by Simon Brunning at 01:34 PM | Permalink | Comments (1)
May 29, 2002
Language Neutrality and the Java Platform

Interesting links from Lambda the Ultimate.

Of course my favorite language has been implemented on the Java platform, so it's good enough for me!

Posted by Simon Brunning at 01:57 PM | Permalink | Comments (0)
May 23, 2002
Yet more new Eclipse stuff

A long way off, though. The Graphical Editor Framework (GEF) proposal looks very interesting.

Amongst other things, it could form the basis for a GUI builder.

According to the Tools Charter, XML and Python support might also be in the works.

Yesterday's new version is looking good, too. A few menu options have moved around, which take a bit of getting used to, but it feels really solid.

Posted by Simon Brunning at 01:35 PM | Permalink | Comments (0)
May 22, 2002
Eclipse Freeze Build F1

Eclipse Freeze Build F1 is out. From now on, expect only bug fixing - no new functionality will be added.

This build shouldn't crap out when a project rebuild hits huge numbers of errors. This is generally a problem when one of your main classes has a compile error, and then many other classes in the project which refer to it also fail. We have over two thousand classes in our project, almost all of which extend a single abstract class. When that fails to compile, we generate huge numbers of errors - over forty thousand - and this tended to break Eclipse. Hopefully, this won't happen any more.

Other Eclipse news - an AspectJ plug-in seems to be in progress. For more about AspectJ, see the AspectJ web site, this developerWorks article, and these JavaWorld articles.

Update: I've installed it, and it works fine. The preferences have been cleaned up, but I havn't spotted any other changes yet.

Posted by Simon Brunning at 12:33 PM | Permalink | Comments (0)
May 21, 2002
Eclipse 2.0 soon

According to the release schedule for Eclipse 2.0, it will be released at the end of June.

We use Eclipse as our IDE for Java development. It is bloody good.

It is also going to form the basis of future versions of the WebSphere Development Tools for iSeries. RPG in Eclipse - I can't wait!

There are also Eclipse plug-ins for C# and Ruby - perhaps a Python plug-in is in progress? Can't find one.

Posted by Simon Brunning at 12:33 PM | Permalink | Comments (0)
May 20, 2002
What is Well-Commented Code?

Interesting discussion at Slashdot Developers.

I must say that I am commenting a lot less these days. Using modern IDEs like Eclipse or Boa, long names are not a problem., so I'd rather give a function a self explanitory name, and not bother commenting it at all.

Back on the iSeries, 90% of my work is on existing RPGIV code. With a six character limit on field and subroutine names, well, loads of comments are needed..

One of the comments on the /. discussion agrees with this. And has a link to a Radio 4 live feed! Cool!

Posted by Simon Brunning at 12:57 PM | Permalink | Comments (1)
May 16, 2002
Prevayler

Prevayler looks like an interesting solution for small scale object persistence in Java.

There are a couple of articles about it over on Advogato.

The big problem with this so far as I'm concerned, is that everything is kept in RAM (like Gadfly). They can talk about Breakthroughs In Memory Technologyand servers with multi-gigabyte RAM, but I'm used to working with multi-gigabyte databases, and in the real world, you just don't have that kind of RAM available.

I'd like to give it a try for something small, though.

Posted by Simon Brunning at 01:01 PM | Permalink | Comments (2)
May 15, 2002
Jakarta-Tomcat tutorial

O'Reilly are running a series of articles on Jakarta-Tomcat.

See Part 1, Part 2, Part 3 and Part 4.

I've recently started using Java servlets, and these articles taught me everything I needed to know about their deployment. Well worth a read.

Posted by Simon Brunning at 01:38 PM | Permalink | Comments (1)
May 02, 2002
Jython Essentials

I picked up Jython Essentials on my way home last night, more or less on a whim. I don't actually use Jython, but a juxtaposition of my language of choice, my favourite technical publisher, and my workaday language was impossible to resist.

Its a good book, and I learned a lot about Jython. It's even cooler than I thought. You can subclass Java classes in Jython, or vise versa. A Java class subclassed in Jython can then be re-subclassed in Java again. It's just all too cool to be true!

Type conversions between the two languages is pretty much automatic, though you can get fine control if you want it. You can embed Jython in a Java app if it needs scripting. You can compile a Jython app into a single Java class or jar, either a small one requiring the jython.jar to run, or a big standalone one. And the interactive prompt is a brilliant way to explore the behavior of Java existing classes, and to smoke test your own. It's a one stop shop for all your Java scripting needs.

It also got me thinking again about why I prefer Python to Java so much. The things which irritate me the most are these:

  • Boiler plate code. This is the code which you end up writing again and again and again. Looping through the containers, for example, requires so much code. Now I don't object to verboseness as such - where it adds value. But where it just adds characters, it's irritating. Python's


    for line in list:

    line.whatever()


    syntax is perfectly comprehensible, and concise.


    And don't get me started on Enumerations...


  • Integration of data structures into the language. You can't override the the built in operators for classes, which leads to very verbose code.


  • Hand holding. If Java tells me one more time that a local variable 'may not have been initialised', when I know damn well it will have been, I swear I'll scream.

Having said all that, Java has its pluses - interfaces are really cool, and JavaDoc is a wonderful tool.

Posted by Simon Brunning at 03:59 PM | Permalink | Comments (0)
May 01, 2002
Syntax Checking the Scripting Way

Cameron Laird and Kathryn Soraiz's article is well worth a look.

One of the most frequent objections to scripting languages (such as Python) is that their lack of static types and declarations will make your code buggier. Until I tried Python, I would have thought the same thing myself. In practice, though, it just doesn't seem to be a problem.

At work, I use Java. Sure, some of the mistakes that I might make are picked up at compile time (or earlier, using a smart IDE like Eclipse). But only some of them. So I have to unit test thoroughly anyway. So all that the static type checking buys me is that I find some errors earlier than I otherwise would.

This would be good, except that static type checking makes me jump through a lot of hoops sometimes to get stuff done. I am certainly many times more productive with Python than with Java.

Now, I would never have discovered this unless I had given Python a try. Dave Thomas and Andy Hunt recommend that a professional developer should learn one new language a year, and preferably one based upon a new paradigm. I'll second that.

My next target is the functional language Haskell.

Posted by Simon Brunning at 03:58 PM | Permalink | Comments (0)
April 29, 2002
Java Tools For Extreme Programming

(Book review at Slashdot.)

This looks interesting. I've not practiced Extreme Programming (XP) myself, but I'd like to work up the courage to have a go.

Actually, I'm not in a position to make this decision. If my team don't practice XP, then I can't.

For more about XP, see the Extreme Programming Roadmap at the original Wiki Wiki Web. This is also home to the Portland Pattern Repository. Be warned - you can lose days here!

But even without XP, this looks useful. It has sections on Ant,JUnit, Cactus and HttpUnit, all of which would be useful even outside the context of an XP project.

Posted by Simon Brunning at 05:47 PM | Permalink | Comments (1)
Eclipse coming on nicely.

The latest (R5) drop of Eclipse is really nice.

It's the tool I use for 95% of my Java development work, along with a bit of jEdit (which has some nice plug-ins).

The auto-completion works really well, and the refactorings are fantastic. The template stuff is also really good.

A Python plug-in for Eclipse would be wonderful, but I don't hear of one in the works.

Posted by Simon Brunning at 05:08 PM | Permalink | Comments (1)
AWT Table component.

I've got the go ahead to use T. Studer's AWT Table component in a work project.

Looks pretty good so far, but I can't work out how to grab mouse-click events on the rows and column headings.

Posted by Simon Brunning at 10:36 AM | Permalink | Comments (2)