# Thursday, June 19, 2008

Разговор за софтуера и бизнеса в него, дори за бизнеса като цяло

Той: em toq html nema izmestvane 100 godini veche

Той: mn tapo

Той:  It can make direct calls to JavaAPIs that are on the platform.

Той: e to pochva da prilicha na aplet ;)

Аз: всичките технологии са аплет-like

Аз: виж кой им е предшественика

Той: da samo ne znam kak opredelqt thin / fat client

Той: to sa razmiva leko

Той: ajax-a e thin i toi uj ;)

Аз: има група хора (аз също съм от тях), които са свикнали да пишат на силно типизирани езици и име е адски трудно да разберат как технологии като perl, php, rss, html, javascript и разни други 'боклуци' придобиват такава голяма популярност - отговорът е в леснотата на употреба и бързината на разработка. А че се жертват разни неща като добър стил и loose coupling - на кой му пука

 Той: awe za html i www kvo mu e lesnotata chovek

 Той: kat v ie raboti po edin nachin u firefox ne

 Той: i staash na lud

 Той: tva e nai-golemiq tashak :)

 Той: prosto ne moa da povervam che sa go dopusnali

 Той: ako imashe pone malko tipizirane :)

 Аз: There is a certain group of people (counting me too) that are used to working with strongly typed languages. It's really hard for that group of people to understand how technologies like php, html, javascript (..., rss, perl, ...) become so popular.

 

The answer is (in my humble opinion) the ease of use and rapidness. Everybody can learn to use them. Sacrificing the good style and the heavy approach (that comes from the heavy books) comes out be (in most cases) an acceptable loss.

Аз: последното изречение го прочети няколко пъти

Аз: :)

Той: :)

Той: awe tva jnlo mn bavno zarejda obache

Той: https://openjfx.dev.java.net/learning.html

Той: skivai tova

Той: http://download.java.net/general/openjfx/demos/tesla.jnlp

Той: ima torque/power curve

Той: a to html i js uj prosto ama vari pravi ajax

Аз: ?

Аз: винаги съм се дразнил на джава приложенията, че нямат райт клик

Той: mi ne e prosto da praish dobar interface (ajax) za www

Той: ich daje

Той: kav right click :)

Аз: explain:

Аз: a to html i js uj prosto ama vari pravi ajax

Аз: mi ne e prosto da praish dobar interface (ajax) za www

 Аз: apletite i сега javaFX нямат right-click

 Той: nali vikash che sa razprostranilo shot bilo prosto

 Аз: zabranen e

 Той: :)

 Аз: da, taka e

 Той: em prosto da praish prosti neshta :)

 Аз: taka :)

 Аз: гмаил, гугъл мапс

 Той: zashto tezi koito iskat da praat ne prosti neshta tria da lejat varhu prosti tech

 Аз: прости ли са?

 Той: shot prostite tech sa sa nalojili

 Аз: защото те са популярни и се поддържат от публиката

 Той: ili shot te samite sa prosti che ne sa nalojili drugo vmesto da praat shitove running varhu prostite tech

 Аз: бизнесът търси размах, дори и да имаш супер технология, ако тя не се ползва, няма смисъл от нея

 Той: mrazq bisnes :)

 Той: i mrazq da mrazq :)

 Аз: трудно е един бизнес да 'налага' технологии (виж на Майкрософт колко им е трудно един стандарт да наложат)

 Той: mi to ako e qko moje da se samonaloji sigurno

 Аз: целият софтуер, който се пише е подчинен на основни бизнес зависимости: (микроикономика 101) търсене и предлагане

 Аз: има доста адекватни технологии, които не са се наложили

 Аз: причини много ()

 Аз: една технология, за да се наложи и трябва много повече от техническа адекватност

 Аз: там отново се намесва мразения от теб бизнес

 Аз: :)

 Той: biznesa razvalq sichko

 Той: vnasq mn izkrivqvane

 Той: ne sa prai shot e qko a shot tekat pari

 Той: i vsichko e shit

 Аз: приятелю мой, забавно е да те слуша човек

 Аз: причината е в развитието

 Аз: смята се, че пазарната икономика води до най-високо развитие. Тя се гради точно тоя принцип с парите, търсенето и предлагането и конкуренцията

 Той: pazarnata ikonomika e shit :)

 Той: vij posokata na razvitieto obache

 Той: tva e edna dosta shibana posoka

 Аз: посоката?

 Той: izkrivena ot bisnesa

 Аз: бъди по-точен

 Той: shit ot sekade :)

 Той: posokata da se pechalat pari

 Аз: разбира се

 Той: razvitie saobrazno taq posoka

 Той: tva e shit

 Той: pitai malkite deca ako ne mi vqrvash :)

 Аз: това е най-важния (ако не единствен) показател колко добре се справяш - универсалният показател

 Аз: хаха

 Аз: кефиш

 Той: toq pokazatel vaji samo taq matrica :)

 Той: v

 Той: v taq

 Аз: така е

 Той: :)

 Аз: другите опитани модели са плановата икономика (комунизмът), която практиката показва, че е не толкова успешна

 Аз: Пазарната икономика е естествен механизъм, който те принуждава да оптимизираш ресурсите, с които разполагаш

 Аз: парите са просто универсално разменно средство, нищо повече

 Аз: :)

 Той: mn poveche ot tova sa :)

 Той: vsashnost

 Той: za neshtastie :)

 Той: ne che i na men ne mi triat ama ..

 Аз: какво друго са?

 Той: te promenqt horata we

 Той: ne samo nekvi hartiiki

 Аз: хаха

 Аз: не перите ги променят, жаждата за материалното ги променя

 Той: e to e sashtoto :)

 Аз: а то, материалното, се измерва с пари просто

 Аз: но не забравяй, че тази жажда (или алчност ако щеш) кара същите тези хора да се стремят към тях и да работят

 Аз: двигателят на прогреса

 Аз: точно тук е гениалността на пазарната икономика естественото желание да купиш най-много с най-малко

 Той: na metrialniq progres

 Аз: ?

 Той: materialniq progres

 Аз: ами духовното е индивидуално, много трудно се измерва с пари и е трудно да се вкара в тая 'матрица'

 Той: to ne moish da go izmervash s pari

 Той: am kvo stana s html i js

 Той: shte gi mahame li ot upotreba :)

 Аз: едва ли скоро

 Аз: :)

 Аз: бтв, мога ли да пусна разговора в блога си?

