Archive for January, 2006

Yet another Eclipse / NetBeans comparison

Sunday, January 29th, 2006

A week or so ago, I downloaded NetBeans 5 RC2 specifically to play with the mobility pack, but figured I might as well explore its capabilities as a J2SE IDE.

For those of you who like their blog posts short and snappy – “Neat, some cool stuff in there, but I’ll be sticking with Eclipse for now”. For those who can handle a couple more paragraphs, read on…. :)

To start with, can I join the crowd and say “Matisse rocks!”? Matisse is the visual editor for Swing apps, and it is fantastic – in 90% of cases it does what you mean: you put an object right on the left border, and it figures that that object should be anchored to the left. You place one button next to another and it keeps them together and snaps them to be level. I played with Eclipse’s Visual Editor in a recent small project, and it has a ways to go to catch up to this.

But (and there’s always a “but”, right?), the killer for me was that “90% of cases” phrase – its the other 10% that comes back to bite you. For instance, I wanted to do a a little “cross” of buttons – and up, down, left and right, laid out in a diamond. After having been spoilt with the editor doing what I meant for the rest of the UI, I found it a bit jarring when I was doing “free form” component layout – buttons were slightly off, by a pixel or two and it kind of “looked” wrong.

There’s probably a hidden “layout in a cross” option I missed :) . And I could have added a panel, set it to GridBagLayout and done it that way (Matisse has good support for GridBag). And how often do you want to have buttons in a bizarre shape like that anyway? But it kind of broke the spell for me in a way. I’m a big believer of being “in the zone”, development-wise, and switching between IDE modes (code and visual) is a real context switch for your brain – to compensate, I think I need almost perfection from the Visual Editor. Matisse is soooooo close, but isn’t quite there for the fiddly cases. (How would I have liked Matisse to handle my peculiar layout requirement? I have no idea!).

Matisse is the big ticket item – the rest of the IDE is good, but not compelling from where I sit. There are some winners, though. I love the idea that the IDE is ant based – take your development directory, zip it up and give it to someone else, and they can compile, test, build, etc. Ant seems to be the one big constant across teams – it makes so much sense to have it as the backbone of your development processes. And the fact that a test folder is created when you start a new project is a little nicety, but a good one.

On the downside, on my machine (2 Ghz with a ridiculous 512Mb of RAM), NetBeans is noticeably more sluggish than Eclipse – maybe this is an SWT thing? (I hope not, I’m one of those Swing fans ;) ). And the plugin environment for Eclipse seems so much richer at the moment – I even have a VI plugin for my Eclipse for when I’ve been doing a lot of Unix work and keep on putting the letter “i” throughout my source code (you Unix guys will know what I mean)!

So, I’m staying with my Eclipse for now. It was certainly worthwhile to check out though, and I’m still planning to do my next little J2ME project with NetBeans – I’m keen to give that Mobility Pack a proper workout.

Developer.com article on Code Reviews

Thursday, January 26th, 2006

There’s a worthwhile article on code reviews at developer.com at the moment called Effective Code Reviews Without the Pain.

Its a quick read, and the title says it all. The article’s focus isn’t so much on what your code review should cover, but how your code review should be carried out – how to make what can feel like a very adversarial, negative process into a postive, learning process. There’s tips for both the code reviewer and reviewee, with points like “Avoid ‘Why’ questions” and “Remember that the code isn’t you”.

Good, common-sense stuff. Its rare to find a development area that doesn’t use code reviews nowadays (even if only intermittently! ;) ), so it should be worth a read for most developers.

Comment on Slate Article – “Keeping Secrets”

Wednesday, January 25th, 2006

I’ve just read an interesting article at Slate called “Keeping Secrets“, where the author, a Professor Tim Wu makes some interesting points:

  • We have to assume that the US Government (and others) will one day succeed at getting at Google’s search data (which includes semi-identifying information like a searcher’s IP address)
  • While this identifying information has some value in improving the quality of search, that does not outweigh the potential privacy implications
  • Seeing as there is little hope in reforming the Government’s attitude towards protecting freedom, the public should demand this protection from Google and ask them to stop storing the information.

(This isn’t a complete summary by any means – I encourage you to read the full article to get the complete context)

Its an interesting argument, but overall, I’m not convinced. The point that jars me the most is the last one, which he puts thusly:

Recent events suggest that relying on the present administration to protect such basic freedoms may be, shall we say, unpromising. Other governments are just as bad if not worse. That’s why the public’s demand must be of Google—not the state.

