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...

Tuesday, October 23, 2007

How to add DZone voting to your Blogger blog

Update:Formatted XML and removed top-level div tag and added instruction to expand widget template, thanks to James.

DZone released voting scripts which allows site visitors to vote from the site itself. You can find voting widgets for Wordpress as well as for Jroller, but nothing for blogger :(.

So here's simplest way to add it to your Blogger blog, Just copy/paste lines below to your Blogger HTML template (after expanding widget templates):
<div style='float:right; margin-left:10px;'>
<script type='text/javascript'>var dzone_url = '<data:post.url/>'</script>
<script type='text/javascript'>var dzone_title = '<data:post.title/>'</script>
<script type='text/javascript'>var dzone_style = 1</script>
<script language='javascript' src='http://widgets.dzone.com/widgets/zoneit.js'/>
</div>


right before

<p><data:post.body/></p>


Here's the image screen shot:



Click on it to enlarge. You might want to customize it a bit, just try out different div styles. Developers, Keep voting!

Monday, October 22, 2007

On IClass (anti-)pattern

I'd been re-reading this post by Sidu and the comments on it. I had to do exactly similar to IClass anti-pattern for one of the development effort. And I think having IWhatever completely makes sense for the current state of affairs in my development environment.

While it's unfortunate, most of the time, to have an Interface for just about every class in the code-base, It does have certain uses in some situations (apart from the (IoC) frameworks which mandate you to have them) like:
  • Support parallel development.
I will define parallel development as a situation where there are many components involved in developing a software and your component (or module or whatever..) and it's arbitrary version has to support other components (and their integration tests depending on your environment). For example, for something as important as (so called) service layer in an Enterprise application you need the Interface with single implementation at one time, it might just be a 'placeholder implementation' for a dependent component while the new version being developed parallely. It just makes sure that there is something to hold the place which can be tested easily. This is one more learning from distributed development, you're not alone developing it man!
  • When using Generative development methods
If you use code generators heavily, say, most of your code-base is generated out of models (UML, BPMN, BlahL ...) then depending on the generation pattern you'll find interface for just about every implementation (or other way around for EMF generator - one implementation for each interface). This is necessary as you might want to customize forward engineering by overriding parts of generated artifacts.

Most of the Eclipse code does have this pattern, for every class there's IClass. For Eclipse, In my opinion, it is justifiable (to some extent) to have them considering it is a development platform rather than just an application. However, I would be more than interested to know conceivable reasons to have those IInterfaces which I might be missing.

Tuesday, October 16, 2007

How would you compare XMLs?

I am supposed to deal with something similar to comparing two gigantic XML documents in wild ways.

I can think of several upfront techniques to achieve it which might involve performance and maintainability trade offs. As you might know, writing code for parsing XML by hand was the the activity of ancient times (hey there are you still writing code for parsing XML?), today we've plethora of tools to parse, bind and persist XML with very less pain. I came across several XML binding libraries like JAXB2.0, XMLBeans, JiBX etc (and given a change why not EMF?). JiBX seams to be interesting but since I'm bounded by not using open source at will, I tried JAXB2.0. The XML schema provided to me was a huge XSD document, the JAXB binding compiler spitted 550 Java classes out of that.

A test driven simple recursive depth-first reflective (opps, too many adjectives) traversal algorithm on the generated object tree sufficed the requirements to identify XML delta information. This was very obvious and pretty fast solution (fast to develop), the downside is, it would require maintenance of 550 generated classes, though they can be regenerated and synchronized with the help of XJC ant task but still the memory foot print and object creation time can be circumscribing for production code.

The other approach I tried was calculating XML diffs using XML processing. I found a nice little utility library XMLUnit among others, which does almost the same what I want. XMLUnit is a tool primarily for unit testing XML-intensive applications, It is very small with clean API and well documented (if you want to read i.e.). There are several utility classes which shields you from looking/writing ugly XML processing code which I used to get the XML diffs. Although I need to poke around on XMLwith XPath still because of the complex requirements.

I would have tried my favourite XStream as well but FAQs suggests me not to, anyway, What would be your strategy to deal with something like this ?

Wednesday, October 10, 2007

Pain of Sourceless Development for an Open source developer

I'm proudly an open source developer, working on Java, And I just realized I can't live without source code of every framework or library I work with. I know many of you are like me, we know we speak code, we write it, we hear it and we communicate in it. Not having source means we are impaired.

Before it happened to me, Neither could I imagine nor perceive myself working with a piece of software without source code, It was so common to have code before, and hey shouldn't that be included in programmer's bill of rights? But, First time in last few years, luck had it and I am working with a closed propriety framework, its painful for all. If you're in the great world of open-source software, you might have started thinking how painful it can be to program without code.

Not having source code means lot of things, debugging becomes nightmare which not only makes you feel stupid to debug but also it frustrates as you feel back in blind environments like the one in M$'. If there's a bug you have no way to look what's going on in the library or framework, you would wait till their (software vendor's) "support team" identifies or guesses what's the problem and gives a patch, which would take like weeks.

In Java, You can try decompiling the binaries, it's easy with Java unless binaries are obfuscated, this can be helpful to an extent. But most decompilers are not very debug-friendly, it would generate source in arbitrary assumptions, so unless you recompile the source back, you're stuck. But decompiling, recompiling and then looking around the weird identifier and method names and reordered statements will drive you crazy, but for Java developers there is a cool eclipse plug-in which would feel like a medic, it's name is JadeClipse. Though, it's too much for just knowing what's going on inside the third party's code.

