Development

Protocol relative linking

An odd discovery today – if you don’t specify a protocol in your links, the browser apparently suppose it’s the same (be that http or https) as the current page. You can se it in action on Slashdot by viewing their source – none of the regular links has protocol specification – they just start with two slashes and the hostname (ie. //netfactory.dk/).

In the case of Slashdot I suppose they don’t use it to save bandwidth, but in most cases it’s probably useless.

Mysql: (date) functions and indexes

Mysql is usually pretty fast by default, but to keep performance to the max sometimes requires knowledge on how mysql works and how to write queries that does their job most efficiently. Today we ran across a simple example which illustrates that mysql’s ability to use an index depends on the way you write the query. Let’s make a simple table and add an index on the date column:

create table members (
	m_id integer auto_increment primary key,
	m_name char(20),
	m_since date not null
);

create index ix_m_since on members (m_since);

A database styleguide

Most databases seems to be well designed when the systems needing them are launched in the first version – but the slowly as the systems evolve (often grow beyond their initial requirements) – the database design seems to go down the drain. Here are a few tips on what to think about when you design a database or alter it.

First rule: Remember the goal of the system.

Different systems have different requirements and thus require different database designs. Some system are build for the web, some are build for medical journals and others just to solve a practical problem. If you’re building websystems, your main concern is probably speed. If you’re building financial system, data integrity and consistency is probably your main concern. Make sure your database design is made for the goal.

Namespace crash in HTML forms

Today’s evil headache was caused by something as simple - yet annoying - as a two HTML form elements having the same name (but different types and uses in the form). The lesson learned is that if a field in a form is submitted but contains nothing - check if another object in the form has the same name and make changes if you need to.

To Mac or not

So, I’ve been wondering if I should by a Mac. Windows works for me, but causes a fairly large number of headaches. Linux is nice for server use, but I’m not nerdish enough to get a desktop running. With the many positive reviews, switching stories and others I was thinking of going Mac. Since OS X was introduced Mac machines runs on a BSD core which makes it almost familiar grounds for people who knows the Unix world. Since the introduction they kept an amazing pace and regularly introduced new innovative features at regular intervals.

SQL and beyond

SQL is a common language implemented by most databases. While it’s a nice language it does lack some features available in some databases (which often differ from database to database). Some argue, that you shouldn’t go beyond the contrains and limitations in SQL because that removes your ability to switch to a different database. That’s just wrong (in my opinion). SQL usually allows you to do all the searches and CRUD operations you need, and by not going beyond the limitations posed by SQL you can switch your application to another database with an absolute minimum number of changes in your application - especially if you utilize the Perl DBI or the Pear DB (in PHP).

Perl, XML, Television and something about encodings

I’ve been busy hacking away on a script which would read the XMLTV format and pour it into a mysql database. It’s fun but nothing is quite as easy as it should be. I’ve rediscovered it once again. I had never before tried to parse XML data from Perl, but a quick google visit suggested it should be a breeze as everyone else seems to do it. I haven’t done my homework and really figured out what the various differences between the many methods you can parse XML is – so I basically found a few examples and picked the one the example used (XML::Parser) that.

WebSiteOptimization

There are quite a large number of tools available for testing and checking a website, but the most valuable is (without doubt) the Web Page Analyzer – as it does tell (and help) you optimize your site in ways you may not have thought of. I am assuming that the site in question is either valid HTML (as any good site should be) or at least tested and found working in the browsers it should work in. The tool is for the “post design” process.

php | architect

If you’re php developer you should check out php | architect. It a monthly magazine aimed at PHP developers and actually quite good. It used to come in PDF-format only, but has recently also launched a dead trees version. It’s a nice mixture of tips, software reviews, interviews and programming techniques. While all articles isn’t equally interesting, it is certainly well worth the US$2.09 which the PDF-version cost. A free copy available from their site.

Java: New logo and a new end-user portal

It seems it’s going surprisingly well for java after a rough birth and slow adoption. This year on the JavaOne conference they celebrated the success by changing their logo and launching a new end-user oriented portal at java.com. If you’re developer, your source for information is still at java.sun.com.