Showing posts with label test. Show all posts
Showing posts with label test. Show all posts

Monday 9 July 2007

space is too much


/**
* Return the concatenation of first name and last name separated by a space.
*/
public String getFullname() {
String s = "";

if (this.getFirstName() != null) {
s += this.getFirstName() + " ";
}

if (this.getLastName() != null) {
s += this.getLastName();
}

return s;
}

Let's say that firstName = 'Pitt' and lastName = 'Dirk'. We got "Pitt Dirk". And what if the firstName is null, we got " Dirk". Hum, less good.

And what if both are null, we got " ", a space!


This f**king space mess up our database. The better, this kind of method are copied/pasted every where the same behavior was needed.


What do we need then ? A nice join method that concatenate elements of an Object array inserting a separator between elements and ignoring null and/or empty string.

Friday 29 June 2007

Copy/Paste


client.setSiteId(clientForm.getSiteId());
client.setPrestaId(clientForm.getSiteId());

(Stupid): Oooops boss. I've done a copy/paste bug 1 year ago. And now the database is a mess.

(Boss): Stupid ! You're fired !


I'd would be this boss BUT if this kind of bug is forgivable, it is unforgivable to let this bug pass tests. So, this boss is not a good boss.

Data in database are EVERYTHING for the application. Applications without data are useless. See google ! They sell data, they make free software ;-)

Copy/paste ok ! Human being makes a lot of stupid error. So, make test !!!