Strongly-typed vs. weakly-typed

There is a certain group of people (counting me too) that are used to working with strongly typed languages. It's really hard for that group of people to understand how technologies like php, html, javascript (..., rss, perl, ...) become so popular.

The answer is (in my humble opinion) the ease of use and rapidness. Everybody can learn to use them. Sacrificing the good style and the heavy approach (that comes from the heavy books) comes out be (in most cases) an acceptable loss.

# Wednesday, June 18, 2008

Chill the coffee out

Patents pending - don't steal my intellectual (he he) property.

The biggest screen resolution I have ever seen - found in my living room

Have you ever seen a screen that supports that big a resolution? This is (...calculating...) ~4.29 GigaPixels. Quite a lot, huh?

Check out how many options it gave for color depth.



P.S. This happened on a friend's machine after two years of no support and windows update.

A custom res:

# Tuesday, June 17, 2008

README - gramatic rules for the Bulgarian language (priceless).

Although it's short and incomplete it's really a cornerstone read. Every single Bulgarian must be forced to read it and memorize it:
http://www.uni-bonn.de/~manfear/lang_mistakes_bg.php

In a few days

In a few days this adventure (having a blog) is going to have its first birthday. I remember the birthday because it is embedded in the admin password (yea, try me ;).

Today I was reading a few articles about having a blog (here and here) and the impression I got left with was that starting a blog is not always a good idea and to do that you have to have something to share and to follow some rules and most importantly have a goal.

F**k that. (Update: I don't know why I put asterisks, maybe I'm afraid of the moderators ?!)

I don't know if I have something to share. I don't know if I have a goal set for my blog. I didn't know about the rules until today. But I don't care.

