Something I’ve spent quote a bit of time thinking about during my years as a student, then lab assistant (AKA demonstrator), and finally occasional lecturer with the computer science department in NUI Maynooth, is how students should be introduced to computer science and programming. I’ve seen all sorts of tactics tried over the past 14 years. The absolute worst tactic I’ve seen is the abandonment programming from first year computer science program altogether. Another disaster in my opinion was the introduction objects before the introduction of basic constructs like conditional statements and loops, the confusion that cased was monumental. I have been involved with final year undergraduate projects for much of my time with the department and have seen first-hand the effects of some of the different approaches. No one seems to be able to agree on how best to start computer science students programming, but something no one can argue with is that any system that results in final year honours students being unable to program is fundamentally flawed.

[tags]computer programming, education[/tags]

Read more

It’s not uncommon that as part of a complex transaction you need to insert a row into a table with an auto-incrementing primary key and then use the key from the row you just generated as a foreign key in another insert within the same transaction. Java provides a mechanism to return the auto-generated keys from an insert query without the need to execute a second query by means of the function java.sql.Statement.getGeneratedKeys(). Unfortunately the PostgreSQL JDBC connector does not appear to support this feature (at least the version I am using does not). Given the fact that we do not have this functionality available to us when using a PostgreSQL database we need to use a separate query to retreive the value of the key we just generated. It goes without saying that we need to do this two-step process as part of a transaction but it may not go without saying that the correct way to extract the value for the key is by querying the sequence that the key is being generated from and not by querying the table directly. It is true that most of the time the highest value of the incrementing variable will be the value just inserted but that is not a guarantee.

Read more

Tagged with:

This week I installed my first QuickLook extension, QLEnscript by Dave Dribin. It uses the Enscript libraries to provide syntax highlighting for a number of common languages within QuickLook. Nothing fancy but handy for programmers none the less. You can find out more in this post on Dave’s blog.

[tags]OS X, Leopard, QuickLook, Enscript[/tags]

Tagged with:

I was searching for a tutorial on setting up custom global exception handlers in Struts 1 when I came across this fantastic article. If you develop with Struts 1 or are thinking of starting development with Struts 1 you really should read this – Jakarta Struts: Seven Lessons from the Trenches

[tags]Java, Apache, Struts[/tags]

Tagged with:

A lot of other bloggers do posts where they just list interesting articles they’ve read. It’s not something I’ve really considered before. However, I’ve recently started coming across some excellent articles that I think are worth sharing. So, I’m gonna give it a go. Consider this a trial. If you’re a regular reader let me know whether or not you’d be interested in reading more posts like this one by leaving a comment.

Read more

Despite the advent of broadband excessive round-trips to the server still slow websites down. Having to send a request to the server to get the same data again but in a different order each time someone wants to sort a table is just not efficient. Hence, what you want is some nice simple JavaScript to do it for you. Ideally this JavaScript should be cross-browser and should not require you to make any substantive changes to your mark-up. Well, the good news is that this ideal has been realized and has been released under the free and open source MIT License. I’m talking about Stuart Langridge’s Sorttable.

Assuming you use proper XHTML markup for your tables, in particluar thead and tbody tags, making your tables sortable is a two-step process:

  1. Include sorttable.js
  2. Set the class of the tables you want sortable to sortable

For a basic setup that’s it! If you want to get a little more fancy you can by doing things like making some columns un-sortable but that too is trivially easy. Honestly, I have no complaints at all about this script, it just works!

[tags]XHTML, tables, sortable tables, JavaScript[/tags]

Tagged with:

It’s no secret that I don’t like PHP. In fact, I dedicated an entire article to explaining just why I don’t like PHP last year. Recently I’ve found another reason to dislike PHP. The GD image manipulation libraries SUCK! They are so insanely and needlessly complex. All I wanted to do was write a simple command-line script to read in a folder and edit each JPEG image in the folder to resize it, insert a Creative Commons logo, and the URL to my website. I’m currently working on uploading some of my photography to my website and doing this manually for all my photos is just not an option, it would take forever! So, I started writing a PHP script because I know PHP can do these things thanks to the DB libs. That turned out to be a bad idea so I ran home to Perl 🙂

[tags]Perl, PHP, GD Libs, Image Magick[/tags]

Read more

Color OracleIf you design stuff please bear in mind that not all of us are blessed with perfect color vision. When you’re developing your color schemes please make sure they are still readable to the color bind. Don’t worry, it’s trivially easy to test this with a great free tool called Color Oracle. BTW, even if you don’t have an actual need for this tool it’s still fun to play with 🙂

What’s really nice about this tool is that it’s available for Mac, Linux and Windows so everyone can play! I’ve only tested the Mac version and it works like a charm. It adds a simple menu bar icon to select which kind of color blindness to simulate. When you select a scheme your screen colors change so simulate what a color blind person would see. I really like that the change is very temporary, just click the mouse of press a key and everything goes back to normal. You can also set up hot-keys so you can very quickly check your interface works for color blind people with just the press of a single button. There is no excuse now for developing an interface that color blind people can’t use!

[tags]color blindness, software, freeware, OS X, Windows, Linux[/tags]

For my post yesterday on the HD-DVD key I needed to convert the 128bit HEX key into a decimal number and then divide it by two. I figured this would be easy. I’d wander over to Google, search for “convert hex to decimal” and hey-presto, I’d get a web-based converter somewhere to bang the hex key into and get out a decimal number. This soon proved not to work in practice for large numbers. All the converters I tried gave me back floating point numbers with very large exponents. The means loads of precision was lost and hence I couldn’t get the exact number the MPAA claimed to own. So I did what I always do when I can’t find a program to do what I want, I hacked something together in Perl! Now, when I say hacked I do mean hacked. It only took me a few minutes to do and what do ya know, Perl lost precision too, giving me an answer of 1.32562788879895e+37. So, I needed to re-implement this algorithm in a language that could give me basically unlimited integer arithmetic. I chose Java because of the java.math.BigInteger class and because Java is the language I know best. I implemented the same basic algorithm in both languages. It’s interesting to see just how much bigger the Java code is!

[tags]Java, Perl[/tags]

Read more

Tagged with:

As anyone who knows me well probably knows I’ve been a huge fan of the website The Daily WTF for a few years now. This week Alex (the owner) caused quite a storm by re-naming the site to Worse Than Failure. Yesterday Alex posted a very good essay which explains his choice of new name and takes a very interesting look at what exactly causes the ‘perversions of information technology’ we seen on the Daily WTF each day for the past few years. If you write software you really should have a read of What Could Possibly Be Worse Than Failure?.

« go backkeep looking »