While wider acceptance of Open-source in the industry is a definitely good thing, but beware it makes you feel less comfortable working with proprietary closed source softwares once you are used to it. I'm still wondering, how long would closed source software exist in platforms like Java or languages like Ruby and likes?

But please, for the hack's sake, please let us, the software developers on the mother Earth, see the SOURCE CODE.

Monday, October 08, 2007

The art of not repeating yourself

I discovered a great bug in the my code today, It was weird hibernate related bug. If you have been working with hibernate enough you know you've to be careful about the ordering of statements relating to your persistent object model, that may sound little odd but that's how it is with hibernate. If you hit the SQL constraint exception and you've multiple joined entities, be cautious, you might want to isolate call to some many-to-one references earlier than populating your domain object.

There are several ways you'll force flush to hibernate session and that flush (a flush can be a batch update) will cause DB validation and if that flush happens before statements that set the non-null fields, you'll be greeted with boring exceptions. They are not very interesting exceptions to deal with and it might take sometime before you understand what's going on. In general, debugging hibernate code is never interesting unless you've less experience with some outstanding ORM patterns.

The problem that I hit today was slightly different than what I described though (but I've experienced similar problems many times), My problem was that I was inadvertently modifying a read-only row which had 'long' primary key with '0L' as value, if you've worked enough with hibernate types you know 0 (zero) is the default value for long and integer types. It is just because I was modifying that row by mistake hibernate decided to save that row with different primary key (new sequence number), it assumed 0(zero) as default value (dirty value in Identity Map) for long primary key type, this is bad assumption but there are less ways any ORM framework can find dirty objects. So from next time onwards be aware about these little details If you hit problem of similar nature.

How I prevented myself from repeating was the way of writing a simple JUnit test case which isolated the problem in my code and pointed me to the place where I should be looking without long (very very long) J2EE debugging session. Let me tell you, that's great relief! With that test case I was able to refactor the code and resolve this bug without too much pain. Which makes me and my manager happy :)

If you've been experimenting something similar, I would be glad to know..

Friday, October 05, 2007

Layman's review on Modeling etc. features in Netbeans 6.0

I know, I'm not going to sound very good for this post on the planet and expecting very less dialog in form of comments on it, but anyway...

The Java development blogosphere is experiencing a new wave of marketing campaign, yes everyone is talking about Netbeans, but hold on, it's not just viral-marketing, I found reviews where some says it's ruby support is the bomb, some are finding profiler better, someone is just finding it coming-up with better attitude:). Well, I've to tell it, I'd tried Netbeans in various forms in last few weeks, I can tell you it can do pretty much what all IDEs do these days. Netbeans might be looking less refreshing with all that swing (elegant inside!) rendering, but giving Eclipse Key binding, for example, really shows it's eager to compete your favorite IDE. In this post I'm not trying to say Netbeans is better or something like that, my love for Eclipse is unparalleled for various reasons, but yes I am, sure, eager to tell you my modeling experience with Netbeans.

Before I do that I'd just write down my opinions about Netbeans 6. I would say, profiling is really pretty good, I don't need to understand nefariously complex architecture to use it, I don't need to go to help to use it. See you would say, TPTP is complex only for lame users. Are you talking about UI? how many perspectives you have as part of TPTP? which one to use for profiling? and what you've to do to profile remote Java application? can you answer it without looking in documentation? Don't get me wrong, I'm trying to be as unbiased as I can.
As for Ruby support, It is just about as good as DLTK Ruby IDE, I'm no Ruby big shot as yet, but things works pretty OK with DLTK as well, cheers! Netbeans has fantastic UI editor though, VE plain sucks, oh and is it around now? last time I heard it's dead.

Now on modeling, To My fellow Eclipse committer guys, let's face it, Eclipse doesn't give anything in modeling front which an average user can use out of the box. It might have innovative and wonderful framework / UML infrastructure for building tools around it though, which is very well appreciated by 2% eclipse plug-in developers (including me), fine. So for our hacky interests EMF might replace MOF but Eclipse users are not getting any advantage of it. I know, some might say it's no big deal to not have modeling as a part of IDE, but hey that's the whole point, everything from single place is the point. Few would like to use Visio to model class diagram and then write code for it. We've quite a few other reluctantly-opensource projects, in the community, controlled by arbitrary licenses which are not very useful.

For those who don't agree, download and try Netbeans for modeling, You will, for sure, appreciate the efforts put into it, it can do hell lot of stuff (It can't copy and paste model elements in single diagram though :) ), Java reverse engineering, simple modeling, in context design pattern appliance, it's just there and works! you don't need to find something on Internet and read it's license thrice before using it. And the best part of it, It doesn't cost an arm and leg to get these features. OK, it might behave little in-development but it's just there for you, try it!

Eclipse is the great Plaform and I can't even start to compare it or any of it's innovative aspects with something as trivial as Netbeans in that context, but guys, shouldn't Eclipse consider it's "end-users" who expect nice features? Advocacy on plain words don't help, it needs strong backing of solid product which offers something more. Learn Learn..

Thursday, October 04, 2007

Dealing with tedious job

So, You are stuck with the wrong job and want to do something different to get your inner-geek rolling. Well, my friend let me tell you what I've done so far when I'm in such situation, I get frustrated initially with all that chore and boredom, naturally. I know it makes you feel bad to do stupid work, but then you can be creative in that too!