That really strikes me as back to front. Democratic Governments are our representatives. Their job is to represent us. If they are behaving in a way that goes against our wishes, then we get to fire them (come the next election). In this age of massive election campaigns, spin doctoring and presentation over substance, that concept may seem a little idealistic – nontheless, that is the principle on which most Western systems of government are based. (I happen to be an Australian, not an American, but the same principles apply).

I’m also not convinced of the argument that the disadvantages of storing the data outweigh the advantages. While Google (and the other search companies) are doing this purely out of self-interest, I’m the one who eventually benefits – I get to find what I’m looking for quicker and more efficiently, in an increasingly disorganised Internet. If you like, I’m trading – “you get to see where I’m going, in return for you providing me with better service”. And importantly, if I decide that I don’t wish to do that trade (some, or all of the time), there are third party services (anonymising proxies) that will let me keep my identity cloaked.

Just my idle thoughts on a pretty weighty topic….

First impressions of J2ME development with Netbeans and the Mobility Pack

Monday, January 23rd, 2006

With my recent interest in J2ME development, I found the time to download Netbeans and the J2ME Mobility pack. I have to say I’m quite impressed.

I’ve downloaded both version 4.1 and the 5.0 Release Candidate (RC2). One of the first things that impressed me is they both perform quite well on my (slightly …mature) laptop. Once things start up, its all quite snappy. I can find Eclipse a bit laggy at times. Of course I haven’t really put these tools through their paces yet with any advanced projects – this is really just a summary of my first inspection.

The big drawcard though (for me) is the Flow Design screen. Here’s a sample screenshot:

NetBeans J2ME Flow Design

Basically, this tool helps you set up the skeleton of your applications. You drag all the different screens onto your workspace, and connect them to illustrate program flow. For example, the default project comes with a “Hello World” program that has an exit option. The screenshot above shows me inserting an “Are you sure?” screen when a user chooses “exit”. So, the exit option now connects to the new screen which presents them with OK and Cancel options. Cancel directs you back to last screen and OK takes you to the “Exit” state. Took me 20 seconds.

This is a great idea for mobile development – compared to a Swing application, a mobile app is likely to have large number of different screens/forms that all interconnect due to the limited screen real estate. This feature really takes the drudge out of that.

You also have a Screen Designer for placing widgets (“Items”) on your screen. Also great, although not as ground breaking as you may think – J2ME’s layout capabilities are pretty simple, so there’s less advanced formatting required (or even possible!). Very handy nontheless.

Once you have your rough architecture sketched out, adding your code is pretty straightforward – the generated code is reasonably clean and well thought out. Versions 4.1 and 5.0 differ slightly in their approach as to how you integrate your custom code:

  • In version 4.1, the generated code is “locked” and uneditable. One of the forms allows you to insert some code in the generated sections (with which you might do a “callMyMethod()”). You can then go to the code view and fill out the implementation. This feels a bit limited, especially as the form doesn’t seem to be able to do intelligent auto-complete.
  • In version 5.0, the generated code is “kind of locked” ;) . You can’t change it, but you can add to it. So, you generate your code structure, open it up in the source view and add whatever behaviour you want.

(At least thats the way it appears after a 15 minute look, without reading any of the help doco!)

I think it all looks pretty cool. The biggest thing holding me back is that I’m an eclipse guy, so I’ve got a bit of a hurdle getting used to the new user interface, keyboard shortcuts, etc. But its compelling enough that I’m going to have go at using NetBeans as my J2ME development tool, while still keeping Eclipse as my normal Java IDE. I’ll keep you posted as to how I go…

Worm Farms – being a bit green in a townhouse or apartment

Friday, January 20th, 2006

I’ve found moving from a house to a townhouse quite the change. I mean, I love it and all, but veggie gardens are a little tough with only a small, concreted courtyard. And compost bins are right out! ;)

And without a compost bin, I was getting that twinge of hippy-guilt – thats when your inner Greenie is rebelling against your actions – everytime I chucked leftover vegies in the bin. Not to mention that towards the end of the week, things could get a bit gross….

The answer (well, partial answer) is a worm farm. Pretty straightforward concept – stacks of plastic containers which you populate with some worms. You chuck your scraps in, the worms eat it. As the population of worms grows, you add containers on top of the stack. And when you get to four stacks, or so, you empty out the bottom one (which has now broken down to good chocolatey soil) and keep on going.

