Corso Test Driven Development a Milano

Mercoledi 16 Maggio terrò un corso sull’utilizzo di Unit Test e sull’adozione di Test Driven Development presso la Fondazione dell’Ordine degli Ingegneri della Provincia di Milano.

La giornata sarà focalizzata su tre argomenti principali:

  • l’analisi di costi e benefici dell’adozione del Test Driven Development basata sullo studio di casi ed esperimenti descritti in letteratura;
  • l’illustrazione delle idee alla base del Test Driven Development e una serie di tutorial che mostrano l’utilizzo di alcuni strumenti standard nello sviluppo di una applicazione;
  • come il Test Driven Development si integri in un contesto aziendale esistente e quali possano essere le criticità nella sua adozione.

La locandina contiene il programma dettagliato e le informazioni sul costo del corso.

What I liked of Codemotion 2012

I’m just back from the Codemotion 2012 held in Rome.

Here’s the list of the most interesting technologies and startup companies I discovered there.

On the tech side I found these topics quite interesting:

  • OrientDB, an very interesting graph database http://www.orientechnologies.com/.
  • Three.js (http://mrdoob.github.com/three.js/) a very powerful javascript library to ease the use of WebGL.
  • Near Field Communication, a new technology that allows devices and electronic tags to exchange data within a range of centimeters. I was not even aware of it. The standards, though, seem not to be totally interoperable.
  • HTML5′s storage solutions: Web Storage, Web SQL Database, Indexed DB and File API. Even though they are not so widespread supported by the main browsers at a level that I feel they should, to make me give them a try in a real world application.
  • Backbone JS (http://documentcloud.github.com/backbone/) brings MVC on the client side. Is it SEO friendly too ? Have to check… It does not seem to be SEO friendly at all, unless you don’t follow this rules.

Here, instead, a bunch of interesting newco:

  • http://map2app.com/ allows you to generate map based applications that can be distributed on various mobile stores.
  • http://hypertvx.com they came out with a nice idea to synchronise a TV program with a stream of media on your mobile devices.

It could be worth to mention LVenture (http://www.lventure.it) a venture capital that funded some of the start up companies present at Codemotion.

Many thanks to Francesco for the beers we shared in the always awesome Rome nights.

Diff in Java

A workmate of mine is currently deep involved in a big deploy. He has to take a huge amount of sql scripts out of our SCM, check them manually to discover if the other programmers have followed the internal coding standard and fix them if this is not the case.

While it is still a mistery to me why nobody though to it, I started the development of a small tool that could possibly automatically check and fix all the errors.

Part of this tool is a diff style window that show the user what the tool is fixing. It seems that diff in Java is a quite required feature, so, here’s my solution.

Obviously I didn’t reinvented the weel and my implementation is 100% based on the one published on wikibooks. My implementation consist of a couple of class.
The first one is able to give access to strings line by line.

  1. public class LineFile {
  2.  
  3.  private List lines;
  4.  
  5.  public LineFile(InputStream in) {
  6.   try {
  7.    lines = IOUtils.readLines(in);
  8.   } catch (Exception e) {
  9.    throw new RuntimeException(e);
  10.   }
  11.  }
  12.  
  13.  public LineFile(File f) {
  14.   try{
  15.    lines = IOUtils.readLines(new FileInputStream(f));
  16.   }catch(Exception e){
  17.    throw new RuntimeException(e);
  18.   }
  19.  }
  20.  
  21.  public LineFile(String from) {
  22.   try {
  23.    lines = IOUtils.readLines(new ByteArrayInputStream(from.getBytes()));
  24.   } catch (IOException e) {
  25.    throw new RuntimeException(e);
  26.   }
  27.  }
  28.  
  29. public String lineAt(int index){
  30.  if(index>=0 && index<lines.size()){
  31.  return lines.get(index);
  32.  }
  33.  return null;
  34.  }
  35.  
  36.  public int lines() {
  37.  return lines!=null ? lines.size() : 0;
  38.  }
  39. }

The second one is the actual implementation of the diff algorithm, and is based on considering each line as the most little element the algorithm can consider.

  1. public class LineFile {
  2.  
  3.  private List<String> lines;
  4.  
  5.  public LineFile(InputStream in) {
  6.   try {
  7.    lines = IOUtils.readLines(in);
  8.   } catch (Exception e) {
  9.    throw new RuntimeException(e);
  10.   }  
  11.  }
  12.  
  13.  public LineFile(File f) {
  14.   try{
  15.    lines = IOUtils.readLines(new FileInputStream(f));  
  16.   }catch(Exception e){
  17.    throw new RuntimeException(e);
  18.   }
  19.  }
  20.  
  21.  public LineFile(String from) {
  22.   try {
  23.    lines = IOUtils.readLines(new ByteArrayInputStream(from.getBytes()));
  24.   } catch (IOException e) {
  25.    throw new RuntimeException(e);
  26.   }
  27.  }
  28.  
  29.  public String lineAt(int index){
  30.   if(index>=0 && index<lines.size()){
  31.    return lines.get(index);
  32.   }
  33.   return null;
  34.  }
  35.  
  36.  public int lines() {
  37.   return lines!=null ? lines.size() : 0;
  38.  }
  39. }

Finally, to give you an idea of how it performs, here’s a couple of screenshots from the application.

If you need more details regarding the code, don’t hesitate and drop me a message!