I was supposed to work on completing a framework which was designed by senior team, what I'd been asked was to do all repetitive soporiferous work (I'm serious..Zzz..). Well I completed it pretty quickly but by then I thought I would do something interesting to take revenge and I jot down an automated test framework to test entire framework, now thaatt was pretty challenging. "Developer testing" makes you think wise, and I was able to understand framework quite easily. With all that fancy techniques put in the test framework, the "original" framework extensions are effortless to test now.

Well that was one thing, but sometimes you just get enterprise-world-weary to write data centric service layers with focus on all those if/else business requirements. Man, you know you've gotta a chance to show how creatively you can utilize design patterns to satisfy those requirements. Reuse your code - stop copying/pasting it, refactor it - clean it up a bit, you know sometimes you can be so creative, for example replacing repeating loop and other redundant Java statements with template methods and anonymous class like this(or if your language is pretty, use lamda forms):

public class IMWhateverClass {
public abstract class IMDoer {
private final Set elements;
public IMDoer(Set elements){
this.elements = elements;
}
public void process() {
while (elements.iterator().hasNext()) {
Z var = elements.iterator().next();
if(!doProcess(var))break;
}
}
abstract public boolean doProcess(Z arg);
}
public void doSomething() {
new IMDoer(new HashSet()) {
public boolean doProcess(String str) {
return str.matches("any");

}
};
new IMDoer(new HashSet()){
public boolean doProcess(Set arg) {
return arg != null;
}
};
}
}
I know it's uselessly verbose in Java but isn't that cool compared to copying and pasting it around? And over-engineering is sometimes fun..

So what I would suggest is, if you're at the place where you don't have enough challenges in your daily assignments and you can't switch job ;), you can always create some excitement on your own. Heh, if you think how will you get time for this, Man forget all these, you're 9-5 laborer.,

But, If you've done something interesting in such situation then I would be glad to know and try it.

Thursday, September 20, 2007

Miscellaneous Frustrations

And now, I'm working with some few hundreds of domain classes and transfer objects generated out of various "xml" configs and database schema, they are generated in such a way that they follow the language naming rules as well as readability. Well I will tell you it meets the first objective perfectly but not the latter, it's not readable at all but yeah it makes rest of the code unreadable for sure. How clever of you to make it so complicatedly vague and ho-hum long.

Working with generated code is not as much fun as you might have guessed, Sometimes you don't just feel good to read 50+ characters long ambiguous identifier, with all kinds of bad naming conventions, just to assign it a naive 'false'. Just think about it, there are tens of such fields, and much more if you got unlucky, on each object, they needs to be checked conditionally, validated as well as copied to different persistent object properties. What it results in is what I call.. MUNDANE-F*.*N TEDIOUS CHORE that causes a mental weary which can easily prevent you from keeping your eyes open till you reach first '_' in identifier past first ten chars or something.

But there are side effects to all these which you might be interested to know, you become expert and addicted to copy/pasting (so much so that you'll find 4 characters long word a good candidate to copy/paste), you'll learn coding (or typing, does it matter?) from top-bottom/bottom-top rather than left to right, it's so much fast to copy identifier substrings vertically, like a machine. No, You are wrong, Eclipse is not a good tool to work with such task at hand, might I recommend M$Word.

Also, You'll learn quite a few things including the divine principle of copy/paste reuse, why take the pain of refactoring (and wasting time in writing those brainsick tests) for reuse when you can copy/paste so easily and fast? do you care about anyone else reading your code and fixing patching it numerous times? Of course you don't. In fact, you're so clever you've built empire of redundant code, You've replicated your favorite code everywhere in the application making it impossible to eliminate it at any cost, you know you're happy, you can always find that code to copy in need. So you see, with such ingenious techniques you can become better developer and have a great peace of mind. And did I tell you, You'd spend time in redeploying entire application, on the piece of s**t which only runs on Jr0ck1t, every so often because you know how it is - you forget to put a negation in that if statement or that minor object initialization and that misspelled variable and what not. Redeploying is cool, it keeps your cpu-cores busy, your virus scanner doesn't sit idle and you get chance to look at the interesting log statements everytime with different timestamps, compare it with writing tests which can identify this problems in seconds, how lame...

There's so much to learn just so much..

Well, writing all that makes me feel just better :)

Thursday, September 13, 2007

Yet another useful reason of TDDying your dev task

I'm one of the true believer of test driven development. To those who are wondering why TDD after all? No, It's not just buzzword, Let me tell you it works, rather It makes your life less miserable! It helps well in many ways.

I'm inspired to jot some recent experiences I'd with an "in-development-legacy" Java Enterprise application, in highly domain centric team (is not fun I know, BA /and not you/ rule that space!), with little focus on code-maintainability because of regular delivery pressure (every software dev. teams I've worked with is not as creative to find outstanding excuse as different than this one, opps that's complex one ;) ).

To come to the point, I just found that if you are new to a *business domain* you might just find TDD one of the most useful technique to ask questions :). You might say WTF? asking questions should be the easiest job on the Earth, ain't it, heh? nah, not always. If you are like me who don't know what to ask (for example situation where there are too many questions to ask about and you are as blank as dry vermouth), Might I advice you to start with a test, because having test will force you to ask dozens of precise questions to start with, apparently you can't continue further development until you get answers for them. Getting answer means you're clear about what's expected of code, the requirements, which means less assumptions and f**k-ups.

