Java Stuff

I think I have already mentioned before that due to the Object Oriented Programming college class I have to play around Java now. I was assigned to do a project in Java and I decided to check what I can do there. Being more a perl guy, I have a faced a numerous problems with Java which I try to overcome in all possible ways. Here is what problems I have:

1. Static method declaration in abstract class. This really drives me crazy :(. I have a case where I really need to have static methods in abstract class (with implementation code inside) and I can not do it which causes me a lot of headache.

2. I am really missing an analog of perl keyword __PACKAGE__ in Java. This, sometimes also have to do with the first issue. For example I want to create an abstract class which defines the structure of a database table model, and this class should have static methods such as retrieveAll or search to return an array of objects of this class. Lets assume that I am allowed to have static methods in abstract classes and that I have a __PACKAGE__ option, then I would write something like this:

abstract public class DBModel extends DB {

abstract static private String dbTableName;

static public __PACKAGE__ retrieveAll () {

DB myDB = new DB();
myDB.query(\"SELECT id FROM \" + dbTableName + \"\");

if (myDB.getResultCount() > 0) {
int i = 0;

__PACKAGE__ itemList[];
while (myDB.getResultSet().next()) {

itemList[i++] = __PACKAGE__ new( myDB.getResultSet().getInt(\"id\") );
}
return itemList;

}

return null;
}
}

public class MCategories extends DBModel {

static private String dbTableName = \"customers\";
}

Like this, all classes which extend DBModel would have a static method retrieveAll() which would retrieve a list of all items from the DB.

3. Declaration and assignment to a variable inside of if/while/whatever. Sometimes I just need to do something like this (using the above example):

if ((Object[] objectsList= MCategories.retrieveAll()) != null) {

// do something with objectsList[].
}

If you know some workarounds, please let me know.

Got my car back

I have finally got my car back from the garage and here is what I think:

First of all the door was replaced. It looks good and I feel happy. This was the main purpose of giving the car to the garage. I also liked the fact that garage had provided me with their car while they were dealing with mine, but here are some things I didn\’t like:

1. It took them 1 week to replace the door. A friend of mine who is working on car repairs told me that he could do it in 2 days. Maybe the guys were very busy, but still – kinda too long.

2. They have not did any additional things I have asked them to do like: change oil, change filters, check the handbrake and check if they can fix the fuel amount sensor. Pity. Now I need to give car to repair these items :(

3. When I called the garage today to ask about a car, they told it will be ready in 1 hour. I came to them 3 hours later and they told me that they haven\’t manage to wash it yet, so I have to wait for another hour – no way, I took the car unwashed since I was in a hurry and now I will give it for washing myself.

Seems to be it, but I think I will be looking for different garage (not that busy one). I was already advised to check one garage owned by friend of friend of mine :) I will check it up and let you know.

Sun JDK on Fedora Core 6

I am not a Java fan and I do prefer doing all my stuff in Perl (due to the perl being more flexible and comfortable to code in [my personal view] and probably due to the nature of the tasks I have), but due to the college class Object Oriented Programming which is totally taught in Java, I have to install Sun JDK on my laptop for some time.

It turned out that the task is not that easy (actually easy, but tricky), but I found a nice article which describes all steps needed to get Sun JDK configured on the system – works for me

Fixed home PC

I have been experiencing some problems with my home PC. It was showing me problems with hard drives. First I though that my hard drives are quite old and need replacement. I got myself new SATA drives since my motherboard supports both PATA and SATA, but then the problem continued and what I have found out is that my power supply was dieing. New SATA drives are faster and probably consume some more power :(. Anyway, I got myself a new 400W power supply and now everything works just perfect.

I also thought to get myself a new PC, but then I remembered that a Quad Core is coming very soon and decided to wait for it :)