What made me start the blog was an article from Joel (I can't find it right now) that simply said that a blog can help you express yourself better, can help you perfect the language you present your blog in, can help you understand yourself better. And one other thing - get more feedback for yourself - and that one is particularly precious for me.

So, do I follow the rules - no. Do I care - I guess not. (yea, sometimes I check the logs to see how 'famous' am I and the good results and some comments boost my ego, but that's pretty much it). Overall, I find it a good experience and the time spent on the blog wasn't completely waisted.

What am I going to do from now on - I guess pretty much the same thing.

P.S. Thank you my one reader for the continuing support and the few comments you left from different IPs (appreciate the effort). I would gladly buy you a beer.


'I'm shocked'

'I'm shocked' is what Charlie Sheen playing Charlie from 'Two men and a half' always says with a beer in his hand when his brother does something stupid.
(Comment to me: I have a problem: cannot produce short sentences.)

Here I am playing the dumb thing Vasko and I gave as a present to one crazy dude:



Update: it's fu*king unpleasant.
# Monday, June 16, 2008

the telephone of confidence

Last night I fell into depression, and called "the telephone of confidence".
My call is redirected to Pakistan.
I said that I'm going to suicide.
They rejoiced and asked me if I can drive heavy trucks ...

# Wednesday, June 11, 2008

Dream working place



What's missing is a hot girl bringing me stuff. The chair is awesome.

Vista connected to the internet - does not know about it

Check it out:



Happened after installing updates but not restarting afterwards.

E-banking - finally, there may be a winner

Seeing these posts first may help get the context of the talk:
What not to do when you're a bank
What to do when most e-banking interfaces suck?
First Investment Bank, the sequel
SG Expressbank

Being stuck with SG Expressbank made electronic transfers impossible, because they didn't work with epay.bg (prohibited) nor did they work with the e-banking software (every recepient has to be registered offline on-site (bank office), and for the ones that are registered the software does not work :) ).

Almost by accident I tested a card I had in epay.bg for the balance (most banks have stopped this service, because of too many requests). And... I got it. It was working. Strange.

I remebered that I had registered the e-banking for that bank and had left the user/pass somewhere.

After a few days of searching I found it.  Keep in mind that getting the user/pass from the bank was quite an adventure and took more than 20 days and quite a few trips to the local office.

The login screen is right on the main page of the bank. I was amazed to see how easy the generation of the certificate was. While doing it I saw that they support smart cars (e-signatures). Well done.

The interface is really user friendly. Supports almost everything or at least it seems so. I haven't tried it yet, because the bankaccount is nearly emtpy.

From the interface notifications can be defined: SMS notifications, email notifications. Now I'm waiting to see whether it works.

A minor drawback was that I can't tranfer money to another bank account via epay.bg - I guess only FIB cards can (FIB is connected to epay).

And because I'm lazy to do it the old-fashion way - now I'm using the only possible way to transfer money electronically from SG Expressbank card to the new card I have - the epay's microbill (микросметка) - another thing I have to learn how to use. It was quite straight forward to start up and use, but it takes a few days (in my case 2 full days) to tranfer the money and the commissions are not going to be small.

# Tuesday, June 10, 2008

ant junitreport task cannot set vm arguments

ant junitreport task creates a html report from junit xml report files.
If the xml files are numerous enough and/or large enough (mine were 102MB total ), the task crashes with OutOfMemoryError.

Solution? set the GLOBAL variable ANT_OPTS. This changes defautl ant conf for the whole machine this setting is on.

Not very nice :)

CVS: dying gasps from server

Why can't there be software that just works?!

There's a CVS server (version 1.11.22) [one can get the version with cvs version -d cvs_root] on a Linux machine.

There's a Hudson on the Linux machine that queries the cvs just fine.

I have Hudson on a Windows machine that gives me:
cvs checkout: dying gasps from server unexpected

The explanation? Here's the best I could find:
dying gasps from server unexpected
There is a known bug in the server for CVS 1.9.18 and older which can cause this. For me, this was reproducible if I used the -t global option. It was fixed by Andy Piper's 14 Nov 1997 change to src/filesubr.c, if anyone is curious. If you see the message, you probably can just retry the operation which failed.

Sources:
http://magic.astro.uni-wuerzburg.de:81/mars/cvserror.html
http://cvsman.com/cvs-1.12.12/cvs_210.php
http://developer.apple.com/opensource/cvs/cederquist/cvs_174.html

Now check the version of the server I have (in the beginning). So what do we do now?!

Why can't there be software that just works?!
# Friday, June 06, 2008

Eclipse, interface implemented by classes, but the implementation is in a base class

Suppose there's an interface

interface PrimaryObject {
    int getVersion();
}


and

public class Base /* not inheriting PrimaryObject */ {
    int getVersion(){}
}


now suppose there are a lot of classes like

public class Class1 extends Base implements PrimaryObject {
}

So why did I mention Eclipse in the title:
When you go to the interface and press Ctrl + T on the interface itself you get a list of all the classes like Class1:



But you you press Ctrl + T on the method you get NOTHING:



Eclipse fails to show all the classes that implement this interface and this method.

@Lob in JPA, what if the class is not Serializable

If you have

@Entity
public class Student {
    @Lob
    private static MyPictureClass picture;



and suppose you forgot to put Serializable to MyPictureClass, then guess what: there's no exception. You have to check the data in the DB.

Surprise no2:
Suppose MyPictureClassis a base abstract class and it is not Serializable. Suppose every inheriting class is Serializable. Then what happens? Well one thing's for sure: there wouldn't be an exception, but there wouldn't be any data in the DB (you'll get null). The runtime checks (in Hibernate) check the signature of the defining class I suppose, not the supplied class at runtime - and I would assume the opposite, because serialization works the opposite way. Maybe it's because Hibernate does some runtime bytecode modifications.


Primitive types as fields in an JPA Entity

The JPA spec supports primitive types as @Columns. What they don't say (assuming Hibernate is the implementation (maybe TopLink does that too)) is that this column becomes nullable = false and the default value is the default for the primitive type. And that is so, even though the @Column(nullable by default is true.


So

@Entity
public class Person {
    private int age;
    private boolean male;

actually means

@Entity
public class Person {
    @Column( nullable = false )
    private int age = 0;
    @Column( nullable = false )
    private boolean male = false;

So watch out.

The new firefox 3.0 RC1 (update: RC2)

The new firefox 3.0 (not final yet - rc1 for now) is awesome. Most plug-ins don't work yet, but that changes very rapidly.
The engine itself is unbelievably fast and looks pretty stable - for a few days it crashed only once - trying to start the updater.

Try it, definitely try it. Link.

Update: the RC2 is out. The link points to it.

# Thursday, June 05, 2008

SG Expressbank

Another bank that I'm unhappy with - SG Expressbank. Reasons
  1. They charge me with 0.69 on ATM withdrawal.
  2. They charge me with 1.39 (monthly fee)
  3. Interest rate: 0.00
  4. E banking application - outrageously bad (screws up every file format I request, cannot send money to an account without going to the bank (some security shit), ugly, not intuitive)
  5. The service is far from good.

I'm looking for a decent bank. Any ideas?

hudson ant javac unit-tests fork=true, cannot start javac.exe compiler

Hudson is a continuous integration tool similar to CruiseControl. It has a very good web GUI for defining tasks unlike CruiseControl.
Inside it I have configured a call to an ant task.

Strangely enough in on of the projects that had to be build I got:

build.xml:200: Error running _path_to_jdk_/javac.exe compiler

Strange.

I double checked the script in eclipse. It worked.
Manual call to ant on the eclipse machine also worked.

Then I went to the Hudson machine (a test environment). I ran the script manually. The same freaking error.
I copied the whole dir to another place on the test environment: no problem.

Maybe it's the credentials: added read/write to all. Still the same error.

Then I ran the script with: ant -verbose and see what I got:


_path_\build.xml:75: _path_\javac.exe compiler
        at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:509)
        at org.apache.tools.ant.taskdefs.compilers.JavacExternal.execute(JavacExternal.java:61)
        at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:997)
        at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:820)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.io.IOException: Cannot run program "_path_\javac.exe": CreateProcess error=87, The parameter is incorrect
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
        at java.lang.Runtime.exec(Runtime.java:593)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:828)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:445)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:459)
        at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:506)
        ... 20 more
Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
        at java.lang.ProcessImpl.start(ProcessImpl.java:30)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
        ... 29 more