Having said that, I've also found when not to TDD, well many would not agree with me but I wouldn't want to judge my code with % of test coverage all the time, which I've found many fanboys in XP-centric organizations do. I mean, come on! Let's not test the obvious code, that's such a waste of time and energy. Well, what I'm not, always, satisfied is lack of time in tddying a lot of complex code just because of less time. The code complexity(cyclomatic or other) is so much so that all permutations will lead me to exponential test counts making it impossible to write tests manually for them (In which case you would love tools like Agitar, if you can afford a license - that is).

Finally, I'm realizing that I'm continuously benefiting from TDD which makes it my favorite technique for development in all environments, what about you?

Sunday, August 26, 2007

Back to Enterprise Apps

It's been quite sometime that I worked with Eclipse and developed RCP apps and Plug-ins leveraging several *highly* interesting Eclipse projects. The more I work with Eclipse more it attracts.

But the time had it and I've to move back with traditional Enterprise Application stuff. I tried hard to be in Eco-system, but I guess I was out of luck. If you ever happen to be JEE developer you know how different feeling it is to code for Eclipse. Eclipse is fun :), Now, that I agree with chris on his views about web development, It's time for a conformity rant: Web application development sucks big time. Ok, I'm done.

Now that I'm back into the Enterprise app. dev. environment where, apparently, I'll wait months and months for Web Logic (or WebSphere w/e. all of them are bad) to start and deploy large-large application with more and more of ugly XML configs than Java code. I would have open war with the BA on requirements that don't make sense. I can't guess what else will happen with me, I've been the part of this nightmare before and It's coming back.

Oh Eclipse, I'm missing you already :(.

Friday, August 24, 2007

Undo Closetab feature for Eclipse editor tabs

One of the things I love about FireFox is it's nice feature of 'undoing' the close tab. If you work with too many tabs you know how cool this feature is.

I was wondering how useful this feature would be in Eclipse. I usually work with tens of FileEditors which keep on growing as I work, to limit my efforts fumbling around a large pile of Editors, I always turn on a useful preference from 'Preferences->General->Editors : Close Editors Automatically'. This is not enough, I still have many editors open and unfortunately it's not too hard for me to close useful editors by mistake, Ctrl+Shift+R helps though. Not sure about you but this feature will be a nice one to have for me.

Monday, July 30, 2007

Fat Jar Plugin for Europa release

There are quite a few bugs on Fat Jar Tracker lately, some of them related to incompatibility with Eclipse 3.3 release (aka. Europa). It's been a long time since I touched the code-base of Fat Jar plug-in, There were several Eclipse 3.3 API incompatibilities including setSorter(ResourceSorter rs) method, now deprecated, and replaced with setSorter(ResourceComparator rc) in org.eclipse.ui.dialogs.ElementTreeSelectionDialog class etc. I'm glad to have no other major, and painful, changes :) (at least, I haven't encounter one so far).

If you are code freak, changes are committed to cvs repository at fjep.cvs.sf.net. For the users, Since I'm just a developer member of the project, I don't have enough rights to upload the build and release the plug in officially, all I can do is to provide you a link for the latest build which works with Europa release. As of this time, I'm not sure when the latest plug in will be available from sf.net, in the mean time you can download it from here.

Enjoy Deployment with Europa :)!

Friday, July 13, 2007

Why is coding considered inferior?

So far, I've been in two quite different IT environments.

One Environment where you are known by your technical competencies and knowledge, you are appreciated even for improving single line of code or eliminating single duplicate line of code. Environment where people visualize code rather than preferring business process diagrams and UML charts, one 'Attila' (best of all coders) of code is known as Software Architect who rather prefers to be called just 'Technical lead' or Senior Developer, this guy is hero for the newly recruited geeks. Environment where people value instant feedback and give them too. Everyone here talks about code and team develops code cultures among themselves.

The Other Environment where you are known by your degree and institute, you are known by your swaggering designation irrespective of your skills and special abilities per se (for e.g. Senior Technical Consultant - who would consult notepad bugs), or you are known if you've special flattering abilities which can trigger a laser of lime light on you. Where it doesn't matter how you code or what you code, but how you present it to management. Where there are special board of 'designers and architects' who analyze and model the solution in industry standard diagrams, the diagrams which can't compete an ounce of real life value. Team members try to hide the details and present problem 'abstractions' to the leads (not that it really matters to lead ). Environment where long feedback chain's ends meet nowhere. No one speaks about code, and if you mistake speaking about it, you'll be provided with 'the look' (not as terrible as the woman look ;)), meaning you're considered inferior just because you spoke about code. Everyone just keeps off the talks where code is inevitable, but would prefer to be called by a fancy technical designation.

There can be many other possible differences, and if you've worked in both environments, you will come up with a list of your own. I just wanted to highlight the variance in the importance given to the most important activity of trade in the same industry! I don't understand why coding is considered bad when this is the only thing which we do uniquely?

I'm a developer who loves coding, and I've no plans to leave it for management (highly non-tech) work. Ever since I left my first job, I've seen more people considering 'coding' to be low-level and inferior profile.

If you join big services company as Fresh grad, you'll quickly develop this feeling that 'coding' is laborer's work, and you should be doing something worthwhile. This is because the way people work (coders) in such companies is disgusting and any non-insane person will runaway from this profile. This doesn't make coding a bad job but it definitely suggests that you should leave that organization to continue developing software. I know many friends of mine who chose something else for developing software, because they think coding is bad, or may be because they could never code well.

