In a project I was working on recently, we were building up a web page by loading up its template, content hierarchy and other information dynamically. This is a common setup, and a very flexible one since it allows sweeping changes to be made very easily. Unfortunately, this flexibility comes with a cost; pulling everything through EJB calls can give you a speed not unlike that of a slightly stunned tortoise trying to sprint up a treacle covered hill.

One way of mitigating this problem is to use a Facade pattern to load as much as possible with as few calls as possible. However, this is not always the best approach, especially if most of the content is not likely to change very often. In these cases, it’s preferable to store the content at the end where it’s being used, avoiding the remote call completely.

This can be implemented quickly and easily with a Map, but that would leave us with a lot of work to do when it comes to managing the cached content. For example, what if we wanted to make sure that the cache does not continue to fill up indefinitely, or that it gets backed to disk when it goes idle for some time to preserve memory?

Since we were already using Hibernate in the data layer, we were already using a cache at that level in the form of EHCache. It made sense to try and see if it was possible to use this in our controller layer, and it turned out to be extremely elegant to use. Read the full post

Category Development
Tags

Following last week’s implementation of the basic shape of the calendar, this week we will add behaviours so that we can pick a date on it.

This post is part of a series of three posts:

  • In part 1 we created a jQuery plugin which displays a simple static calendar.
  • In part 2 (this post), we will add the facility to pick a date, and to switch the month on display.
  • In part 3, we will add some sanity checks, and the ability to display events on given days. Read the full post
Category Development

A few years ago, I wrote a calendar control for a Code Project article. Although I’ve used it myself several times, and despite the fact that people still appear to be using it, I can’t help but cringe every time I look at it again. Every time, the thought that comes to mind is “It could have been so much cleaner in jQuery…”.

Well, the time has come to bite the bullet and see how it can be pulled off again. Rather than going over the whole thing in one go though, we’re going to take it in steps over a number of posts to implement a feature or a group of features, so we can look each in slightly more detail. This is as much for my benefit as everyone else’s. If anyone spots anything weird, inefficient, or badong in these posts, please let me know. I like to think of this as public code review, so, you know. Bring it on.

We can rebuild him – we have the technology

The posts will be divided as follows:

  • In part 1 (this post), we will deal with the display of a simple static calendar.
  • In part 2, we will add the facility to pick a date, and to switch the month on display.
  • In part 3, we will add some sanity checks, and the ability to display events on given days.

And with that, on to the post itself. Read the full post

Category Development

SHA1 in PHP and MySQL

September 21, 2009 10:59 am Comments (0)

Wrote a brief note on the speed of digests in PHP vs. the speed of the same digest in MySql.
Read it at http://fwebde.com/php/encryption-php-vs-mysql/

Category Development
Tags ,

New theme for The Simple Part

September 13, 2009 1:08 am Comments (5)

Despite my best attempts at procrastination, it had to happen sooner or later. Stephen Reinhardt’s Light theme, the free version of which has served this blog well and faithfully for the last year and something, has finally been decommissioned. Replacing it is a new theme I clobbered together over the last week.

One of the reasons I moved this blog off the old wordpress.com subdomain – the only reason in fact – was to allow me to mess around with it as much as possible. Writing the theme is one such messing, though a number of things got in the way and meant that it took a while longer to get started than originally intended.

This theme will be considered a permanent work in progress. I’d be interested in any comments, complaints or suggestions concerning its usability (or lack thereof), appearance (or hideousness thereof), or anything else which may be handy or simply cool.

With thanks to Emilyn and SZC, whose advice prevented a number of crimes against aesthetics and partly offset my inability to work with colour schemes more complex than black and white.

Category Design
Tags ,

An Up/Down control in jQuery

August 16, 2009 4:30 pm Comments (4)

Recently, I needed to write an up/down selector – you know the sort, it’s where you select a number by clicking on an up or down arrow. Since they can be useful for other things besides numbers, I gave it the plugin treatment.

Most of the information about the plugin can be found in its documentation page.

Also available is a slightly beefier styled and animated demo of the plugin.

If you’re just interested in the plugin itself, you can find it here.

This morning, I found out about a very useful jQuery function going by the unassuming name of data. This fantastic little beast creates a data store for an element, and lets you store just about anything in there.

One of the ways in which this can be used is to attach functions to an element, and using them when required. To demonstrate the usefulness of this feature, I wrote two versions of a simple validation system. In one, we use the data function to assign one or more validators to an input box [Example 1: using $(x).data()]. In the other, we iterate over the inputs and check them against validators as needed [Example 2: not using $(x).data()]. Read the full post

Generics in Java and C#

July 23, 2009 12:00 am Comments (2)

Today I was writing some interceptors in Java, and I wanted to be able to filter the input based on whether it implemented a given interface or otherwise. Class<?> exposes a very handy isAssignableFrom method for this, but it doesn’t look very nice, so I tried to go for something a bit neater, like:

   1: Feature.<TargetFeature>isImplementedBy(interceptedInstance);

Neat, and much more readable. I didn’t quite make it there, but got close enough for my purposes, and had some (very little) deeper knowledge of generics inflicted upon me for my sins.

Read the full post

Category Development

I’ve (belatedly) updated my iPhone 3g’s OS today. Just after the update, it started to heat up, and was not recharging no matter how long it was left on the charger. Restarting (hold down the home and the power buttons simultaneously for about 10s) seems to fix both issues.

First law of IT support – try restarting the bloody thing.

Category Other Stuff
Tags

Code reviews with NDepend

April 5, 2009 12:08 pm Comments (0)

Using NDepend to identify areas of interest in a code base.
Read the full post