--- Nested Exception ---
java.io.IOException: Cannot run program "_path_\javac.exe": CreateProcess error=87, The parameter is incorrect
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
        at java.lang.Runtime.exec(Runtime.java:593)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:828)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:445)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:459)
        at org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter.executeExternalCompile(DefaultCompilerAdapter.java:506)
        at org.apache.tools.ant.taskdefs.compilers.JavacExternal.execute(JavacExternal.java:61)
        at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:997)
        at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:820)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: java.io.IOException: CreateProcess error=87, The parameter is incorrect
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
        at java.lang.ProcessImpl.start(ProcessImpl.java:30)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
        ... 29 more


Cannot create a process?!
That's weird.

So tired enough I did something desperate:

From
<javac fork="true"


I went to
<javac fork="false"

and it worked ..... :(

Keep in mind that in the same build project I was calling a few other build.xml doing <javac fork="true" several times before this one.
But this one was the only one having a reference to junit.jar (somewhere on the net I saw an article saying something about junit but don't remember what).

So I left it like this.

# Friday, May 23, 2008

And if that doesn't put a smile on your face...

... I don't know what will:




And because nowadays it's modern not to steal intelectual property, here's the source of the picture.

# Tuesday, May 20, 2008

First Investment Bank, the sequel

I was unhappy with my bank (What not to do when you're a bank).

Recently, the rumors about it going bankrupt became stronger and stronger so I cashed out my accounts and went for another bank.
The rumors came out to be fake and I felt like a dumb ass, becase I followed unchecked information.

But overall I don't regret my decision. The bank now has a new software which sucks big time. I was on a few occasions unable to access my money (ATM, online, bank office), so I don't think this is a bank that I could trust.


First Investment Bank, you were one of the best, now you're one of the worst.

# Thursday, May 08, 2008

What to do when most e-banking interfaces suck?

In a previous post (here) I spoke about having trouble with e-banking software of my bank.

There is a pretty simple solution - the online payment operator - epay.bg. It also can do bank transfers, so it's perfect for the task.

Epay can work with almost all bank cards, it's cheap, it's user-friendly, it's reliable. It's the perfect solution.
One minor drawback - it can't check balance, because for sometime now most banks don't support that feature for epay :(

Still I'm going to use it. I can check my balance using the e-banking app.

What not to do when you're a bank

My primary bank is First Investment Bank.
I chose a quite a while ago because it had the reputation of a bank that was the first in everything.

It's e-banking was uncomparable with the competitition - outrageously ugly, but accepted smartcards and did all I wanted it to do.

Now it's getting different - they changed their system with a new one. Something called FlexCube. Weirdly enough owned by Oracle.

From internal sources I know that the new system sucks and they failed to deploy it for more than a year. And when they finally made it last week during the weekend - my bank card was not working, meaning me without access to my money just before I went to Serbia. I had to take a loan to be able to go - not a pleasant thing to do.

So about the new e-banking interface - it sucks, all my preferences and beneficients are gone. It's ugly and hard to learn.

So I'm looking for a new bank with a decent e-banking services.

I have experience with SG Expressbank and Postbank - they suck too.

Update: the comments following that post reminded me of a story:
I was in the Netherlands. Once talking to one of the guys we discussed how much cash does each of us carry. I did carry a lot, he counted on the cards he had. My case: bank cards don't work on the road, on the street, they can fail, cash cannot fail.

Later that week:
There was this friend with which we drank quite a few drinks and on the way back to the hotel (I was in an apartment, the friend in a hotel) they said the employer forgot to pay the room, so it couldn't be used. We tried all the credit/debit cards we had - no luck - none of them worked. He had to sleep at my place. Cash is bulletproof !

# Tuesday, May 06, 2008

Srbija

I spent a couple of days in Serbia. Pictures here.

Overall I was surprised by what I saw - although they are not a rich country, its visible that they are situated closer than us to the more developed countries.
They don't speed on the road, it's clean and nice and green and ordered, people are really polite, roads are so much better than the Bulgarian ones.
Overall they are more advanced than we are.


# Friday, May 02, 2008

EJB Exception wrapping, commiting broken transactions, resource handling in finally statement - overridding thrown exceptions

In this piece of code the task is to override system exceptions (JPA, JTA exceptions) with application exceptions:

try {
    transaction.begin();
    bm(); //business method
} catch (PersistenceException) {
    //rewrite persistence exception and throw it     (1)
} finally {
    try {
        transaction.commit();
    } catch (RollbackException re) {
       if( re.getCause() instanceof PersistenceException ) rewrite
       else // THROW SOME DEFAULT EXCEPTION          (2)
    }
}



The rewriting of PersistenceException (PE) is straightforward.
It could come from the business method (bm()) and from commit().
When it comes from commit() it is wrapped in RollbackException. Thus the if.

Unfortunately if PE is raised from the bm(), it is also raised from the commit().

So if I throw an exception at (1), it gets overridden in (2). As simple as that. Because of the finally's ability to override results (OOP got messy here).

So what should be fixed?
First, at (2) I shouldn't throw any exception.

Second, I'm thinking of checking the result of bm() - if an exception, don't call commit(), but rollback().
Sounds right.

# Wednesday, April 30, 2008

EJB Sucks: one more reason why

I'm trying to like the specification, but I just can't.
Here's one more reason why:

I have SSB (Stateless Session Beans). The persistence is via JPA (implementation is Hibernate).

All my business method look something like:
...
public Object1 doSomething( Object2 ) throws ApplicationException1;
...


I use CMT (Container Managed Transactions) which means that the container calls begin() before the method call and commit() after the method call is over.

The problem: what happens if the transaction is rolled back?

A RollbackException is thrown. It looks common sense to try to rewrite it as ApplicationException1. Well.... YOU CAN'T.

No F way (at least not an easy one).

Solution1:
Make the Beans stateful and use SessionSynchronization. UGLY - I don't want to be stateful.

Solution2:
Implement TransactionSynchronizationRegistry - just look at it.

Solution3:
Make a facade EJB that calls my own EJBs which should use requiresNew. One more level of abstraction? I have to change the contract? I don't have just one Bean, so a wrapper for every single one of them?

Solution4:
Switch back to BMT (Bean Managed Transactions) and call begin() and commit() myself. Well then the container becomes useless. But my business methods are rarely longer than a few lines, so I'm choosing this one.


CMT without any simple way to plug after commit() and this is an enterprise level spec? Really?

I'd be really happy if someone corrects me and shows me a simple way to do what I need.

# Tuesday, April 29, 2008

Cases in SQL syntax

I've never seen this SQL syntax:

    select
        column1,
        case
            when table1.column1 is not null then 1
            when
table2.column1 is not null then 2
            when
table0.column1 is not null then 0
        end as column_nameX,
    ...

Have you?

JPA (Hibernate), EJBs, and WebServices interface.

Here's the design:
EJBs for business logic, JPA @Enitities for object (domain) model, Web services for a public interface.

The model is quite complex.

Even in the presentation (web services) I use the entities model.

The problem comes from that in the presentation a call is made to an EJB. The EJB returns an entity which after the call is ended gets disconnected. So all collections (@OneToMany) cannot be loaded.

EAGER fetching was the solution but then half of the database was loaded on a single method call. And eventually I got to a really ugly MySQL limitation (A query with more than 61 joins (inner selects + cases + at least 40 left outer joins) and a length of 436 lines.

Now before returing the entity in the EJB method via Reflection I initialize all the collections I need. Ugly.

What I need and would perfectly fit me would be an eager fetching only until some level of deepness is reached, then switch to lazy. Then a level of 2 or 3 would be perfect.

Currently I don't of something like that existing.

If someone has an idea, please let me know.

MySQL sucks: one more reason

MySQL is a RDBMS. Or at least that's what it's creators claim it to be.

There's no other self respecting database who's only engine that implements transactions (innoDB) is not created by MySQL guys. Only until recently their own engine claims to support them. Even small in-process databases like Hypersonic and Derby fully support transactions from version one. Flawlessly.

Today I found one more reason for which I think MySQL should not be put under the category RDBMS:

Caused by: java.sql.SQLException: Too many tables; MySQL can only use 61 tables in a join
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:3026)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1137)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1231)
        at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:236)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
        at org.hibernate.loader.Loader.doQuery(Loader.java:674)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
        at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)


