Saturday 29 March 2008

Configuring a new Java project

Since I started working as a software engineer something has always been bothering me and I couldn't quite put my finger on it. A number of things that I thought might have been the problem became clear to me (like not setting up logging clearly and failing to communicate how it should be managed and maintained with your team members) but not until now has it been this clear and obvious.

From my experience it always seems as though the project setup and build process is an afterthought and quickly becomes a time-consuming and difficult to maintain hack. You know what I mean, horrible ant build files that have a million directory specific build exclusions and inclusions; mixed up unit test configuration files; unclear logging processes; missing jar files - it all has a crippling effect on the willingness of developers to fix the problems (they're too scared to touch the build files in case they break something). Surely I am not the only developer who's felt this pain?

One thing became glaringly obvious tonight, in fact it seems so obvious to me that I am posting this to ask you guys why on earth it isn't a standard practice. Am I missing something? Is there some sort of obvious problem with this approach that I have missed?

I believe this is the root cause:

Unit tests stored in the same project as the main application code. Why aren't unit tests stored in their very own, very separate, project in an IDE? Why is it that every project I have worked on has a source directory (inside the main application code project) specifically for testing? When the test code is in its own project it's amazingly simple to manage the build process for your actual application and amazingly simple to maintain your test code without getting lost and confused. The clarity it provides is mind-blowing, at least to me.

So what I want from you guys is an explanation as to why this isn't standard practice (as far as I'm aware)? Is there some sort of fundamental problem I haven't yet found with this approach? Or have I just been working with crappy developers? ;)

Over to you guys..