Archive for February, 2009

IDEA versus Eclipse

IDEA has been giving me grief lately. Fed up with mysterious pauses, bugs in svn moves, and crashes even after performing cache-deletion voodoo in IDE, I’m back to trying Eclipse.

Keystroke differences and functionality differences have been the major stumbling blocks. The things I miss from IDEA:

  • Refactor > Safe delete
  • A single keystroke that does svn update for the whole project
  • smart-complete that builds anonymous inner classes with the methods stubbed out automatically (I found the secret — ctrl-space after typing “new”, the interface, then left paren)
  • smart-complete that only offers classes or fields that are semantically correct (rather than eclipse’s string-matching-based complete). This is my most frequent grief.
  • The ability to group together sets of files for committing (but I think Mylyn does this) (Switch to the SVN Repository perspective, and open the Synchronize window)
  • The ability to rollback or make changes to files while still in the commit window (again, you can surf your pending changes in the SVN Repository’s “Synchronize” window)
  • There are bugs in Refactor > Move — not all string or spring XML references get fixed properly.
  • The code formatting preferences in Eclipse are much less flexible than IDEA’s.
  • I haven’t found the keystroke yet to “go to next error/warning”.
  • Spring IDE gets confused if the XML file isn’t fairly well formed. IDEA seems to still be OK if the file is in tatters.
  • ctrl/cmd-clicking targets in ant build files don’t take you to the target definition. They take you to a nearby matching string, which may or may not be the target.

Things that I found that work better in eclipse:

  • Eclipse kicks IDEA’s booty up and down the street when it comes to performance. Eclipse startup time for my large-ish work project: 19 seconds. IDEA, opening the same project: 2 minutes, 25 seconds. That’s after an initial launch and quit, so they both should be using only cached-in-RAM files. Eclipse never pauses while typing. Ever. IDEA momentarily wedges every few seconds.
  • Projects in your workspace (IDEA calls them “modules”) can be “closed” temporarily when you aren’t actively working on them. That saves memory and recompilation time.
  • You can run automatic code-cleanup fixes on save (and only apply those fixes on the lines of code that you touched)
  • The templates support auto-imports and auto-static-imports (fancy!)
  • IDEA has this artificial partitioning of file types in the project tree based on what facets are enabled in a module — there’s no simple filesystem tree widget for me to find, say, the web.xml that lives in ../web/WEB-INF/. IDEA shoves it into a “libraries” root node. Eclipse has both a project explorer and a package explorer that don’t do this weirdness.
  • Creating new JUnit tests in Eclipse is sane and intuitive. IDEA doesn’t have a junit test plugin that worked reliably for me.

Things that are a blessing and a curse:

  • Eclipse has this weird “it’s not real until you hit Save,” whereas you never click save in IDEA. A bunch of things (incremental compilation and spring validation) only happen after Save All. But you get used to that.
  • Eclipse has very flexible window management — far exceeding IDEA’s. You can dock, stack, drag, quick-hide, pile, and generally get very confused or very satisfied (depending on your experience level) with where windows are. Is an editor on the wrong side? Drag the tab where you want it. IDEA’s editor tabs on the mac simply don’t work — after N tabs are shown, the other tabs disappear, and you can activate an editor where the tab isn’t visible or in focus. So at least Eclipse’s tabs seem to be bug free.
  • Eclipse update sites that are external to eclipse.org — I added a couple plugins that destabilized things to where I couldn’t bring any window up without an exception being raised. I ended up having to start from a new bare-metal install again, but my project settings were picked up (including the new keymaps) so that wasn’t too bad.

Updated May 7th with some of the solutions I’ve come across.

Simple Log4J eclipse template

Do you use eclipse and log4j? Do you have a template to add a static Logger instance in classes? Do you have to manually add the import? HA! NO MORE!

Under Preferences > Java > Editor > Templates, click New…

Give the template a name (like “logger”).

Use this for the Pattern:

${:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class);

Click OK, OK, then incant the template by typing the name of the template and invoke Content Assist (ctrl-space on most platforms).

The import line will add org.apache.log4j.Logger to your imports automatically if it doesn’t exist already. Nifty, eh?

How to set up native subversion (javahl) with Subclipse on Mac OS X

Note that this is for Ganymede (Eclipse 3.4.x).

  1. Install the javahl binding with MacPorts:
    sudo port install subversion +bash_completion
    sudo port install subversion-javahlbindings
    
  2. Run eclipse, and add this upgrade site: http://subclipse.tigris.org/update_1.4.x
  3. Select the “JavaHL Adapter” and “Subclipse” modules and click “Install”
  4. Choose Eclipse > Preferences…, go to Team > SVN, find the “SVN Interface” pulldown, and choose “JavaHL”

Solution for mysql_upgrade errno: 13

Are you upgrading MySQL, and seeing this?

$ mysql_upgrade
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck'...
....
Could not create the upgrade info file '/usr/local/mysql/data/mysql_upgrade_info'
in the MySQL Servers datadir, errno: 13

Solution — run the script as root (so you’ll have permission to write to mysql_upgrade_info).

Skype Beta for Mac 2.8 has screen sharing

Skype Beta for Mac OS X version 2.8 adds screen sharing, and it’s easy to use — but screen sharing is only available on the Mac version of Skype.

Until they port screen sharing to Windows and Linux, teamviewer and VNC will have to make do.

java rake db:migrate implementations

I was surprised that there were so many libraries that do the same thing — manage change inĀ  your database schema. Here’s what I’ve found so far:

  • Liquibase (migrations are specified in db-generic XML)
  • migrate4j (migrations must be writted in java, and has “down” and “up” support)
  • AutoPatch (“down” and “up”, with both .sql and .java support)
  • dbmigrate (no “down” — only “up”, with both .sql and .java support, but no test coverage)
  • c5-db-migration (nice integration with maven)

I’ve used a heavily patched version of dbmigrate on my last project at work, and it’s doing what it’s supposed to. I’ve only read documentation for the other projects.