Until recently the maximum was only 31 table. A major WTF?!

I would gladly bet that Hypersonic and Derby do not have a constraint like that (haven't investigated it though).

The stack trace is intently complete to show that this comes from Hibernate. This can be reproduced by having a rich object model with EAGER fetching.

Maybe I'll write a little more on the EAGER fetching and the issues I have: here.

# Tuesday, April 22, 2008

Localization (L10n) vs. Internationalization (i18n)

As simple as that:

Internationalization can be thought of as the design and information technology practices that enable localization to take place. It adapts products for potential use all over the world, whereas
Localization allows products to be suitable for a specific place, or “locale.”

So before thinking about localization, product and software designers must conceive the product in a way that will allow it to be later localized to many different cultures.

# Saturday, April 19, 2008

The easiest A in years

I got an A today in corporate finances - there was no exam, just an A for participating in classes and being memorable enough :)
Not everyone who attended all the classes was remembered - finally a reward for speaking in classes and asking dumb questions.

# Wednesday, April 16, 2008

I'm fine, thank you for asking :)

Today after an additional X-Ray I got a shot in between the bones and expect to have more
... and got this thing:



I gotta be with it for 10 days.

The good news is that the new X-Ray photos show no dislocated bones and fracture.

The old one was pretty scary:


# Monday, April 14, 2008