And we also have groups of people in modeling corner, who've developed the feeling that coding is mundane and should be automated. We've tools today which can partially generate code. We'd have tools which can generate full code, but we've to code (or model the problem to extremities) the models. Coding as an activity remains part of software crafting with Modeling approach as well.

I consider 'coding' a skill, and take pride doing it. I don't know why people 'make' it inferior.

Tuesday, June 19, 2007

Bad Bad USB

I've got 80GB Hitachi USB Portable hard drive few weeks back and now I'm repenting on the money I shred on it. Well, it's not extremely bad, but sure it can't copy a file bigger than 2GB.

Try it and you'll get red head monster popup stating "Delayed write fail"! The general meaning of this message is that kernel failed to write the buffer to the device, would be familiar if you have worked with 56kbps modems with bad network interfaces. It's not a windows problem, It doesn't work on Linux too, which is not a surprise.

USB2.0 is pretty fast, and the hard drive with 12msec seek time is good. USB2.0 is still "new" and I, among others, feel that it is not well implemented. Google search reveals that it's mostly because of loose connection or something related to poor hardware mechanism, heh, I don't think that's the real problem. Because I could copy thousands of small files without pain, but a single large file proves fatal.

I suspect few things about this problem:
First, the disk manufacturer might have sacrificed a good cache which can cause controller to lose track of what's being written, hence the failure.

Secondly, It can be drive seek+write speed problem together with controller, USB pumping data at high speed which the disk can't handle at it's 5200rpm.

W/e...

There is at least one sub-optimal solution to this, switch to USB1.1 interface from BIOS and you can copy bigger files! Ten time slower, however. (which means it's not a connector problem).

Monday, May 28, 2007

On the road again

Last month had been a good vacation time for me after a really long time. Now that I'm back on track, I'm seeing lots of new things on the Internet. Things have changed here fast. Oh and what's this? Blogger has became less irritable, it has new feature to save drafts in background, Gmail has now bigger attachments ....

Well, I've switched to Google reader and it's really good for what it says. I had been traveling here and there without computer and found it useful. Since I don't own a mobile computer yet, my FireFox live bookmarks are useless. So I exported my live bookmarks to OPML(plug in here) and imported it into Google reader. Now I can have look at what's happening on Internet from a single application :).

Now I'll keep posting here!

Sunday, April 29, 2007

Closed development instance in Eclipse ecosystem

I've been reading Bjorn's posts on open source and open development. I can't disagree with his view on open source being more than just making code available. Getting project participation, in greater capacities than just mailing lists, from community is a good thing, and that should definitely be taken into consideration with proper feedback. The very purpose of being "open" is defeated when a project starts ignoring community contribution without sensible reasons.

I've reason to write this, although I'm not strictly against closely developed open source projects.

I've been working with a modeling toolkit for quite sometime and had customized it to suit my requirements. The contribution was in the core part of the tool (GEF based clipboard, motility and other ergonomic support for better modeling experience). I sent a mail to project admin asking if they would be interested in taking this contribution, after unknown number of days I got the reply asking for contribution review. I sent it as plug-in source code, not as patch, listing changes in the packages and configs. Most of the features offered in the contribution are actually in the project road-map as enhancement list.

But, after more than two months now, I'm still without reply(positive or negative), without comments, without acknowledgment. Now, I've almost lost interest in contributing it.

I hope those required features will be implemented (in anyway project team wishes) in next major release of the project, but I can only hope because the project is not really being developed openly. How sad...

Don't get me wrong. I've nothing against the tool, the tool is excellent and remarkably well designed and implemented; Nor with the team developing it, it's their job. But they should definitely mention somewhere that they are not open to external contributions in development.

Friday, April 13, 2007

Essential Features for Eclipse PDT

Eclipse PDT project initiative is a good news for PHP developers. However, there are few basic features, which are expected of any web development tooling, still missing. It is good to know that the project is focused on serious features on unit testing, debug infrastructure, editors etc. You can vote for the essential feature enhancement on project page.

I would like to share some PDT uses from a developer perspective. I use PDT for editing and source code management. These features are good enough, and will be more productive eventually.

However I felt lack of support for deployment features, all you get is external tools for local apache and basic page browsing. But Every time I modify a web page, I've to do rcp or use WinSCP to deploy that file back to the server and refresh page. Also, most of the times, It's essential to be connected with server on SSH connection to do regular fancy server stuff. WinSCP, although a great tool, isn't really "ergonomic excellence" and hence this tool switching becomes a painful activity.

It seems PDT is assuming that developers work only on development/staging machine and hence the lack of support for deployed web applications. Also based on my experience, I found PHP deployment to be very very different, fairly simple to be ridiculously near non-existence, compared to other "heavy-weight" web environment. Java, for example, has lots of "things" and steps to deploy a web app, but that's a different story...

I strongly recommend consideration for following features:
  1. Built in SSH command interface (remote terminal as console view ).
  2. Support for auto upload, or built in rcp (rsync builder - rsync as a part of auto-build would be a great feature!). Alternatively, this can be like MS Visual Studio style interface through HTTP interface, using HTTP methods (PUT etc.). Live Deployment feature is *essential*.
These basic features, not specific to only PHP IDE, can substantially increase productivity.
I'll post more uses of PDT as I go along using it.

