BOFH: knot in cables caused data stream to become twisted and kinked
ITworks
Regexp fun
November 25, 2009 on 11:57 pm | In IT, fun | No CommentsReading the post about useful regular expressions, remembered what my favourite solution is to one of the questions of the test we give to junior Java developers.
The task is to write a method that takes a string as a parameter and returns the acronym of the string in uppercase made up of the first letters of the words in the string. The acronym must ignore the words “the”, “of” and “and”.
The usual solutions are either to sequentially step through the string (Yuck!) or split it up or use a StringTokenizer class. The people usually overlook the fact, that the input strings can be padded with whitespace, or contain multiple spaces, and they usually ignore, that the keywords that are to be omitted might be found on the begining of a valid word. Thus my test ” United States of Andorra” string breaks most of the methods. The ones who have time to write the answer down, usually forget to return the value from the method, or to change it to uppercase and sometimes even ignore that it should be a method to start with! This is my favourite question, as it can really show how the applicant can handle stressful situations.
I was tired after several interviews one day and tried to come up with the shortest possible solution. Naturally it contains regular expressions.
My solution looked something like this (OK I just reproduced it for the sake of the article, using nano and javac, so it might have overlooked flaws in it):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public class Acronym { private static String toAcronym(String str) { return str.toUpperCase(). replaceAll("(THE|OF|AND)(\\W+|$)",""). replaceAll("(\\w)\\w*\\W*","$1"); } public static void main (String args[]) { if(args.length>0) { System.out.println(toAcronym(args[0])); } } } |
Using JAX-WS without code generation
August 5, 2008 on 11:58 pm | In IT | No CommentsSomething gave me the weird idea to try the new features of JAX-WS on a current project. The main idea was, to get rid of the code generators that must be ran whenever some minor change is done in the web service.
So instead of designing the WSDL along with the matching schema definition for the connector classes, I decided to start of by designing the interfaces and the connector classes, then just create the implementation with the corresponding annotations on the server side, that will be deployed automatically. The WSDL is generated from the annotations and the connector classes, there is no need to write them manually.
Continue reading Using JAX-WS without code generation…
The Parable of the Object Oriented Programmer and Breakfast
June 15, 2007 on 1:00 pm | In IT, fun | No CommentsThis is the English version of a tale I’ve recently found in my archive mailbox from 2001. Looking at ongoing projects, I think it still has a point.
Once upon a time, in a kingdom not far from here, a king summoned two of his advisors for a test. He showed them both a shiny metal box with two slots in the top, a control knob, and a lever. “What do you think this is?”
Continue reading The Parable of the Object Oriented Programmer and Breakfast…
Developing J2ME application on Linux
June 8, 2007 on 1:27 am | In IT | 5 CommentsWe are starting up prototyping on a new project I’ve mentioned in this article. Our aim is to provide a proof-of-concept implementation of a simple off-line application running on the PDA’s we have.
Continue reading Developing J2ME application on Linux…
Quick and dirty way to create DB2 update scripts
May 29, 2007 on 10:52 pm | In IT | No CommentsIn on of our major projects we store some of our business logic data as database metadata, but provide GUI interface for updates. Since clicking through the project’s GUI is much easier, than creating and verifying scripts for each tiny modification, our developers got lazy and we had to find a way to create SQL scripts to bring releases up to date. This basically means, we had to create a script generator that compares the data in source and destination databases and creates SQL INSERT, UPDATE and DELETE statements that can be used to modify the destination to source.
Continue reading Quick and dirty way to create DB2 update scripts…
How not to use Java key stores
May 23, 2007 on 2:23 pm | In IT, fun | No CommentsI spent half a day today trying to see why a the web start application created and deployed using a simple build script didn’t work after I’ve created a new certificate as our previous was about to expire.
First I suspected it was because I signed the application using SUN JDK 1.6, and it might have some compatibility issues (as if) then I suspected it was the IBM JDK 1.5′s ikeytool I used to create the key (NB. I’m lazy to learn the keytool paramers, so I prefer to use a GUI for creating keys)
It turned out I was presuming the keys use UTF internally, like most Java applications should, so when entering the locality I used “Vác” with accented characters. Neither ikeytool, neither keytool warned me about this. Once creating a new key without the accent the application started working straight away.
Since “Budapest” doesn’t have any special characters, I never noticed this, but I think it deserves to be mentioned, so others won’t run into this problem.
Off-line SWT application
May 10, 2007 on 1:02 am | In IT | 1 CommentOne of our current Customers have a very interesting requirement for an upcoming project. The nature of the project requires mobile clients and frequent (or even instant) database updates, but there is no guarantee to have constant connectivity. We more or less have full control on the choice of tools to use for this application, but since our developer resources are limited, it would be great if we could use the architecture from a previous project. We’ve been working with András on this for quite a while and it seems we found a pretty interesting way to do this.
Continue reading Off-line SWT application…
Continous integration issues with Ant(hill)
May 2, 2007 on 11:11 pm | In IT | 2 CommentsAnthill is a small, easy to configure automatic build and publish environment.
I don’t want to discuss the deployment and configuration of the tool itself, I’d rather highlight the main issues that we had on using Anthill to automatically build and deploy our ongoing projects.
Continue reading Continous integration issues with Ant(hill)…