ICQ in GoogleTalk web client (gmail) - revised

What I wrote so far:

Open browser, go to the messenger part, log in, as simple as that.

First impressions:
  • no ICQ groups - that sucks - I used to use it a lot
  • aliases of people are retained ('MG Zas' for example) - which is a backup for groups ('group MG -> user Zas' becomes 'MG Zas').
  • Cyrillic characters work fine (if it was working with my other client - Pidgin/Gaim)

Concerning the standalone client - Google Talk - I have no idea if it works there - Google have a pretty wierd update policy - they update silently and only some clients - it sucks.



After all  - it's usable

After a week of using it this is what I noticed:
  1. Cyrillic doesn't always work with everybody, sometimes UTF-8 comes as cp-1251, even though the browser is in UTF-8.
    1. However, when I write, everybody sees it correctly.
  2. No way to give authorization to people, no way to ask for one.
  3. No way to see user info. No way, really.
  4. Some of my peers receive everything in html. It's hard to chat with them.
    1. I guess people without the official client.
After all - it's still usable, but I'm not going to recommend it to any more.

Warning: stuff gets modified in the future

Look what I got some time ago:



Explanation:
Obviously this could happen when Ant sees files that are modified after the script is started. Which is what I did. This could also happen if sources are copied from a different machine with different system time.


Still the warning is kinda weird.

