Archive for category Software Development

On usability of Java 5 language features

I only had a chance to develop using JDK5 for a short period of 1 month. And it was 1.5 years ago. Recently I needed a quick solution for basically a script comparing two Excel spreadsheets for matching records and recording results into same spreadsheets. Since I programmed in Java really fast and I felt reluctant indeed to get myself buried into MS VB for Excel documentation, and also taking into account my good experience with Jakarta POI — a Java API To Access Microsoft Format Files, I decided in favour of Java. (Well those were mostly excuses as you might have guessed anyway :) ).

Там есть еще »

Комментарии (4)

& operator is applicable to booleans

While I thought binary operator & in Java was designed to work with integer types, it appeared to be perfectly applicable to boolean operands and worked exactly the same way as &&:

//always true:
assertTrue(boolean1 & boolean2 == boolean1 && boolean2); 

See more things that I still discover about Java.

Комментарии (4)

Subversion: incapable of merging deletion with modification?

I am currently discussing in Subversion mailing list an issue with SVN merging, when a file is deleted in branch, modified in the main trunk and then merged back from the branch to the main trunk. What subversion does in this case is it silently deletes the file losing the changes made in the trunk. Here is the start of the discussion thread. So far I discovered that this (turns out) rather important for our company scenario is handled well by CVS (my posting about this). During merge, CVS simply says

cvs.EXE update: file file1.txt has been modified, but has been removed in revision demo-branch

What is it? If it’s not a bug then at least an imperfection. My purpose currently is start discussing this in a subversion developers’ mailing list so that we at least are able to see any movement towards fixing this in the future.

Комментарии (6)

Subversion: do I need to explicitly add/delete each file?

Started to get familiar with Subversion (SVN) recently. We have plans to employ it at work and I need to create good demo cases for other developers distinctly showing advantages of SVN over our current version control system. I discovered an interesting feature of SVN which I’d like to hear your comments about.

In CVS if I delete couple of files locally and then run cvs remove, if I remember correctly, it discovers which files I deleted and marks them all for removal from repository. It does not work with additions though: I need to cvs add explicitly each file/directory after I created it. In SVN, I need do both explicitly. Unless your IDE does all deletions/additions for you, which all good IDEs do of course. But not everybody use good IDEs so this feature looks like a regression given that SVN is positioned as a replacement for CVS. Let alone that they could also improve additions so that running svn add without argument(s) adds files that are created in the local copy after last update and do not yet exist in the repository.

Нет комментариев

Quake 2 written in java

Guys from Bytonic have created a java port of open-sourced quake2 engine. It is using standard Java3D API and two different implementations of Java3D based on OpenGL. So apart from OpenGL the engine is all pure java. Although they have a benchmark page, I was interested to test it myself. So I downloaded jake2 (this is how the port is called) and original q2 demo version. I used q2demo1.dm2 to measure fps. I left all the settings at their default values except the resolution which I set to 1024×768, full screen. jake2 showed 212 fps, original C version resulted in 191 fps. The only thing that was unfair is that jake2 was based on quake2 3.21 sources and original demo I used was version 3.14.

I had a glance at the java sources too. Naturally, they don’t look like proper java sources but more like not very object oriented C sources. At the end of the day, this is a port from conceptually different language, not an original application.

The conclusion is whoever challenges the performance of modern JVMs is welcome to give jake2 a try and eat dirt :)

Комментарии (2)

void.class

Ha, another addition to my Things that I still discover about Java registry: Expression void.class is legitimate and results in a java.lang.Class instance representing void type. I did know that each primitive type had its own Class referenced as byte.class or char.class, but had no clue that you could do same thing with void.

Один комментарий

IntelliJ IDEA 6 will have Websphere support!

Yow! According to «IntelliJ 6.0 (Demetra) Roadmap released» TSS article, next major version of my favourite and truly enjoyable Java IDE, IntelliJ IDEA will have support for IBM Websphere appserver. That would be a pleasant addition for me. Currently, I use a somewhat hacker’s approach to start/stop Webshpere instances on my computer. I intercepted the command line that WSAD (IBM’s IDE) is using to start integrated Websphere, and now use it to start Websphere from ant script. The major drawback is that sometimes server state needs synchronisation with the config files, which only can be done from WSAD. Also, re-generating deployment sources requires WSAD too. Although I am not sure these will be addressed in IDEA 6.0, it is a good step forward for such a great IDE.

Комментарии (3)

Stateless private methods: static or not?

We had an short argument with a collegue at work recently whether the private «stateless» methods of a class (those that do not use instance fields) should be declared static or not. My opinion was they should be static because this marks them as stateless and not only eases code reviews, but provides a compile time safety against using instance fields. This used to help me when I was digging in numerous piles of somebody else’s code. In turn his argument was that

… if someone decides that they need some state in the method it is possible that they’ll make the mistake of creating or changing a static variable instead of creating an instance variable or removing static from the method signature. Also, static methods tend to create yet more static methods, like cancer.

I don’t like declaring all methods as instance methods just because there are people with procedural language background that can’t or don’t want to fight their habits. If the field should be an instance field, don’t make it static, it just won’t work in most cases!

I am eager to hear your opinions on the case.

Комментарии (7)

Things that I still discover about Java

Once in a while I find those little tricky things in the core Java that I didn’t know before. Read my Things that I still discover about Java page.

Нет комментариев

Sun Certified Java Programmer for J2SE 5.0

Продолжая славные традиции Рустама, докладываю, что сегодня успешно сдан экзамен на Sun Certified Java Programmer for J2SE 5.0.

На 63 вопроса из 72х отвечено правильно, то есть 87%. Проходной балл был 59%. Надо сказать, что экзамен был не лёгкий, и, не готовившись, я бы вряд ли его сдал. Во-первых, практического опыта с Java 1.5 у меня очень мало, да и то давно было. Тут мне помог сановский онлайновый курс по отличиям 1.5 от 1.4. Во-вторых, все вопросы подковыристые, и расслабиться они мне не давали. Благо, Рустам подсказал, как найти эмулятор натурального экзамена, так что к подковыристости я был готов.

Красивой бумажки пока нет, ждём.

Запарился искать парковку около Wembley Stadium в Лондоне, навернул два круга, знаки типа «парковка-туда!» везде есть, а самих парковок нет. Нашёл какую-то заброшенную в конце концов, но за 8 фунтов. К тому времени был уже на нервах, и готов был отдать последние трусы за место, так как опаздывал на 10 минут. В следующий раз выеду намного заранее. Если «томтом» говорит ехать 33 минуты, то в Лондоне в час пик это означает час.

Комментарии (9)