Wednesday, April 11, 2007

SOA for Techies

Tired of marketing meaning of SOA? Does the word SOA really made you feel sick? Confused what is SOA after all?

Here is the simple explanation of SOA (Service Oriented Architecture) with technical touch by Uncle Bob.

SOA is the practice of sequestering the core business functions into independent services that don’t change frequently. These services are glorified functions that are called by one or more presentation programs. The presentation programs are volatile bits of software that present data to, and accept data from, various users.
SOA is very obscure, if not obliterate, term - one of many which are humming on the web. Thanks to guys like Martin, who tries to address the real side of it. Read more here. I recommend reading this post, and upcoming posts, before you start speaking about SOA in any conference or technical discussions. Well the same is true for every other Buzz word.

Tuesday, April 10, 2007

HOW TO: Setting up GForge in minutes

GForge is a collaborative development environment, which was forked from SourceForge, read more about it here. GForge is being used heavily world wide and is much better option for project management, versioning and collaboration. The best thing is, it's open source and freely available and is documented and improved regularly.

I spent past week configuring and hacking GForge. Apparently, It requires a good understanding of many Linux related stuff. Being sufficiently complex, it takes good system administration skills to get it running perfectly. I'm not proclaimed Linux expert, neither plan to be one; but I agree it was fun playing with this cool stuff in Linux among others.

Well If you are not curious on details, you may skip rest of the post.

There are multiple ways of setting it up, in increasing order of difficulty:

1. You can download Pre-configured GForge VMWare Image on Fedora core.
2. If you use debian based linux distributions, auto install all the dependencies and gforge using one simple command.
3. Download official tar-ball and configure it by hands on any Linux.

I tried all of them on Ubuntu and Fedora, and It worked well in most cases. Doing everything from scratch, i.e. installing it from "official" tarball, is bit difficult but not amazingly hard (more than linux, you need to understand how various things like DNS, Postgres, MailMan, WikiWikiWeb, CVS, SVN, LDAP etc. work).

If you want to deploy it on Debian or debian based distro, you've to update your sources.list to lookup/install and upgrade Gforge for debian, read more here. Be careful in doing 'apt-get install', it may render your OS useless, if GForge and dependencies are not configured smartly. Especially you'll face problems related to OpenLDAP and Postgres SQL, also these sources has older versions of Postgres which are bit difficult to upgrade without dependency issues. For example, if you fail to install postgres properly, you'll not be able to login which expects LDAP authentication. LDAP, in turn, depends on DB which is not well-configured, what will happen is everytime you try to login at tty it will give you "Can't connect to DB". If you run in such problems, You can login as single user from GRUB loader and delete ldapnss and other ldap related files from /etc to get it running normally, but this can be really dirty exercise.

The easiest most is to play with VMWare image. Recently, (ok, not so recently) some contributors at gforge.org made virtual appliance of GForge on Fedora Core 3, you may download it from here. It's pretty easy to setup and get going with it.

However, There are several problems when you run VMWare image in VMWare Player:
1. At first you've to setup the virtual host for 80 and 443 (HTTP, HTTPS) in apache configuration.

2. If you run this image on other network, you'll have problems of failed login with out any warning or error message you'll see glorious "Cookies must be enabled past this point" and nothing will happen. This is because your VMWare Image IP is different than what it is configured for apache, and browser will stop accepting cookie from the server. This whole IP thing is problematic with VMWare because VMware host does not automatically provide internal DNS service for the virtual machines, and IP allocation is based on the host network adapters bridged with virtual VMWare adapters, which may have different addressing schemes. In short, IP of gforge image keeps changing based on the computer you run it on.

In this case you can either reconfigure Virtual host settings in httpd.conf to match current IP or you can force static ip by adding following lines in your /etc/rc.local file.

/sbin/ifconfig eth0 [staticip] netmask [subnetmask]

This will ensure that you've static IP everytime you run image. Once run, you can access the gforge portal from host OS browser. That's it, there you go.

I'll write more about GForge interesting internal stuff sometime later.

Saturday, March 31, 2007

Linux, AMD, VIA and Me

I installed Ubuntu Linux on my AMD64 3000+, S3 DeltaChrome IGP (it's just a big name for chipset which is good value for money), Asus A8V-VM mobo and a Gig DDR RAM. I've been working with many distros for quite sometime now(Mandrake, Knoppix, SuSe, Redhat since 6.2).

I'd some repeating bad experiences with it...

After numerous attempts to install via_drv.so for X, specific to my VIA K8M890 chipset (which is cheap and, not so surprisingly, widely unsupported by Linux), finally I realized this hardware isn't currently supported at all. The generic VESA driver draws at 40Mbits/s, which is *not* good enough for 1280*1024*75Hz GD. The kernel is generic 32bit, SATA drive runs in PIO mode (11Mbits/s, not better than even USB2 babe, hopefully I will fix this problem). Well, If Linux has to support only NForce, Radeon or very regularly expensive hardware, what's the use of it for those who seek the price-performance ratio well beyond brands?

There's an open source project, openchrome.org, for S3 Chrome Linux drivers, which doesn't have support for K8M890. Ironically it supports K8M800, I think I've got 90 more transistors/diode/resistors in my hardware; but this support doesn't excite me to know the differences between the models. And this support seems to be specifically for dear old XFree64 (hard-wired path in make scripts), hmm, its hopeless.

I've no success stories to tell about Linux on AMD based boxes. With three of my AMD based boxes, all I got is handful of driver installation defeats, shaky drags / scrolls and overall miserable system performance. Sad, I've to use Windows for most of my work. Now, I don't even mind keeping driver.cab on my hard drive.

I downloaded and tried Fedora Core 7 Image and it seems it will support my hardware (xfree86), I hope newer versions of Ubuntu will provide drivers for Via chipsets out of the box (Ubuntu is after all "Linux for human" and not for people who understand: Why only kernel headers are required to compile, link, probe and install modules), this is partly the fault of hardware vendors who don't want to develop drivers for Linux (I also read somewhere they don't even open specification for others to develop).