[Joke] IT Developers in projects

Five cannibals (Man eaters) get appointed as programmers in an IT company.
During the welcoming ceremony the boss says: "You're all part of our team
now. You can earn good money here, and you can go to the company canteen
for something to eat. So don't trouble the other employees". The cannibals
promise not to trouble the other employees.

Four weeks later the boss returns and says: "You're all working very
hard, and I'm very satisfied with all of you. One of our developers has
disappeared however. Do any of you know what happened to her?" The
cannibals disown all knowledge of the missing developer. After the boss
has left, the leader of the cannibals says to the others: "Which of you
idiots ate the developer?"

One of the cannibals raises his hand hesitantly, to which the leader of
the cannibals says: "You FOOL! For four weeks we've been eating team
leaders, managers, and project managers and no-one has noticed anything,
and now YOU ate one developer and it got noticed. So hereafter please
don't eat a person who is working."

source: here

# Sunday, April 13, 2008

Refactoring

On a recent project I had after some thoughts I decided to unify some coding styles.
Eclipse rules in that matter. It was cumbersome, but easy enough. Until I reached a point.

Refactoring some coding style differences is a piece of cake.
Refactoring some design issues you want to fix is mission impossible.

The best way to proceed - scrap it and start from scratch. By scrap it I mean make a clean project and copy only relevant stuff.

Now this project has 2 times less classes :)

Dude, where's my terrace?!

И сега къде ще си простра прането:
(коментарът е на БГ, щото ми е трудно да преведа "простра прането" на английски)

Fix this

Only a restart can fix this
(happened after a beamer was unplugged, vista rulez)


10 kilometers

I ran 10 kilometers today. But only if the track was 400 m long, if it was 300, I ran only 7.5, which is still a good result for me.

# Tuesday, April 08, 2008

Старата фонетична за Виста

(Само и само да си вдигна рейтинга в Гугъл...)

Както всички, които са ползвали поне малко Windows Vista, са забелязали - няма я старата фонетична подредба. Аз лично я ползвах доста. Вместо нея има сложена една "стандартизирана от БАН" фонетична подредба, на която обаче няколко букви са разместени. Примерно Ж е на мястото на W, което на мен не ми харесва.

Имаше някъде спор из нета относно коя да бъде - старата или новата, но ме мързи да търся.
Аз си харесвам старата и открих един инструмент от Майкрософт (тук ще ги похваля), с който сравнително лесно могат да се пренаредят клавишите (едно време имаше нещо подобно във FlexType (моля ви, не си слагайте FlexType - Инженерът ще се кара)).
Инструментът се казва Microsoft Keyboard Layout Creator. Работата с този инстурмент не е толкова елементарна колкото изглежда, аз няколко пъти оплесквах нещата.

Та а използвайки тоя инструмент си направих фонетична подредба.

Update: във фонетичната на БАН забелязах нещо интересно: Shift + ь = ѝ. Тоест малка оптимизация. Ер малък се използва само като малка буква. Главна такава буква в Българския език няма. На мястото на главната буква те са сложили "и с ударение". И с ударение също няма главна буква, тоест ѝ трябва само една позиция на клавиатурата. За "и с ударение" имам малко инфо тук.
Та аз реших да направя същата оптимизация и направих нова версия на класическата фонетична за Виста.

Инструкции за инсталация:
  1. от zip файла с инсталатор цъкнете на setup.exe, следвайте инструкциите.
  2. Клавиатурата сама се "пъха" в активните, така че веднага е готова за употреба.
  3. Ако все пак искате да цъкате ръчно разни неща: "Regional and Language Options" в Contol Panel -> "Keyboards and Languages" -> "Change keyboards..."
  4. Фонетичната на Виста/БАН се казва "Bulgarian (Phonetic)", моята излиза като "Bulgarian (Phonetic) - REAL"
  5. Ако имате старата ми версия инсталирана, по-добре я махнете, тъй като и старата и новата излизат с еднакво име. В списъка с инсталирани програми се различават по версията, обаче.
Поддържани хардуерни платформи: i386 (32 bit), ia64 (64 bit), amd64, wow64 (дори не знам какво е това).

Това е фонетичната подредба за Windows Vistа (в архива има инсталатор):
Bulgarian (Phonetic) - Old School (by Mihail Stoynov).zip (253.38 KB)      (без оптимизацията за "и с ударение")
Bulgarian (Phonetic) - Old School (by Mihail Stoynov) v2.0.zip (252.92 KB)       (с оптимизацията за "и с ударение")