Perhaps a piccy will make things clearer:

Worm Farm

While not the kind of thing you’d have as a centrepiece in your living room, its not an eyesore – I have mine in my garage. It’d easily fit on a balcony. If you have it running OK, it has a kind of musty, rainforesty smell to it – nothing like some composts you may have encountered.

There’s some caveats – worms aren’t big fans of citrus or onion. And feeding them meat is a Bad Idea (plus you wouldn’t want them developing a taste for it… :) ). But, generally a big win. Maintenance is so low as to be non-existent. Its way better for the environment (chucking scraps in the bin, and thus to landfill, tends to end up resulting in anaerobic composting, which releases heaps of methane). And if you have pot plants (or a small garden), the resultant soil and liquid is fantastic for them.

Mine cost about $80 (AUD). You could probably make your own without to much hassle.

Doxygen – Javadoc for the C++ brethren

Thursday, January 19th, 2006

Typically, I work in Java. When I’m not working Java, I’m working Perl. Sometimes I even do work in Prolog (no, really!). But once in a while I venture into the C++ world.

I’m not a fan. Having my classes split across multiple files. Having the parent class decide what I can and can’t subclass. Trying to decide whether the caller or callee has responsibility for deleting an object. That said, there is a Perl-ish “Theres More Than One Way To Do It” (TMTOWTDI) thats kind of nice.

But with all the complexity inherent in a C++ program, documentation is all the more important. A work mate put me on to doxygen. It can be summarised as Javadoc for C/C++. Technically, its more than that – it can handle a range of languages and input files (even Java!), but the largest use appears to be the C/C++ arena.

Just like Javadoc, you create special comments throughout your source code, which get turned into documentation. And, you can insert special directives in these comments which have special meanings. Some favourite examples are:

  • @todo to flag a To Do item – your documentation will include a TO DO page summarising all these items
  • @version to detail what is in a particular version
  • @bug to flag a bug. Again, your documentation will include a bug page summarising all flagged bugs

In some ways, Doxygen is more powerful than Javadoc, out of the box. It can generate HTML and LATEX formats (Javadoc can do LATEX, but you need a custom doclet). The default pages show the class hierarchy, as well as providing links to the source code, neatly colourised and formatted. And most impressively, it can integrate with DOT from GraphViz to do graphical representations of the class hierarchy, as well as simple “has-a, is-a” type diagrams.

The flexibility comes at a cost – typically you have a big config file to tell Doxygen how to run (It reminds me of the “less is more” nature of Java versus C++ – Java may have less language features, but is more straightforward to debug and use as a result). And the nature of C++ in particular, with a class definition spread over multiple files can make some of the documentation decisions tricky: Do I put the method summary and method detail in the header file, or the cpp file? Or one in each? Whichever I pick, I always end up swearing once a coding session and having to flip around source files to find the info I need.

Niggles aside, this all makes C++ programming a lot more manageable. On larger projects, I can hand over the source to another developer and know they have reasonable documentation from the start. And on smaller projects, I can keep track of the issues, and architecture more easily. If only my IDE supported it, like Eclipse supports Javadoc…. :)

J2ME Development in Eclipse – EclipseME

Tuesday, January 17th, 2006

I’ve been playing around with some J2ME development lately (thus my earlier posts on Sudokulet). The whole process has been pretty painless, thanks in large part to EclipseME.

EclipseME is a plugin for Eclipse to let you use Eclipse for J2ME development. And it fulfils my idea of a good design by changing very little about my Eclipse experience. I use Eclipse like I always do – its just I’m using a different set of APIs and the end result will run on a mobile phone. But all the normal Eclipse-y things like refactoring, etc work as normal.

As well as making J2ME “just work”, it also simplifies some of those tasks specific to J2ME. JAD files in particular (which are used to describe various aspects of your J2ME Midlet) are given a special editor so you don’t have to worry about the format of this file, or its various permitted keywords.

Also of great use is the new right menu option “Run on Emulator” (and “Debug on Emulator”). Its really handy to be able to do this from within Eclipse, rather than have to get out of the zone (and the IDE). That was one thing that used to drive me crazy in my old days when I used nothing but the Sun Wireless Toolkit to develop in.

(A note for new players – you still need the J2ME libraries which you can get from Sun, but also from various mobile vendors like Nokia, Sony, etc. The vendor SDKs also include special emulators that are more “true” to their particular phones. EclipseME supports a variety of these, and I’ve never found one that I couldn’t get to EclipseME to play with at all. However with at least one version of the Nokia SDK, I couldn’t get the “Run in Emulator” to work. It wasn’t a total loss though – I configured a “Run External Tool” setting to accomplish almost the same thing).

