Blogs

Beware the Empty String

2 minute read Published:

Regardless of how you feel about empty strings, you should be aware of the implications of allowing them on objects that will be persisted. While it seems reasonable to expect a database to store the exact value that you give it, that is unfortunately not always the case. If you’re going to allow empty strings on persistent objects, you should take the time to determine the behavior of the database management system you’re using. You should also assess how likely it is that you are going to either have to support multiple databases, or that you will switch to another database management system in the future.

Developing Spring Roo Addons

5 minute read Published:

As of Roo 1.1.0, addons are created with the addon command. This is slightly different than previous versions, where addons were created with a template argument to the project command. If you find documentation referencing this old style, it’s probably out of date.

Static Content Alongside Jersey Services

2 minute read Published:

If you’ve worked with Jersey, you’re likely familiar with the embedded Grizzly server. Though I haven’t seen it mentioned often, Grizzly can indeed serve static content too. The following snippet is all that’s necessary to fire up an embedded web server. These examples were written with Grizzly 1.9.18-m and Jersey 1.4.

GData Objective-C Client

3 minute read Published:

I’ve recently been working on an iPhone application that integrates with Blogger, and as such I have gotten some experience with the GData Objective-C Client Library. The issues below were all encountered while working with the GDataServiceGoogleBlogger service, but they should apply to the other GData services too.

Simple Backup

2 minute read Published:

I finished putting together my personal website backup script, and it can be found on my Github page.

Moving and Copying Lines in Xcode

3 minute read Published:

Being a heavy Eclipse user, I’ve grown accustomed to its keyboard shortcuts for moving and copying lines of text. Xcode doesn’t have a regular editing command for this, but it does offer similar functionality via user scripts. The Move Line Up and Move Line Down scripts are already there, just waiting for you to bind keys to them. Go to the script menu, which is to the left of the Help menu, and select the Edit User Scripts… menu item. Expand the disclosure triangle next to Text, and you can set keyboard shortcuts by double-clicking in the column to the right of the script names. Below is a screenshot of what the dialog will look like if you follow all of the instructions in this post.

Reading Two-Up PDFs

2 minute read Published:

Some Two-Up PDFs, such as the new Pragmatic Guide Series, are intended to be read with specific pages on the left or right side of the screen. Unfortunately these types of documents don’t always display the way the author intended in every PDF reader. However most PDF readers do provide features to get the desired presentation.

Backing Up Your Personal Website

6 minute read Published:

Most website hosting companies do their own backups, but they often make no guarantees about actually recovering your data. If you put any amount of effort into a website, you really owe it to yourself to have a decent backup and recovery strategy. You don’t have to do anything too fancy or complicated, but at a minimum you should backup your home directory with tar and any databases that your website uses.

Eclipse Generated Equality

4 minute read Published:

Most users of Eclipse are familiar with its code generation features. One of the more common of these is “Generate hashCode() and equals()…” from the right-click -> Source (⌘-Opt-S) menu. It roughly follows the recipe on page 33 of Joshua Bloch’s Effective Java, and it is effective in most situations. One case where it doesn’t work is when the class is proxied. Hibernate is just one example of a framework that generates proxies. If the Person class below were proxied, the default Eclipse implementation of equals() would break. In a Hibernate application, this can lead to anything from unnecessary deletes and inserts to some very frustrating bugs.

Liquibase and the modifySql Tag

3 minute read Published:

Liquibase is a tool that helps you manage database changes. It can can be integrated into your build process to automatically update your database, and it also has a command line interface that operational staff can use to generate SQL scripts for production deployment. One of its nice features is database abstraction. You define your changesets in XML, and Liquibase generates compatible SQL for you. As with any tool that tries to provide this level of abstraction over a large number of vendors, it doesn’t work 100% with all DBMS. Below is a simple changeset.