Ето и самата подредба (ако някой иска да си играе с нея, не е никак елементарно):
Bulgarian (Phonetic) - Old School (by Mihail Stoynov).keyboard layout.zip (2.26 KB)      (без оптимизацията за "и с ударение")
Bulgarian (Phonetic) - Old School (by Mihail Stoynov) v2.0.keyboard layout.zip (2.33 KB)     (с оптимизацията за "и с ударение")

# Thursday, April 03, 2008

JPA (Hibernate) and enums, Updated

If there's an enum
(this is all java 5)
  
@Entity
public static enum Type {
    TYPE_1(1);

private int i;
    private Type(int i) {this.i = i;}
}


you can't do entityManager.merge( Type.TYPE_1 ), because merge returns a persisted copy of that object and requires a default constructor.
Even if you add

      
private Type(){}


it would fail.

The only way to add the possible values is with persist:

step1:
for( Type type : Type.values() ) {
    entityManager.persist( type );
}

Unfortunately I don't know of a shortcut for that operation - it seems logical all enum values to be in the DB, but are not there by default.

So what happens if there's an object

@Entity
public class Subscription {
   // Cascading for all operations
   protected Type type;
}


and one wants to persist an object like that: 

entityManager.persist( new Subscription() ); // would work even without step1
entityManager.merge( new Subscription() ); // would work only with step1
entityManager.merge( new Subscription() ); // without step1: "
InstantiationException: No default constructor for entity

So the conclusion is:
It's relatively easy to use enums as @Entities as long as on DB init all the enum values are preloaded in the DB (step1).

UPDATE:
What I wrote so far is true, BUT:

Even if one can persist enum, one cannot get them back, because of the aforementioned problem with the default constructor.

I was thinking of the doing the type-safe enum design pattern myself (as it was done pre- java 5): useless supplying a default .ctor prevents having a small number of instances - so again no good. Maybe if the .equals() and .hashcode() are rewritten this could work (but with a larger number of instances and a small number of different hashcodes) - just thought of it, may or may not work. One has to think about @Enumerated (JPA) or about Enum.name() and enum.ordinal() - still it does not look achievable.

There is an ugly solution of which I shall speak tomorrow because I want to go home !!!.

UPDATE: The solution: (be warned it's really ugly).

There should be an @Entity with an int (or whatever actually) @Id.
Then there should be the enum with a private property, whose type should be the @Id of the previous class. There should be a getter of that property
The getter() and setter() of the @Entity should be with the enum's type and in the getter and the setter the wrapping between the enum and it's int (or whatever actually) should occur.


Examples when I get back from lunch.

UPDATE: Example

// The enum
public enum Gender {
  Male(0),
  Female(1);
  private int value;

  private Gender(int value) {
    this.value = value;
  }

  public getValue() {
    return this.value;
  }
}

@Entity
public class Entity1 {
  @Id
  private int gender;


  // ... other properties

  public Gender getGender() {
    return Gender.valueof(this.gender);
  }


  public Gender setGender( Gender gender) {
    this.gender = gender.getValue();
  }


  // ... other stuff.
}


Yes, I know - it's ugly, but this is the best I know.

JVM Crash - have never seen that before



This is to JVM* what BSOD** is for Windows.

* Java Virtual Machine (the Java runtime)
**Blue Screen of Death (the thing windows does when it crashes)

Note: this happened when trying to merge (in Hibernate) an enum with a default private .ctor.

It is a happy day :)
# Wednesday, April 02, 2008

ICQ in GoogleTalk web client (gmail) - amazing

Open browser, go to the messenger part, log in, as simple as that.

First impressions:
  • no ICQ groups - that sucks - I used to use it a lot
  • aliases of people are retained ('MG Zas' for example) - which is a backup for groups ('group MG -> user Zas' becomes 'MG Zas').
  • Cyrillic characters work fine (if it was working with my other client - Pidgin/Gaim)

Concerning the standalone client - Google Talk - I have no idea if it works there - Google have a pretty wierd update policy - they update silently and only some clients - it sucks.



After all  - it's usable

First in weird google search

How can this blog be the first in this search
email program fails needs ttl start first

What's wrong with you google?!

Update: Now I'm sixth.

# Monday, March 24, 2008

Being a referee at the IT Boxing event

The event: http://itboxing.devbg.org/


100 000 bucks joke

I have a friend who once called and asked whether I could loan him 100 000 bucks just as easily as if he has said 'let's go have a cup of coffee'.

So for his birthday he got:

# Monday, March 17, 2008

I failed exam 11

I have a bad feeling in my mouth. Too bad, it would have been a good T-shirt sign: 12 exams in 1 month. Now it's gonna be even longer 10/11 exams passed, 1/2 failed in one month :)