Gienah: inject Spring dependencies in your JUnit 4 tests

I wanted a way of using my test with dependencies coming from my Spring definition.
Continue reading

Posted in java, spring, test | 6 Comments

YAGNI — You’re Aren’t Gonna Need It

A couple of weeks ago, I started working on the objects that needed to be mapped onto the database. As I didn’t know what to do with each of them, I tried to keep things simple by mapping a foreign key into a Long.
A couple of days ago, I realized that this foreign key actually pointed to an object that was now available. Predictable enough, but was I right to map it to a simple Long before?

  • a Long was indeed the simplest thing I could do to design the link, as I didn’t need any other class to be designed to get my first class running
  • however, refactoring it into a real object is not easy; in fact, it is quite risky, as many places in the code will be changed (tests, Hibernate requests, equals() and hashcode() implementations). In fact, I tried and wasted a full day on it.
  • I think I’ll eventually have to remove it entirely before re-introducing the link between the two objects
  • Designing the first class as simply as I could was the right move. However, that’s not what I did; actually, I had added this foreign key because it was there, not because I needed it. If I had refrained from adding it as all, I wouldn’t have wasted time in trying to refactor it.

    All that because I didn’t apply YAGNI properly. A lesson to remember!

    Posted in agile, java | 2 Comments

    Hiring Tips

    Every once in a while, I stumble upon a new list of tips to hiring someone. Since I am actively involved in interviewing candidates technically, I always read them in detail.

    If you don’t know them already, here they are for your reading pleasure.

  • Joel Spolsky’s Guerrilla Guide to Interviewing, possibly the most referred to paper on hiring
  • Steve Yegge’s Five Essential Phone-Screen Questions, a bit too system-centered for my taste, but interesting
  • Mike Cannon-Brookes’ 5 Tips For Startup Hiring, Mike is the co-founder of Atlassian; I’ve met him briefly at CITCON London 2006
  • Posted in misc, valtech | Comments Off on Hiring Tips

    CITCON Dallas/Fort Worth April 27-28

    Paul Julius and Jeffrey Fredricks have announced CITCON D/FW 2007. It is the third in a series where CITCON London 2006 was number 2.

    Considering how enjoyable CITCON London was, it is totally worth going to CITCON D/FW if you’re around.

    Posted in citcon, continuous integration, openspace, test | Comments Off on CITCON Dallas/Fort Worth April 27-28

    Got a new laptop bag

    The original briefcase-style bag that came with my laptop one year ago was finally so torn that I decided to buy me a new bag. My criteria were the following:

  • it must be a backpack. I’m sick with having something on my side
  • it must be professional-looking. An amazing quantity of backpacks are ok for laptops but also sport flashy colors and such. I was to be able to walk in a pre-sales meeting with my bag.
  • it must be a small as possible. No more annoying people and myself in the Metro.
  • Continue reading

    Posted in misc | 6 Comments

    p6spy, dbUnit and maven

    p6spy is a JDBC proxy that will log the SQL statements passed to a database. It is a relatively old project (last release is from 2003 but I only heard about it today, as I was looking for a way to trace SQL queries sent by dbUnit to my Oracle database.
    The bad news, of course, is that usage of p6spy along with dbUnit and Maven is not documented. Since it took me a while to figure it out, I thought I’d share it here.
    Continue reading

    Posted in java, maven, test | 2 Comments

    Test Driven Design and Data Access Layer

    I am currently writing the Data Access Layer of a Java project using Hibernate and I want to apply TDD on my work. The part that is concerned with the database is the mapping of objects on the database schema, and the queries.
    As a recap, there are the options:
    Continue reading

    Posted in hibernate, java, tdd, test | 3 Comments

    Changing maven local repository

    This is something that is not well documented on the web, though it is quite clearly in the default settings.xml file provided with the default Maven installation.

    The default repository used by Maven 2 to store the various artifacts is <user_home>/.m2/repository. Under Windows, that translates to C:\Documents and Settings\<user>\.m2\repository.
    On my client site, the size of the user home directory is severely restricted, presumably because it is being backed up. So, how do you change this value? Easy, once you know.

    You need to have a settings.xml file, either in the <user_home>/.m2 directory, or in the <maven installation>/conf directory (make sure you keep a copy of the existing one). Add a new <localRepository> tag. On my machine, it looks like that:

    <settings>
      <!-- any type of slashes works -->
      <localRepository>D:/mavenrepository</localRepository>
    </settings>

    That’s it!

    Update 06/12/2011: fixed typo in name of tag

    Posted in java, maven | 23 Comments

    Hibernate: so, the identifier field *is* mandatory after all!

    Is it obvious to everyone that an identifier is mandatory in Hibernate? I actually thought that Hibernate generated some kind of internal identifier for classes that do not specify one.

    The documentation says:

    saveOrUpdate() does the following: […] if the object has no identifier property, save() it

    That strongly implies that you can have no identifier, right?

    In the test that I have written recently, I wanted to keep things as simple as possible. Just a String column in a table.
    Continue reading

    Posted in hibernate, java | Comments Off on Hibernate: so, the identifier field *is* mandatory after all!

    Configuring Cobertura in Maven 2

    After many spurious error messages, I finally managed to make it work. Be warned that the information on the official Cobertura Maven plugin page, the informations are not exactly correct. Below, you’ll find in bold the fixes.

    The “Basic Cobertura Configuration” seems fine, however, to configure the instrumentation, you need to add the following to your config file:

    <project>
      ...
      <build>
        ...
        <plugins>
          ...
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.1</version> <!-- apparently, this is not necessary in the reporting part -->
            <configuration>
              <instrumentation>
                <!-- <ignore>com.example.boringcode.*</ignore> --> <!-- not sure how to make this work, or even if it is necessary at all -->
    	    <excludes> <!-- the usual ant exclude pattern was missing -->
                  <exclude>com/example/dullcode/**/*.class</exclude>
                  <exclude>com/example/**/*Test.class</exclude>
                </excludes>
              </instrumentation>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>clean</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </project>
    Posted in java, maven, test | 6 Comments

    Successful internal OpenSpace meeting yesterday

    Yesterday, I hosted an OpenSpace conference in the Valtech office in Paris. The theme was ‘pet projects that we want to work on (though we already work fulltime)’. I was a bit apprehensive, as my previous experience had been in London; I was not sure how a French audience would react.

    I think I can say that, by and large, it has been a success. Because it was taking place in the evening after the usual daytime assignments, we could only provide for 2 one-hour long sessions in 4 rooms(plus one hour of preparation beforehand). So, as expected, a few topics did not gather enough momentum and were dropped in favour of somemore popular ones.

    I attended two that gathered half-a-dozen people. Not much compared to the 30 or so participants, but more than enough to have a productive session.

    As it appears, I am going to take the lead in organizing a public OpenSpace Conference on Agile practices (though we do not want to compete with XP Day Paris). Many things still need to be sorted out, but my goal is to have it happen before the end of year 2007 (my boss would prefer before summer, but somehow I am not confident we can do it so quickly).

    Another one I’ll contribute to is lead by David. The plan is to organize bi-weekly evening technical sessions opened to the public and to Valtech consultants.

    Sadek told me he had taken more than 200 pictures yesterday (?!). I hope he’ll put some of them on his blog.

    I also have my own pictures of the event.

    Posted in openspace, valtech | 2 Comments

    Eclipse-Subversion Integration: Secrets Wars

    Did you know there were 2 Eclipse plugins for Subversion? Neither did I, until this morning.

    The leader is still Subclipse. Runner-up is Subversive. Being a credible alternative when it was released, mildly insulting words were exchanged; the Subversive team even suggested that cooperation was in order (which was mostly rejected by the Subclipse team). This culminated with 2 competing proposals (one for Subclipse, one for Subversive) being made to the Eclipse foundation.

    That was about 6 months ago. Today, I am not clear who the winner is. The proposal for Subversive states that it has been approved (though I thought that the Eclipse team usually did not give formal approbation). But development goes on furiously for both teams (both released Eclipse 3.2-compatible versions in early February 2007).

    As for me, being behind a very annoying firewall, I cannot use the update feature from Eclipse to get Subclipse. So I am giving Subversive a shot.

    Somehow, this all sounds like a storm in a tea cup, doesn’t it?

    Posted in eclipse, java, subversion | 5 Comments

    Format On Save Plugin For Eclipse

    I’m writing this post as a future reminder for myself… This plugin is damn hard to find when you are looking for it.

    All it does is automatically format and organize import statements in your Java classes each time you save (Ctrl-S). Basically, it replaces Ctrl-Shift-F (format), Ctrl-Shift-O (imports) and Ctrl-S (normal save).

    I had used it for a month, and now that I have changed project, I find myself lost without it. I just found it again today.

    Links: Eclipse Plugins website, SourceForge.

    Together, let’s all thank Sebastien Vauclair for it.

    Thanks to my colleague William Ferreira for the tip.

    Update (18/04/07): this is now native in Eclipse 3.3. See Jean Laurent’s post for details.

    Posted in eclipse, java | 2 Comments

    Visit by Jean Tabaka

    This week, Jean Tabaka from Rally Dev came to teach Scrum to my colleagues from Valtech. In the evening, she gave a talk on her book, Collaboration Explained.

    I have been very impressed by Jean’s easy-going personality. As most people had left the office, I was still hanging around with the boys for a few more minutes when Jean came over and ask if there was anything left to drink. Well, our resourceful Gian managed to find 2 bottles of red wine and the party went on till 10pm.

    This is very much in contrast to the only other ScrumTrainer I know, Craig Larman, who I think can be fairly described as “frugal”.

    Posted in agile, scrum, valtech | 2 Comments

    New project for me

    This week, I have started a assignment with a new client. Remember the one that I mentioned would probably not take me? Well, I was wrong after all ;-)

    Slow start so far. I have not received my work machine yet, so I have to make do with my Valtech laptop and unofficial access to the web proxy.

    Posted in valtech | Comments Off on New project for me