Tuesday, March 27, 2007

How to: Reinstalling Grub in Ubuntu Edgy, Fixing Windows Boot Record

Since windows likes to play with MBR and can't live without it, it overrode the boot record of my hard disk - wiping Linux boot info :(.

If you ran in similar problem, Here's a quick way of fixing it,

Boot from Ubuntu Live CD
sudo grub
grub> root (hd0,0)
grub> setup (hd0)
grub> exit

In (hd0,0) hd0 suggests first hard disk and 0 is the partition number (starting from 0, 0 means first partition). Also you can find out where the grub is installed by keying the command "find /boot/grub/stage1" in grub prompt.

Then, Add following lines to /boot/grub/menu.lst or wherever grub is installed.
title Windows XP
root (hd0,)
makeactive
chainloader +1
Just in case, if you have lost the boot record altogether ("Can't boot: Invalid Disk"): Boot from Windows CD and start repair just before installation, it will start recovery console. There, type in "fixboot". It is one of the risky windows command, see details here fixboot. Running it will restore the partition boot record and your system should boot (also you may like to use "fdisk /mbr" to restore, default jump on first partition boot record, your master boot record).

Six reasons why TDD is necessary

In Earlier post about experiences with evangelizing TDD, There was a comment by my friend Devang, asking for "real examples" for "real need" of TDD.

I'll write here few benefits of TDD (mostly on why tests are necessary? ) as I understood:
  • You want to be confident about your code, with tests backing your code up, you always know your code will work without problems. You get confidence by successful test runs. Every time you see a green bar, you get satisfaction.
  • Even when you have inevitable bugs, by chance, its easy to isolate them. The test points the exact location, you can quickly reproduce it with other test and fix it. For example, If a test method "testBlah" fails, you can directly look in to the code of that tests and real code tested there. Tests brings fewer surprises without dealing with huge logs and coding horrors.
  • Writing good tests forces you to write good code and hence better low level design. For example, if I tell you to write a test for a thousand line C# method, it will be near to impossible to achieve it, so you'll break this method in smaller methods and try to test them each. With each test written, your code becomes good looking and reliable.
  • Tests are the best ways to learn about the library, framework etc, tests are documentation. For example, If you want to learn how Hibernate.NET works or how to use APIs and don't want to RTFM, then you can have a quick sneak in Hibernate tests and you'll know how to use it.
  • Talking of original TDD sense: If you've always written code first then you never worried about testability of your code. Whereas if you test first develop it, your code becomes testable. And there are many reasons why you want to make your code testable...
  • With automated tests, You don't need to repeat yourself with debugging sessions, it's once and for all. Even if you have to debug, it will be at much smaller scale. For example, a bug is repeatedly coming up and you debug each time to fix it, each fix takes days because it involves debugging entire component, even if that component is as simple as build SQL and fetch-map objects with rows, it can turn out to be a debugging nightmare, if you'd written tests for it - they would have saved you hours of pain to step through the buggy code.
I hope this list will be helpful for those who are still wondering why TDD has become such a phenomenon or are still skeptic about it.

Believe me, Tests save your life and makes it very easy :). If you like this post and found useful, please share it with others, your comments are welcome.

Tuesday, March 13, 2007

TDD Evangelizing Experiences

I was discussing about usefulness of developer testing and TDD stuff with one of my friend, Kapil. I told him "you should avoid debugging at all costs" - debugging is painfully mundane and costly activity, "one of the way of avoiding it is; to write automated unit tests", he said, "I avoid it by debugging differently..".

I asked how and what different debugging techniques, and he gave an example of manual technique to avoid seeing what's going in code ("If a file is not found, I'll try renaming or something like that"). I said, "this is no debugging, its kind of troubleshooting to avoid debugging". He would not agree to it.., then I told him why not write an intelligent program which will do the same thing programmatically ?(well, its kinda behavioral testing), then? well then he was interested in listening... and was ready for few pills of TDD :).

With few examples, It was easy to explain him how TDD can change the way you think about developing software, he already knows it a bit, tries to minimize it through other manual hacks (this is partially because PHP has smattering good debuggers and he works on PHP based server apps).

I told him "debugging happens to be one of those trivial activities which doesn't differentiate you from others" (no big deal, everyone can do it, right?); You need to consider audience attitude for a successful systematic evangelizing :).

TDD, in its real sense-the test first, is one thing that I still find difficult to explain to people; It requires you to give it a shot without unveiling providential "Zen" behind it, somethings you should just try without resisting and put in practice if you find it effective.

Once, I explained TDD to my trainee team at C-SAM, I explained it by example, told them what happens when you don't have tests, made them feel the pain of debugging; then write tests and show what great peace of mind this automatic testing gives.

