Software Engineering


Software Engineering08 Aug 2008 10:38 pm

It had never even crossed my mind until today, but it turns out that a java finally clause is allowed to overwrite the return value. This example prints 0 rather than 1.

package com.kstruct;

public class Main {

	public static void main(String[] args) {
		System.out.println(test());
	}

	private static int test() {
		try {
			return 1;
		} finally {
			return 0;
		}
	}
}

That could get really confusing in a long / complex / poorly written function…

…and apparently things get worse and worse the more you look into them.

Software Engineering13 Jun 2008 06:50 pm

Annoyed by CSS’s lack of #define style constants, and looking for an excuse to try out with the Google App Engine, I started building with a simple app to provide a simple CSS constant expansion service a few weeks back. It’s now up and running at http://www.constantcss.com/ if anyone would like to try it out.

The service is only intended for use while tweaking your design. You’ve got to be logged in to the site to actually fetch the updated CSS file (to avoid allowing people to use the site to serve up their site’s CSS file), but it does provide a cute tweaking option by reading parameters out of the referrer URL, meaning you can tweak the CSS without changing the actual CSS source in the web page.

Here’s a very simple example of the constant syntax.

/* @cssconstants
    @define NORMAL_SIZE 10pt
*/
p {
    font-size: /*NORMAL_SIZE*/10pt/*NORMAL_SIZE*/;
}

It isn’t elegant, but is nice in that

  • The values can be updated without ever losing the information about which constants occurred where, which makes the tweaking workflow a bit smoother.
  • The file itself is still valid CSS, so you can serve it up with the constants still in there if you like.
  • If I ever go away, you could pretty easily update it with just a text editor which can do simple regular expression replacements.

The source code is also available in a git repository at http://github.com/mattsheppard/constant-css/tree/master if anyone wants to run their own version or make improvements. This is my first time using Python and Git as well, so I imagine there are currently many things being done poorly, and any pointers are more than welcome.

Software Engineering03 May 2008 05:34 pm

I just put a python script up on google code which you can use to convert an allhomes.com.au page (like this one for all the property listings in Braddon). I’m using it with NetNewsWire’s script subscription feature, and it seems to have done exactly what I want for the last week or so.

http://code.google.com/p/allhomes-rss/

(I’m pretty new to python, so anyone who’d like to take the time to point out where I’m making life hard for myself in there is most welcome)

Mac& Software Engineering03 May 2008 12:55 pm

Looks like the iPhone developer program has gone international - I’m in Australia and just got my approval. Looks like there are now 28 countries (or at least currencies) on the list. (Actually, now I think of it, lots of those countries are in the EU and using the Euro. Hmmmmm)Cropped version of the iPhone developer program country listTime to start playing with that accelerometer…

Software Engineering10 Apr 2008 06:46 pm

I’ve been spending quite a bit of my time lately learning my way around a big new code base. Being able to set random breakpoints and step through the code is a godsend, but quite often, it can be tricky to quickly narrow things down to the area you’re interested in. What I realised this afternoon is that my life would be much easier if I had a debugger combined with a free text search.

In the first instance, it would be enough to just search the source lines which are being executed (and maybe break whenever there’s a match). That would let me, for example, find exactly where that extra parameter is being added to my URL without having to step through everything or grep the source code for what turns out to be a very common string.

To take it a step further, it would be really handy if it searched values of variables along the way to catch the case where the parameter name was pulled out of a config file or database).

Of course, it would probably be very difficult to implement (at least in a compiled language) in a way that has reasonable performance, but even a very slow solution would work well from what I’m currently doing. Maybe the another way of looking at the problem is that I want to search through only the code which was actually executed during a particular invocation…

Anyway, it’s probably not something I’ll be heading off trying to implement (and I imagine at some point someone will tell me you can already do it in smalltalk), but it certainly would have been handy if it had been in eclipse today.

Software Engineering30 Mar 2008 01:46 pm

I played with Macrovision’s InstallShield for the first time last week in my new job. Pretty impressive UI compared to InstallBuilder which I’d used previosuly. Obviously the problem is made a lot simpler by the fact that InstallShield doesn’t really work cross platform (and from my experience, Macrovision’s InstallAnywhere’s UI crashed so much it was more of a liability).

In a way though, the name find and replace change I was making would have been a bunch simpler in InstallBuilder, where the installer is pretty much configured with a big XML file (once you very quickly hit the limits of the token UI editor provided).

I guess I should try opening the InstallShield file in a text editor to see what under the hood there…

Software Engineering& Web15 Jan 2008 06:20 pm

I was playing with selenium to try testing a web app I work on earlier today, but ran into the following error pretty much straight away…

input [error] Unexpected Exception: message ->
  element.ownerDocument.createEventObject is not a function
…

From a bit of digging, it looks like the current version of Selenium (0.8.3 as of Jan 15, 2008) isn’t compatible with mootools.

The mootools forums have a fairly simple patch to fix the issue.

Apparently Selenium is checking for the fireEvent method, normally only available in IE, but which mootools adds to other browsers. As a result, mootools thinks it’s running in IE, and tries to call createEventObject, which really is only available in IE.

Having made it over that hurdle, selenium is looking like quite a nice tool.

Software Engineering20 Jun 2007 07:29 pm

Thanks to Eric for point out that the two marbles solution I presented previously isn’t optimal. I’m pretty confident that allowing the first pass windows size to vary will fix it up, but haven’t found the time to site down and work it through.

On the other hand, it crossed my mind this morning that the question didn’t state what we should optimise for. I imagine the number of marble drops is what’s expected, but if you took into account the running up and down stairs involved that may well affect the solution…

Hmmmm…

Software Engineering& Technology& Web31 May 2007 01:37 pm

Google Gears (Google’s toolkit for off-line web applications) looks really cool (thought it’s a pity it has to be installed as a plug-in and there are a lot of “We have nothing to announce at this time” type responses floating around. A lot of people seem to be asking about things like conflict resolution etc. which is being left as an application concern for now. The few web developers around seem to be underestimating the amount of rework which would be required, but for new web applications it looks like it will be quite easy to produce a radically better off-line experience.

Maplets look cute, but I’ve not really played with maps much, so it doesn’t seem to radical to me. The ‘coming soon’ mention of AdSense for maps is interesting - looks like you’ll be able to make a call with your id and a number of ads to display and have them shown along with whatever other map content your maplet/mashup is adding.

Food’s been pretty good, got a very cool notepad which has a picture of the earth on the cover then zooms in as you tilt it forward.

…And why do they always have conference name tags designed so they turn backwards accidentally so easily. Surely it would be simple to attach it to the lanyard at two corners rather than just at the centre…

Technorati Tags: , , , ,

Mac& Software Engineering19 May 2007 11:46 pm

Getting the following error when you try to run html tidy from TextMate?

html tidy failed assertion `option_defs[ optId ].type == TidyInteger’

You’ve probably got the current (as of 19 May 2007) binary version installed by fink. If you install the one built by fink from source, or the one from the html tidy website, then it should start working.

(For what it’s worth, it seems the binary package fails with that error whenever it’s given the ‘-i’ flag to ask it to perform indentation.)

Next Page »