These quizzes remind me of my childhood as these kinds of quizzes are what I used to solve when I was a primary schoolchild. It was approximately 22 years ago. That time, I learned Basic (Not Visual Basic (VB), VB didn’t exist back then), Fortran, COBOL and C. When I was learning Basic, those kinds of problems were what I solved. After I graduated from the primary school, I had not touched any computer programming languages at all for 13 years. I started it again as I came to Sydney and entered the university to study IT. Then I realised that I could remember nothing about what I learned before. Nothing at all. That’s why my ‘about me‘ page doesn’t contain any of Basic, Fortran and COBOL since I’ve completely forgot about these (it does have Visual Basic though as it’s my first programming language that I learned at the diploma school, UTS:INSEARCH). So my point is, doesn’t matter whether it’s a programming language or a human language, if you don’t practice or keep studying constantly, you will lose your skills and fluency of the language.

Anyway, I saw those quizzes and solved it for fun yet feel like I did better when I was a kid. Back then, I didn’t even use a computer to solve it but only pen and paper.
The followings are the quizzes and my answers, yet there can be much better answers of course, so why don’t you try by yourself before you check out mine.

This is the prompt utility class, used for the other programmes, to get input values. Notice that it doesn’t check whether the input value is number, integer more precisely, or not although it does check if the given integer is a positive one.

Like this:

I have been very busy and am still busy so haven’t written anything for quite a while on my blog except for those entries with only one or two sentences. So I’m quickly writing what I do these days and some issues I have dealt with.

Sonatype released the new version of m2eclipse in February 2010. Since I updated with it, I had got some problem with maven build through Hudson.

The new version of m2eclipse comes with maven3 embedded yet my server uses maven2 so does my Linux on my Desktop PC. So it was only m2eclipse which uses maven3 (SNAPSHOT version) and I deployed some of my libraries used in one web application development project. Problem was that I deployed the dependency libraries several times with the same version number. With maven2, it’s OK as it uses time-stamp to distinguish one version from another within the same version, yet with maven3, having the same version is not allowed. Well, I am not 100% sure about this as once I solved the problem I didn’t really check the details as I didn’t have enough time. Anyway, so as shown in the following image, the project status icon once became dark rain clouds which mean really bad.

Build Failure: Project status icon became dark rain clouds

My project build failed seven times due to the difference between maven2 and maven3 I described above, or it can be something else yet it is caused by some difference between those two versions.

Build Failure: It failed seven times due to the difference between maven2 and maven3

(It happened in February. The build number in the image is 108 but it is now 305).

So why did I not just keep the old version of m2eclipse with maven2 embedded? Well, the old one comes with some old version of maven2 which does not support password encryption while the maven2 on both my PC and my server does support it as it is a newer version. Thus I updated with the new m2eclipse as soon as it was available yet didn’t really expect that it comes with maven3. Anyway, It’s solved by using maven2 installed on my PC when deploying project packages. The other times such as solving dependencies and building package without deployment, I can still use the embedded maven3 in the new m2eclipse without any problems.

I founded a start-up company with my friend a few months ago, and we are currently working on a web application development for our own start-up, but it is probably too premature to announce what it is as it’s still an early stage of development.
The issues listed in the following image is a part of the issues I and my colleague have solved and been working on.

I'm currently working on this project.

In addition, I have been developing my own Java libraries which can be commonly used in many other projects (and my friend has also been developing reusable JavaScript libraries). However, I did not record all the issues belong to these reusable components and recently felt that I should do it before I go any further. Otherwise, I may later forget what problems I solved and how I did as well as all the issues covered previously. So I wrote all the tickets for those libraries.

Issues of commonly used libraries built by myself

I’ve also been developing ‘Java object to JSON’ library and did the same as what I just explained (that is creating issue tickets). There are already a number of the libraries which convert Java object into JSON so why would I make another? Well, there can be several reasons but major ones are

It has to be simple as I do not want to have any complex functions or heavy library for a simple conversion (some libraries are too heavy for such a simple task).

When customisation is required or bug is found in the library, I want to be able to change and fix it however I want so that I do not have to waste my time on waiting for others to solve it.

I want it to work in some environments where using bytecode manipulation is not an option. So if I programme one with bytecode manipulation then it works faster when it’s available whereas the other one is without it so that it can be used in those enviornments (I currently have only the latter one and will do the former one when I have time later).

The following issues are what I have solved for the Java to JSON library.

Issues of my Java object to JSON library

Finally, I have another project to help Ajax enabled web application development. From my experience, I found that it is sharing the information about the available server-side functions with the client-side developers that causes the most waste of time between the front-end development and the back-end development. The first time one function is made or whenever the existing ones are changed, I have to write or rewrite the document explaining it and the client-side developer has to find the changed parts in the document. It is annoying and a non-productive moment in the development so I and my colleague discussed about this issue and came up with the idea of having a library which exposes all the available server-side functions to the front-end (It can understand Spring @MVC controllers). For now, it has only this, yet I will add more features to help Ajax web application development.

Issues of my web method library

* As I used more and more reflection to develop those libraries, I realised that Java Reflection has no method to get the names of method parameters. Well, there can be some ways for instance, using -g (generating debugging info) option when compiling or using some libraries such as ASM or use ParaNamer (It requires an additional step when compiling to add the constants having the parameter names in the class) but not by just Java reflection. Anyway, none of these is the solution I want, and unfortunately if I heard right, this problem will remain in JDK 7.

OK, it might be a bug in that particular version. Fortunately, the most recent version of SUN JDK 6 was released yesterday. It was officially released before (the 15th of April, 2010) yet the version managed by Ubuntu was not available before yesterday. So I installed it and tested it again with the Java compiler in the new JDK6.

I probably need to test with the Java compiler in the JDK6 for Windows but I have no stomach for that now nor do I have time to do that.

* Update1 (2010-05-10)
I also tested it with the Java compiler in the JDK 6 (1.6.0_16) for Windows and got the same result. It seem like static import cannot handle method overloading. I didn’t have time to research to find the details but based on my testing, method overloading cannot be used with static import.
If so then there should be a good reason for that, and the only one I can think of right now is that it might have something to do with varargs.
Take a look at the following code.

Since a method with varargs can take no argument when it’s called, Test.test() and SomeHelper.test(Object… object) can be indistinguishable with static import. This is, I think, probably one of the reasons why method overloading is not allowed with static import. Nevertheless, it is still very weird as calling test() does not cause any compile-time error while test(object) does.
So the following code has no compile-time error and displays Test.test().

What if the helper class has test() method with no arguments and the Test class has test() method with varargs then call test()? The same result! It still calls Test’s test() method with varargs (Test.test(Object... object)).

Although one might say that I can use Lombok instead, I prefer to see what is going on in my code. Those hashCode and equals methods are not additional info of the class. It tells what makes instances of the class equal thus I prefer to have it in there to see and want to freely change it whenever and however I want. Well, in other words, just a matter of personal preference.
That’s it.
I perhaps have more to say yet am getting tired (4:55 AM :O). So I’m calling it a night.