To sum the experiences on evangelizing TDD:
  • To a good programmer explain the benefits of writing intellectual tests rather than idiot debugging every time.
  • To a novice, give a real example; mock a bad situation and exhibit how to tackle it with TDD.
  • To an amateur, explain how tests are better than manual troubleshooting.
Kill Debugging, Write tests.

I hope this experiences will find some use and benefits in development.

Monday, March 12, 2007

Taking care of abused Exceptions using JDT AST

How many times you went nuts while dare debugging a large application? and while debugging, faced desperate failure in getting any clue on what went wrong, no exception, no log?

Well, If you work on right smartly large bad code base, this experience is quite common. One of the main reasons, as I think, for this situation is swallowed and mishandled exceptions.

I ran in similar problems once, where it was becoming very hard to find the problems. I came to know mishandled exceptions in many places. And I decided to write a plug-in to manipulate AST and replace it with logging statements.

Here is the code for interesting parts of the plug-in. Created a catch clause visitor, which will visit all the catch clauses in AST. The AST will be parsed for each Compilation Unit in a loop.

private final class CatchClauseVisitor extends ASTVisitor {
@Override
public boolean visit(CatchClause node) {
allCatchClauses.add(node);
return super.visit(node);
}
}

This visitor can be used to collect clauses from AST:

ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(lwUnit); // set source
parser.setResolveBindings(true); // we need bindings later on
CompilationUnit unit =(CompilationUnit) parser.createAST(null /* IProgressMonitor */);
unit.accept(
new CatchClauseVisitor());

Now that we have all catch clauses, we can iterate on them to execute transformations and rewrite the AST.

try {
for (CatchClause node : allCatchClauses) {
if (list.size() == 0) // SWALLOWED EXCEPTION
putLoggingStatement(node, null, rewrite, null);
else // code to replace SOP statements with logger call
for (Object object : list)
// ....
// computation of the new source code
TextEdit edits = rewrite.rewriteAST(doc,
lwUnit.getJavaProject().getOptions(
true));
edits.apply(doc);
String newSource = doc.get();
// update of the compilation unit
lwUnit.getBuffer().setContents(newSource);
lwUnit.save(null, false);

} catch (...){...}

And here is the putLoggingStatement method..

private void putLoggingStatement(CatchClause node, Object object,
ASTRewrite rewrite, ASTNode expStatement) {
MethodInvocation invocation = node.getAST().newMethodInvocation();
setLoggingMethodName(node, invocation);
SimpleName args = node.getAST().newSimpleName(
node.getException().getName().getIdentifier());
invocation.arguments().add(args);
if (expStatement == null) {
ExpressionStatement statement = node.getAST()
.newExpressionStatement(invocation);
ListRewrite listRewrite = rewrite.getListRewrite(node.getBody(),
Block.STATEMENTS_PROPERTY);
listRewrite.insertFirst(statement, null);
rewrite.replace(node, node, null); // replace the nodes
return;
}
ExpressionStatement statement = node.getAST().newExpressionStatement(
invocation);
setContextInstaceVariable(invocation);
rewrite.replace(expStatement, statement, null);
}
// ....

A number of details are removed for the sake of brevity and I don't claim the code to be professionally written. There are some improvements I can thing of, like, the SOP can be replaced with logging statement, a provision for rethrowing exception statement based on some config (no, no configs!)....

Finally let me tell you that writing the code involving AST can become complex and error prone, but it does a real good job. This small job of carefully writing a custom code manipulation saved me from doing it manually for hundreds of java source files as well as code maintainability got much better, what a relief!

Saturday, March 03, 2007

The State of software

There's a thought provoking discussion on pragprog on the current state of software. The discussion was really insightful, and I can't disagree with the group that, quality of softwares has gone bad.

These days, People comfortably accept existence of bugs in most software, which is a fact not acceptable at all but it seems the expectation from software is being relaxed and hence limited existence of better software, is this the failure on our part?

Even after almost fifty years, people are still writing code in historical languages, and are happy with it, this is very questionable compared to other disciplines. If we compare software crafting with other domains, it's quite frustratingly slower in improving, this rant is quite valid. Although few of us have started picking up the lessons from domain, lean software development being one of them.

On optimistic fronts, there are few good news also (note that 73.5% of all stats. are made up ;) ). According to these news there are few outright software project failures and look at the bloody success ratios! they are marginally good in comparison!

Of course, there are few world class development in open source, which have outperformed most traditional stuff (e.g. managed environments), but they are not in sufficiently large number.

IMO, all this deserves evolutionary development, and yes Agile helps, not a silver bullet but helps; quite a lot in controlling four essential aspects of four variables.

And this pragprog topic is worth a read...

Friday, March 02, 2007

I'm unemployed

Today is last working day at my organization, After a year I thought to move on...

At my organization, I learned a lot of technologies; most of them related to rich applications based on Eclipse Platform. Other than tech., I got chance to work with complex graph based algorithms, template based generators, UML & BPMN specs, compiler stuff, few model transformations related stuff, licensing, release engineering, heavy weight refactoring (ashamed to say, without tests), great tooling and many more things...

It was really fun doing all that, but finally I've to move on to apply my understanding to the business. Like all geeks out there, I used to fascinate with the tech. curiosity and internal stuff, but now I'm realizing that the value of this knowledge to business domains is much more than mere curiosity. I hope I'll be able to create some value out of my tech. understanding.

I'm now an unemployed Indian programmer.