Wednesday, February 06, 2008

How to Auto Increment version (build id) with Ant

For those who are still stuck with manual ant builds, this tiny little tip will tell you how to auto increment the version number with each Ant build. Follow the steps:

1. Create a file say build.number (or change the name to one which gives you pride)
2. Add the following target to your build.xml file, change entry key to whatever you want the property name to be:
<target name="increment_teh_build_number">
<propertyfile file="build.number"
comment="Build Number for ANT. Edit not!">

<entry key="build.number" type="int"
operation=
"+"
default=
"1" />

</propertyfile>
</target>
3. Make sure this target is executed on successful build for example after 'test' target, Once this target is executed you can use property build.number where-ever you like in build.xml, For example,

<property name="app.version" value="${major.minor}.${build.number}" />

Hope that saves you some.

Friday, December 14, 2007

Of length of experience and developer's worth

I'm of the opinion that there's no incredibly sensible reasoning which confirms that a higher number of years of experience (always) makes one developer more competent (for most jobs) than other. Before someone starts on me, I perfectly understand the value of having experience and its importance in general, but I'm not biased towards the quantitative usage of it (numbers that people like to attach with themselves). But what I don't understand is why experience becomes the only factor in rating a developer in every compensation decision?

One of the reason of this frustration is the way 'experience' is handled by Human Resources department of a average company. I, for one, extremely hate to negotiate my pay rates with pitifully non-technical HR executives, especially when a non-technical person in front says, your rate is way higher than your number of years of experience. See? they don't care about the proficiency (or productivity) required for job but the number of years of experience, they take casual interviews; get reverse-interviewed and start negotiations relating to length of experience (because they don't know how to negotiate other way). How am I supposed to make that person understand what I can do and what level of productivity I can offer? there's no measurement in competency but a person more experienced would easily win, all because length of experience has become and is increasingly becoming de-facto bargain.

Why many people don't understand that the field of Software development is way too different than most of the fields out there (like manufacturing)? Why they tend to apply their (illogical) rules of thumb to software development realm when they don't even understand software development?

In my career, I've seen many experienced people, people with considerable experience and but not many can even prove their expertise. I also know many many bright people who keep inspiring me, they also have vast experience but I consider they have valuable experience because many have learned from their and other's experiences. I've interviewed many fresh as well as less experienced guys whom I found far better and who can, any day, out-perform those so called experienced professionals. I have always favored the competent than simply experienced, because I know experience isn't the only thing that matters in my field.

It is miserably disappointing how our industry is lead by such nonsense measures of identifying developer's worth. Experience isn't the only thing that makes a developer productive, People!!

Monday, November 19, 2007

What I want to do coming year?

I have been bored programming dear old enterprise applications lately, so I am seriously thinking of doing something new and more intellectual than writing data-driven applications.

I'm thinking of doing something significant coming year; while it would be pretty tough to stick to it all year along, I would at least want to build a strong tooling around, barely known, Felix language. Felix, compiler is written in OCaml, seems to be an interesting procedural/functional scripting language. In coming months I want to build an IDE for Felix using Eclipse and DLTK sub-project. There are many strong motivations for me to start this off apart from working on something intellectually stimulating and looking DLTK from inside.

I have just downloaded sources for OCaml, Python and Felix and compiling them to get started. As of now there's no progress and I'm yet to learn python, Objective Caml, Felix and DLTK itself, but I'm sure it would be a lot of fun.

While compiling OCaml on Ubuntu 7.10 I got this error
/usr/bin/ld: crt1.o: No such file: No such file or directory
and thanks to this guy for reminding that I'm not just Ubuntu user but a developer as well and would need libc-dev for just about everything :).

I'm looking forward to creating something interesting.

Tuesday, November 13, 2007

Hibernate won't delete child objects from database

Given a commonly known parent/child relationship in a domain model, the hibernate code below would not delete child object from database.
Parent p = (Parent)session.load(Parent.class, id);
Child c = p.getChildren(0);
p.getChildren().remove(c);
c.setParent(null);
Unless you have specified 'all-delete-orphan' as the cascade value in the relation as shown below, or use 'Session' object to delete the object from db.
<set name="children" inverse="true" cascade="all,delete-orphan">
<key column="parent_id">
<one-to-many class="Child">
</set>
This detail is from hibernate manual (Section 21.3), and I have read it many times in last three years, but somehow I didn't find it intuitive thing to do and hence drawing a blank.

It's a breeze to have 'Session' object available everywhere in the code, but imagine a pile of layers hiding everything related to persistence, all you can do is play around with associative object references in the object graph.

There are many such minute intricacies in Hibernate which give surprises (and pain if that code is not covered by test cases), Endless debugging with hibernate is just as painful as dear old CMP (Container managed persistence in Entity Beans). Ironically though, Hibernate can win the "paingiving" if you use it with cglib whereby, while debugging, you see weird things in lazily loaded proxy (or object zombie if you like to call it so) where you wanted to see only a string value.

And oh I hate that AbstractEntityPersister.java with it's 4000 lines of code...