Backwards Content Compression

You don’t see it nearly as much as you should, but some web developers and server administrators are intelligent enough to put a compression filter (or module) in front of their web servers. When a browser that supports compression, the filter / module kicks in, and compresses the HTML, Image, Video, Flash or whatever is being fetched. The compression means that the file moves over the wire faster. Or at least thats the theory.

The fact is that for some instances (generated HTML code for example), the effort of compressing the file is more than it’s worth. In other instances (large images, or any static content for that matter), compression can make a huge difference. So I’ve started working with the idea of “Backward Compression”. The files are stored as “GZIP” files on the disk, if a browser that does not support compression requests the file, my filter decompresses it and sends it to the client. This has several advantages over compressing the files:

  • Most browsers support compression, so the file can be sent as is
  • GZIP decompression is cheaper than compression
    • Less effort is expended by decompressing for the browsers that don’t support GZIP
  • You can decide up front what should be compressed and what shouldn’t

Stupid People code EJB

After so many years of coding in Java, I’ve finally decided that almost universally, stupid (or ignorant) people code EJB’s. Almost every piece of EJB code is nothing more that a data-access layer. Why on earth would you willingly incur the expense of 15 additional stack layers for each call, and the expense of marshaling and marshaling the parameters of each of those calls?

Why? Because then you can load balance the data-access layers across multiple machines.

Except.

Databases do load balancing by themselves!

The intention is generally that the business layer will go in the EJB’s and the web / fat-client layer will be a very thin layer that does calls to the EJB’s. Except it almost never works out that way, because most coders are simply to lazy, or figure out theres a huge expense in doing it that way as well (you  wind up overloading your network / internet connection with UI related calls). Although with a fat client I can understand the use of an EJB in this way.

So all you ignorant / stupid types, heres what to do:

  1. Either integrate you EJB’s into your GUI code base and be done with it.
    1. On a small project, this actually makes things more manageable
  2. More more of your business logic into you EJB’s
    1. Changing a users email address on the EJB should send the confirmation email and wait for a “confirmAddressChange” sort of method.

Arbitrary Selects in EoD SQL

Sometimes, when writing database driven applications, you need to break the PreparedStatement rule, and do a completely arbitrary select. I find I use such queries a lot when dealing with tags, since you never know how many you’re going to be working with, and some databases don’t support arrays as parameters (for “IN”).

In EoD SQL (as with the EoD RI), you construct your queries as interfaces with your query strings in annotations. This doesn’t allow you to change the SQL query at runtime, it’s fixed at compile time. So to plug this little annoyance, I decided to add a QueryTool.select method. It looks like this:

public static <T> DataSet<T> select(Class<T> type, String query, Object... parameters)

Imaging a class User with some fields that are bound to a “users” table in the database. To select all users with a specific first name, you could:

DataSet<User> users = QueryTool.select(User.class, "SELECT * FROM users WHERE first_name LIKE ?1", firstName);
for(User u : users) {
// do something with "u"
}

users.close();

Currently the code is available in Subversion, but it will be included in the upcoming 1.0 release of EoD SQL. There are several other improvements waiting to be developed, but they will wait until after the 1.0 release.

Do “Hardware People” actually use computers?

This is a bit of a rant. Being someone who just spent R1350 (~ €142) on a new stick of RAM for my laptop, I have to wonder at a quote for a desktop machine I saw yesterday. It’s for a kid who’s really into his gaming. His power-supply fried (most likely cause of all the mods he’s got in the machine with a really rubbish 350 watt power-supply). The place he took the machine to, gave him the following explination:

Something strange happened on the power-lines, and fried the power-supply. It took you motherboard with it.

Now since his motherboard currently has a 939 socket for his Athlone 2600+ CPU, and the FSB speed is not great (the whole thing is over 2 years old), they quoted him for the following:

  • Dual-Core AMD 3600+ (64bit)
  • AM2 Socket Motherboard with 1Ghz FSP
  • 512Mb Memory (833Mhz)
  • 400 watt PSU

Do I see something wrong here? First off, he’s running 32bit XP… he doesn’t have a 64bit copy of Windows, why isn’t it in the quote?!?! Why is there only 512Mb of memory, and why the hell is it 800Mhz when the motherboards FSP is 1Ghz?!? Why, because 1Ghz memory modules would be more expensive than the motherboard.

This seems to be a bad case of selling things for the highest cut.

I know the difference some extra memory can make, it’s far greater than a slightly faster CPU or faster memory will make. With a CPU like the one in the quote, it should have 2Gb of RAM in the quote. Make the whole system 833Mhz FSB, and take the CPU clock-speed down a few notches.

Bah! Enough ranting ;)
Just beware of whats in the box when you buy a computer!