OrmLite Tips

Recently, I featured the Java ORM library OrmLite. Here are some tips.

  • Use annotations on your domain objects. @DatabaseTable for the class itself, @DatabaseField(generatedId=true) for its id, @DatabaseField for Java types, @DatabaseField( foreign=true) for fields that are other domain objects, and @ForeignCollectionField for fields that are lists of domain objects.
  • For @ForeignCollectionField, use @ForeignCollectionField(eager=true) to make it lazy load.
  • Don’t forget to add no-argument constructors to each of your domain objects.
  • By all means, make a service (or “manager”) level that abstracts away some of the getHelper().getDomainObjectDao().queryForFieldValues() calls!

Web Performance

Steve Souders, the Head Performance Engineer at Google, has an article on web performance that is worth reading.

It it he shares his first major discovery that “80-90% of the end-user response time is spent on the frontend”.  He shows how web performance has been critical in making frontend engineering a distinct specialization.

Souders argues that specialization is necessary when tackling the problem of web performance. He concludes with this:

“What’s needed are dedicated web performance engineers and dedicated performance teams. Just like frontend engineering, these teams will start small – just one person at first. But everyone will quickly see how the benefits are bigger, are reached sooner, and don’t regress.”

Featured Library: OrmLite

At my workplace, I use an excellent ORM (Object Relational Mapping) product called Hibernate. Basically, it takes care of mapping your Java domain objects to the database.

When I began to do Android development, almost immediately I found the need to persist data into SQLite. Almost simultaneously, I saw the need to have some sort of ORM. However, Hibernate seemed to be overkill.  Hibernate is great for a large server-side app, but for a mobile app it is just so heavy with code, dependencies, etc.

That’s when I discovered OrmLite. It is truly a great project and provides the sort of lightweight ORM that I needed. It makes Android development a delight. It’s close enough to Hibernate make me comfortable and yet simple enough to make it ideal for mobile development.

Tamper Data

Web application security is obviously a huge deal right now. And yet far too many web applications are vulnerable to well-known exploits.

I believe that some newer (and older) web application developers suffer from never having been exposed to the basic details of the HTTP protocol, networking protocols in general, packet sniffing, and port scanning.

We web application developers ought to be occasionally interacting with our apps on a more sophisticated level than merely mimicking user behavior in a web browser.

Enter Tamper Data. It’s a Firefox plugin which allows you to watch HTTP requests as they are sent out to websites you access, and tamper with them.  It’s absolutely fantastic, I wish I had something like this long ago.

I wonder how much more secure the web would be if every developer would take some time to familiarize themselves with this tool and then experiment with their sites through it.

Featured Library: jsoup

jsoup is a power HTML parser for Java. It is well-suited for web scraping tasks. It is wonderful for finding, manipulating, and cleaning/tidying things in HTML.

I’ve been working a bit with jsoup on some professional and personal projects and have really enjoyed working with it. I love the way you can use jQuery-like approaches to “selecting” various tags. For example, you can invoke select( “table[class=className]” ) to iterate all tables with a particular class name.

I’ve put it to use in a couple of my GitHub projects, and android app named BorderWaitWatcher and a Java module named ScrapeTheWorld.

You can find more out about this project here.

Recent GitHub Activity

Here are some things I’ve been doing on GitHub recently:

  • Worked on ruby-museday, a  Ruby on Rails poetry submission tracker.
  • I ported Johnathan Feinberg’s Python module, haikufinder to support Python 3.x  (without breaking support for 2.x) and it got merged into the main branch.
  • I ported a fork of Bitly’s bitly-api–python to Python 3.x
  • I’ve ported Greg Smith’s PostgreSQL configuration tool pgtune to Python 3.x and called it pgtunepy3

Featured Library: jxls

jxls is a simple Java library for reading from and writing to Excel files. I’ve enjoyed using it and would heartily recommend it.

It’s great for lightweight uses, but also has a wide feature set, such as:

  • Using SQL queries directly in XLS templates
  • Simple property access notation
  • Full expression language support
  • Complex object graph export
  • Flexible collection export
  • Flow-Control Tags support
  • Dynamic grouping of data
  • Export of a single collection into multiple worksheets
  • Adjacent tables support!
  • Complex formulas support
  • Charts, Macros and many other Excel features in XLS template
  • Dynamic Outlines
  • Dynamic Columns Hiding
  • Dynamic Cell Style processing through custom Processors
  • JDBC ResultSet export
  • Merged Cells support
  • Multiple bean properties in a single cell
  • Reading XLS files

It’s licensed under LGPL.