The development of EclipseME is nice and active, and it also integrates with other tools. ProGuard can be used in particular to obfuscate (and thus shrink) your J2ME midlet – which gets all the more important on limited storage mobile phones.

So, well worth checking out if J2ME is an area you want to get into. Its not the only option though – in particular I’m reading great things about NetBeans with the Mobility pack. As I understand it, this offers a slightly different model of graphically showing you the Midlet’s life cycle – giving you the option of more of a graphical based development process. I hope to get some time to play with it – expect a post soon! And Nokia are getting into Eclipse in a big way – an Eclipse-based tool for developing native C++ code is due out soon, and theres been talk of them contributing J2ME tools to the core Eclipse project.

Wordpress 2.0 plus….. Ads

Monday, January 16th, 2006

What a day! Upgraded the site to Wordpress 2.0, and introduced Ads. Its a surprise I have any time to do my paid job!

Well, not that surprising. The whole exercise has taken around 30 minutes – love that! The Wordpress upgrade is a doddle. The hardest part is doing all the backup steps “just in case” – the actual upgrade is soooo simple! (And, touching wood, after 4 Wordpress upgrades I am yet to need my backup files :) ).

Hard to tell from the look of the site that much has changed, but the back-end admin is much improved. AJAX really lifts the bar for what we expect from web-driven apps nowadays. Deleting comments is particularly nice – seeing them go red then fade away is kinda fun, and really satisfying when it happens to be comment spam.

As an added bonus, the SecureImage plugin I use to get Captchas (a means of preventing comment spam) worked straight away with the new version.

I’ve had ads on my company web site for some time now, to support those resources I make available for free, so I was already a member of the AdSense program. I thought I’d trial ads on the blog as a bit of an experiment. I’m using the Adsense Deluxe plugin, which seems really nice so far – this post will be the first real test of it. It seems to be under active development – last update was only a week ago.

If nothing else, the experience has been an eye-opener about the size of the Wordpress community. There’s a real wealth of extensions and experience out there!

ACT’s Water Tune-up program

Thursday, January 12th, 2006

The ACT Government offers a program for its residents called “The Indoor Water Tune-up”. Basically, they subsidise the cost of a plumber to visit your place, install a variety of simple water saving devices (like tap aerators, water-saving shower heads, etc), and give you advice. Additionally, you become eligible for other incentive programs for things like replacing single-flush toilets with dual flush. The cost to you is $30.

(Its worth checking the rest of the Think Water website too – there’s a number of other incentive and rebate programs you may not have been aware of for things like water tanks, water-saving shower heads, etc)

Even though I’ve already done a few things on my own in this area (replaced all the shower-heads, gone with a front-loading washing machine, etc), I went ahead and signed up. I certainly can’t complain about the service – when I rang to register, they offered me an appointment the next day! The guy who came round was great – friendly, punctual. Most importantly, he was a wealth of knowledge – I now know a lot more about what to consider when replacing my toilets with water efficient options.

I’m not sure how much longer the program is going to go, but I’d recommend it. If you’ve already done the obvious water saving steps, its $30 to have a plumber visit and advise you (which is good value in itself). And if you haven’t even begun to consider water efficiency, its a no-brainer: the value of a new shower head, plus the savings in water and electricity bills should have you well in front.

Comments are back, hello Captcha’s!

Tuesday, January 10th, 2006

After being motivated by a workmate (who when confronted by comment spam, hacked together a quick maths-based Captcha in an evening), I decided to install a Captcha plugin and re-enable comments.

(For the uninitiated, a Captcha is a “thing” that attempts to distinguish humans from computers – particularly handy for preventing comment spam)

I’ve gone with SecureImage as my Captcha. It requires the user to type in some random letters that are displayed in slightly distorted form for a comment to be posted. The plugin was nice and self-contained, some Captchas require the wordpress files to be hacked in various places, but all that was required was to drop the file into the “plugins” directory, then enable it through the WordPress interface.

One gotcha was the choice of font – by default, SecureImage expects to use a font called FreeSansBold. I don’t have this, and as a result got a blank image. Makes it unreasonably hard for the user to guess the random letters, in my opinion ;) . Changing the default font fixed all that though.

So, welcome back comments!