SlideShare a Scribd company logo
1 of 42
Ricette per Eliminare gli IF

        Francesco Cirillo




           Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                               Javaday Roma III Edizione – 24 gennaio 2009
La Campagna Anti-IF




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
I sostenitori




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Anche tu puoi aderire




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Il nuovo sito




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Ricette per eliminare gli IF




  Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                      Javaday Roma III Edizione – 24 gennaio 2009
Ricetta anti-if#1: Il navigatore




      Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                          Javaday Roma III Edizione – 24 gennaio 2009
Ricetta anti-if#1: Il navigatore

if(command.equals("start")) {
...
...
} else if(command.equals("stop") {
 ...
...
} if(command.equals("start")) {
          parseAndExecuteStartRequest();
     } else if(command.equals("stop") {
          parseAndExecuteStopRequest();
     }
              if(command.equals("start")) {
                   new StartRequest().parseAndExecute();
              } else if(command.equals("stop") {
                   new StopRequest().parseAndExecute();
              }                         Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                                                             Javaday Roma III Edizione – 24 gennaio 2009
Ricetta anti-if#1: Il navigatore

if(command.equals("start")) {
     new StartRequest().parseAndExecute();
} else if(command.equals("stop") {
     new StopRequest().parseAndExecute();
}
      if(command.equals("start")) {
           _command1.parseAndExecute();
      } else if(command.equals("stop") {
           _command2.parseAndExecute();
      }
           public Navigator(Command start, Command stop) {
                _command1 = start;
                _command2 = stop;
           }                          navigator.commandFor("start").parseAndExecute();

                                    Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                                                        Javaday Roma III Edizione – 24 gennaio 2009
Ricetta anti-if#1: Il navigatore

if(command.equals("start")) {
...
...
} else if(command.equals("stop") {
 ...
...
}    navigator.commandFor("start").parseAndExecute();

       public Command commandFor(String aCommandName) {
          return _commands.get(aCommandName);
       }
                         navigator.put("start",new StartRequest());
                         navigator.put("stop",new StopRequest());


                                   Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                                                       Javaday Roma III Edizione – 24 gennaio 2009
Ricetta anti-if#1: Il navigatore

if(command.equals("start")) {
...
...
} else if(command.equals("stop") {
 ...
...
}    navigator.commandFor("start").parseAndExecute();
     public Command commandFor(String aCommandName) {
      if(!_commands.contains(aCommandName) return _defaultCommand;
         return _commands.get(aCommandName);
     } public Navigator(Command defaultCommand) {
              _defaultCommand = defaultCommand;
              …
          }
                                   Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                                                       Javaday Roma III Edizione – 24 gennaio 2009
Sintomi Sindrome IF




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Attacco alla diligenza




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Attacco alla diligenza
private void mouseClicked(MouseEvent evt) {
    long start = System.currentTimeMillis();
    System.out.println("Inizio " + _operation + ": " +
         Calendar.getInstance().getTime().toString());
    String[] parameters = new String[]{_command,
         getField_remote_export().getText(),
         getJTextFieldCommentoRelease().getText().replaceAll(" ","_"), _location};
    _project = getField_directory().getText());
    try {
             if(_inProd) _project = “project”;
             Process process = Runtime.getRuntime().exec(
                  parameters, null, new File(_project));
             process.waitFor();
    } catch (Exception e) {
         e.printStackTrace();
    }
    System.out.println(this._command + " eseguito in: " +
         (System.currentTimeMillis() - start) + " ms");
                                     Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
}                                                          Javaday Roma III Edizione – 24 gennaio 2009
Attacco alla diligenza
private void mouseClicked(MouseEvent evt) {
    long start = System.currentTimeMillis();
    System.out.println("Inizio " + _operation + ": " +
         Calendar.getInstance().getTime().toString());
    String[] parameters = new String[]{_command,
         getField_remote_export().getText(),
         getJTextFieldCommentoRelease().getText().replaceAll(" ","_"), _location};
    _project = getField_directory().getText());
    try {
             if(_inProd) _project = “project”;
             Process process = Runtime.getRuntime().exec(
                  parameters, null, new File(_project));
             process.waitFor();
    } catch (Exception e) {
         e.printStackTrace();
    }
    System.out.println(this._command + " eseguito in: " +
         (System.currentTimeMillis() - start) + " ms");
                                     Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
}                                                          Javaday Roma III Edizione – 24 gennaio 2009
One Class One Method




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
One Class One Method




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
private String getMcCabeValue() {          One Class One Method
    String max = null;
    NodeList metriche = _doc.getElementsByTagName("Metric");
    int numeroMetriche = metriche.getLength();
    for(int i=0;i<numeroMetriche;i++){
         Node metrica = metriche.item(i);
         if (metrica.getNodeType()==Node.ELEMENT_NODE){
              Element Emetrica = (Element)metrica;
              String id =Emetrica.getAttribute("id");
              //mi stampo tutti i tipi di metriche
              System.out.println(id);
              if(id.equals("VG")){
                   NodeList values = metrica.getChildNodes();
                   for(int j=0;j<values.getLength();j++){
                   Node value = values.item(j);
                   if(value.getNodeType()==Node.ELEMENT_NODE){
                        Element Evalue = (Element)value;
                        max = Evalue.getAttribute("max");
                        // mi stampa il massimo di McCabe
                                       Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                        System.out.println(max); } } } } } Javaday Roma III Edizione – 24 gennaio 2009
                                                             return max; }
private String getMcCabeValue() {          One Class One Method
    String max = null;
    NodeList metriche = _doc.getElementsByTagName("Metric");
    int numeroMetriche = metriche.getLength();
    for(int i=0;i<numeroMetriche;i++){
         Node metrica = metriche.item(i);
         if (metrica.getNodeType()==Node.ELEMENT_NODE){
              Element Emetrica = (Element)metrica;
              String id =Emetrica.getAttribute("id");
              //mi stampo tutti i tipi di metriche
              System.out.println(id);
              if(id.equals("VG")){
                   NodeList values = metrica.getChildNodes();
                   for(int j=0;j<values.getLength();j++){
                   Node value = values.item(j);
                   if(value.getNodeType()==Node.ELEMENT_NODE){
                        Element Evalue = (Element)value;
                        max = Evalue.getAttribute("max");
                        // mi stampa il massimo di McCabe
                                       Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                        System.out.println(max); } } } } } Javaday Roma III Edizione – 24 gennaio 2009
                                                             return max; }
Arpione Programming




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
double calculateValue() {
    if(_type == BTP) {
          Connection result = null;    Arpione Programming
          try {
                 Context initialContext = new InitialContext();
                 if ( initialContext == null){
                 log("JNDI problem. Cannot get InitialContext.");
                 }
                 DataSource datasource =
                        (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);
                 if (datasource != null) {
                        result = datasource.getConnection();
                 } else { log("Failed to lookup datasource."); }
          } catch ( NamingException ex ) {
                 log("Cannot get connection: " + ex);
          } catch(SQLException ex){
                 log("Cannot get connection: " + ex);
          }
          ...
          for (int i = 0; i ...) { ... } ... return result; }
    else if(_type == BOT) {
          for (int i = 0; i ...) { ... } ...
          return result;
    }
    for (int i = 0; i ...) { ... } ...
                                         Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
    return result;                                             Javaday Roma III Edizione – 24 gennaio 2009
}
double calculateValue() {
    if(_type == BTP) {
          Connection result = null;    Arpione Programming
          try {
                 Context initialContext = new InitialContext();
                 if ( initialContext == null){
                 log("JNDI problem. Cannot get InitialContext.");
                 }
                 DataSource datasource =
                        (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);
                 if (datasource != null) {
                        result = datasource.getConnection();
                 } else { log("Failed to lookup datasource."); }
          } catch ( NamingException ex ) {
                 log("Cannot get connection: " + ex);
          } catch(SQLException ex){
                 log("Cannot get connection: " + ex);
          }
          ...
          for (int i = 0; i ...) { ... } ... return result; }
    else if(_type == BOT) {
          for (int i = 0; i ...) { ... } ...
          return result;
    }
    for (int i = 0; i ...) { ... } ...
                                         Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
    return result;                                             Javaday Roma III Edizione – 24 gennaio 2009
}
Log-Driven Programming
DEBUG: [2009-01-09 16:40:04,657] debug - Effettuo la copia fisica del file tramite stream
DEBUG: [2009-01-09 16:40:04,657] debug - Creo la directory in cui copiare il file
DEBUG: [2009-01-09 16:40:27,801] debug - Elimino il file temporaneo /tmp/temp_11-12-2008_12-29-14.xml
DEBUG: [2009-01-09 16:40:27,802] debug - Aggiorno nella history il file uploadato. Il nuovo stato e' 10
DEBUG: [2009-01-09 16:40:27,812] debug - Effettuo l'update
DEBUG: [2009-01-09 16:40:27,940] debug - Aggiornamento history completato
ERROR: [2009-01-09 16:40:27,941] error - CaricaFileAction: [KO]
DEBUG: [2009-01-09 16:40:27,942] debug - nome actionForward: upload
DEBUG: [2009-01-09 16:40:27,984] debug - pulizia sessione terminata con successo
DEBUG: [2009-01-09 16:40:27,986] debug - --- LISTA_FILE_RICERCATI
DEBUG: [2009-01-09 16:40:27,986] debug - --- session_user
DEBUG: [2009-01-09 16:40:27,987] debug - --- org.apache.struts.action.LOCALE
DEBUG: [2009-01-09 16:40:27,988] debug - --- MACROSERVIZIO
DEBUG: [2009-01-09 16:40:27,989] debug - --- org.apache.struts.action.ACTION_MESSAGE
DEBUG: [2009-01-09 16:40:27,990] debug - --- FILE_DA_UPLOADARE
DEBUG: [2009-01-09 16:40:27,991] debug - entry point: VisualizzaCaricamentoFileAction
DEBUG: [2009-01-09 16:40:27,992] debug - id servizio: 4
DEBUG: [2009-01-09 16:40:28,037] debug - utente abilitato al servizio richiesto
DEBUG: [2009-01-09 16:40:28,066] debug - id servizio: 4
DEBUG: [2009-01-09 16:40:28,067] debug - Caricamento dati relativi al servizio: 4
DEBUG: [2009-01-09 16:40:28,191] debug - ms richiesto: true
DEBUG: [2009-01-09 16:40:28,191] debug - ms presente: true
DEBUG: [2009-01-09 16:40:28,204] debug - pulizia sessione terminata con successo
DEBUG: [2009-01-09 16:40:28,205] debug - --- session_user
DEBUG: [2009-01-09 16:40:28,206] debug - --- org.apache.struts.action.LOCALE
DEBUG: [2009-01-09 16:40:28,207] debug - --- MACROSERVIZIO
DEBUG: [2009-01-09 16:40:28,207] debug - --- org.apache.struts.action.ACTION_MESSAGE
DEBUG: [2009-01-09 16:40:28,208] debug - Carico la dimensione massima del file in upload
DEBUG: [2009-01-09 16:40:28,209] debug - Imposto ad 1 il numero di file da uploadare
DEBUG: [2009-01-09 16:40:28,210] debug - Carico i dettagli degli ultimi 10 file uploadati
DEBUG: [2009-01-09 16:40:28,219] debug - Effettuo la query
DEBUG: [2009-01-09 16:40:29,149] debug - Caricamento file completato
DEBUG: [2009-01-09 16:40:29,150] debug - VisualizzaCaricamentoFileAction: [OK]
DEBUG: [2009-01-09 16:40:29,151] debug - nome actionForward: upload
DEBUG: [2009-01-09 16:40:34,210] debug - entry point: AbilitaProcessazioneFileAction
DEBUG: [2009-01-09 16:40:34,214] debug - id servizio: 4
DEBUG: [2009-01-09 16:40:34,452] debug - utente abilitato al servizio richiesto
DEBUG: [2009-01-09 16:40:34,497] debug - Effettuo il passaggio di stato del file con id 177 per abilitarne la processazione
DEBUG: [2009-01-09 16:40:34,506] debug - Invio Jms ID[177]
DEBUG: [2009-01-09 16:40:34,624] debug - Invio Jms OK!
DEBUG: [2009-01-09 16:40:34,630] debug - Effettuo l'update
DEBUG: [2009-01-09 16:40:34,728] debug - Aggiornamento stato completato
DEBUG: [2009-01-09 16:40:34,729] debug - AbilitaProcessazioneFileAction: [OK]
DEBUG: [2009-01-09 16:40:34,729] debug - nome actionForward: upload

                                                  Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                                                                                      Javaday Roma III Edizione – 24 gennaio 2009
Arpione Programming




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Log-Driven Programming - Avanzato




     Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                         Javaday Roma III Edizione – 24 gennaio 2009
Log-Driven Programming - Avanzato

DEBUG: [2009-01-09 16:40:04,657] debug - Effettuo la copia fisica del file tramite stream
DEBUG: [2009-01-09 16:40:04,657] debug - Creo la directory in cui copiare il file
DEBUG: [2009-01-09 16:40:27,801] debug - Elimino il file temporaneo /tmp/temp_11-12-2008_12-29-14.xml
DEBUG: [2009-01-09 16:40:27,802] debug - Aggiorno nella history il file uploadato. Il nuovo stato e' 10
DEBUG: [2009-01-09 16:40:27,812] debug - Effettuo l'update
DEBUG: [2009-01-09 16:40:27,940] debug - Aggiornamento history completato
ERROR: [2009-01-09 16:40:27,941] error - CaricaFileAction: [KO]
DEBUG: [2009-01-09 16:40:27,942] debug - nome actionForward: upload
DEBUG: [2009-01-09 16:40:27,984] debug - pulizia sessione terminata con successo
DEBUG: [2009-01-09 16:40:27,986] debug - --- LISTA_FILE_RICERCATI
DEBUG: [2009-01-09 16:40:27,986] debug - --- session_user
DEBUG: [2009-01-09 16:40:27,987] debug - --- org.apache.struts.action.LOCALE                                    [#|2008-12-15T14:55:03.074+0100|INFO|sun-appserver9.1|javax.resourceadapter.mqjmsra.lifecycle|_ThreadID=10;_ThreadName=main;|MQJM
DEBUG: [2009-01-09 16:40:27,988] debug - --- MACROSERVIZIO                                                      [#|2008-12-15T14:55:03.438+0100|WARNING|sun-appserver9.1|javax.jms|_ThreadID=10;_ThreadName=main;_RequestID=d4f04750-1fdc-4896
DEBUG: [2009-01-09 16:40:27,989] debug - --- org.apache.struts.action.ACTION_MESSAGE                            ion refused|#]
DEBUG: [2009-01-09 16:40:27,990] debug - --- FILE_DA_UPLOADARE                                                  [#|2008-12-15T14:55:04.675+0100|WARNING|sun-appserver9.1|javax.jms|_ThreadID=10;_ThreadName=main;_RequestID=d4f04750-1fdc-4896
DEBUG: [2009-01-09 16:40:27,991] debug - entry point: VisualizzaCaricamentoFileAction                           ion refused|#]
DEBUG: [2009-01-09 16:40:27,992] debug - id servizio: 4                                                         [#|2008-12-15T14:55:05.749+0100|WARNING|sun-appserver9.1|javax.jms|_ThreadID=10;_ThreadName=main;_RequestID=d4f04750-1fdc-4896
DEBUG: [2009-01-09 16:40:28,037] debug - utente abilitato al servizio richiesto                                 ion refused|#]
DEBUG: [2009-01-09 16:40:28,066] debug - id servizio: 4                                                         [#|2008-12-15T14:55:09.311+0100|INFO|sun-appserver9.1|javax.resourceadapter.mqjmsra.lifecycle|_ThreadID=10;_ThreadName=main;|MQJM
DEBUG: [2009-01-09 16:40:28,067] debug - Caricamento dati relativi al servizio: 4                               [#|2008-12-15T14:55:11.097+0100|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=10;_ThreadName=main;|ADM1079:
DEBUG: [2009-01-09 16:40:28,191] debug - ms richiesto: true                                                     [#|2008-12-15T14:55:13.578+0100|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=12;_ThreadName=Thread-21;servic
DEBUG: [2009-01-09 16:40:28,191] debug - ms presente: true                                                      [service:jmx:rmi:///jndi/rmi://sin-svil-app1:59440/jmxrmi]. This is where the remote administrative clients should connect using the standard
DEBUG: [2009-01-09 16:40:28,204] debug - pulizia sessione terminata con successo                                [#|2008-12-15T14:55:13.595+0100|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=12;_ThreadName=Thread-21;true;|A
DEBUG: [2009-01-09 16:40:28,205] debug - --- session_user                                                       [#|2008-12-15T14:55:16.466+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=10;_ThreadName=main;|WEB030
DEBUG: [2009-01-09 16:40:28,206] debug - --- org.apache.struts.action.LOCALE                                    [#|2008-12-15T14:55:16.954+0100|INFO|sun-appserver9.1|com.sun.jbi.framework|_ThreadID=13;_ThreadName=pool-1-thread-4;|JBIFW0010: J
DEBUG: [2009-01-09 16:40:28,207] debug - --- MACROSERVIZIO                                                      [#|2008-12-15T14:55:18.656+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=10;_ThreadName=main;38182;|W
DEBUG: [2009-01-09 16:40:28,207] debug - --- org.apache.struts.action.ACTION_MESSAGE                            [#|2008-12-15T14:55:18.979+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=10;_ThreadName=main;4849;|WE
DEBUG: [2009-01-09 16:40:28,208] debug - Carico la dimensione massima del file in upload                        [#|2008-12-15T14:55:22.432+0100|INFO|sun-appserver9.1|org.apache.catalina.loader.WebappClassLoader|_ThreadID=14;_ThreadName=pool
DEBUG: [2009-01-09 16:40:28,209] debug - Imposto ad 1 il numero di file da uploadare                            B-INF/lib/javaee-1.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class|#]
DEBUG: [2009-01-09 16:40:28,210] debug - Carico i dettagli degli ultimi 10 file uploadati                       [#|2008-12-15T14:55:22.440+0100|INFO|sun-appserver9.1|org.apache.catalina.loader.WebappClassLoader|_ThreadID=14;_ThreadName=pool
DEBUG: [2009-01-09 16:40:28,219] debug - Effettuo la query                                                      B-INF/lib/servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class|#]
DEBUG: [2009-01-09 16:40:29,149] debug - Caricamento file completato                                            [#|2008-12-15T14:55:50.373+0100|INFO|sun-appserver9.1|javax.enterprise.system.core.selfmanagement|_ThreadID=10;_ThreadName=main;|S
DEBUG: [2009-01-09 16:40:29,150] debug - VisualizzaCaricamentoFileAction: [OK]                                  [#|2008-12-15T14:55:50.626+0100|INFO|sun-appserver9.1|javax.enterprise.system.core|_ThreadID=10;_ThreadName=main;|Application serve
DEBUG: [2009-01-09 16:40:29,151] debug - nome actionForward: upload                                             [#|2008-12-15T15:00:23.009+0100|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=15;_ThreadName=httpWorkerT
DEBUG: [2009-01-09 16:40:34,210] debug - entry point: AbilitaProcessazioneFileAction                            ruts.util.PropertyMessageResources).|#]
DEBUG: [2009-01-09 16:40:34,214] debug - id servizio: 4                                                         [#|2008-12-15T15:00:23.026+0100|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=15;_ThreadName=httpWorkerT
DEBUG: [2009-01-09 16:40:34,452] debug - utente abilitato al servizio richiesto                                 log4j:WARN Please initialize the log4j system properly.|#
DEBUG: [2009-01-09 16:40:34,497] debug - Effettuo il passaggio di stato del file con id 177 per abilitarne la processazione
                                                                                                                [#|2008-12-15T15:07:37.139+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=15;_ThreadName=httpWorkerThre
DEBUG: [2009-01-09 16:40:34,506] debug - Invio Jms ID[177]                                                      [#|2008-12-15T15:07:39.533+0100|INFO|sun-appserver9.1|javax.enterprise.system.core.transaction|_ThreadID=15;_ThreadName=httpWorkerT
DEBUG: [2009-01-09 16:40:34,624] debug - Invio Jms OK!                                                          [#|2008-12-15T15:07:39.717+0100|INFO|sun-appserver9.1|javax.enterprise.system.core|_ThreadID=15;_ThreadName=httpWorkerThread-3818
DEBUG: [2009-01-09 16:40:34,630] debug - Effettuo l'update                                                      [#|2008-12-15T15:07:42.837+0100|INFO|sun-appserver9.1|javax.enterprise.resource.corba|_ThreadID=15;_ThreadName=httpWorkerThread-38
DEBUG: [2009-01-09 16:40:34,728] debug - Aggiornamento stato completato                                         [#|2008-12-15T15:07:42.839+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=15;_ThreadName=httpWorkerThre
DEBUG: [2009-01-09 16:40:34,729] debug - AbilitaProcessazioneFileAction: [OK]
DEBUG: [2009-01-09 16:40:34,729] debug - nome actionForward: upload

                                                                                               Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                                                                                                                                                 Javaday Roma III Edizione – 24 gennaio 2009
Scavatore di trincea




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Scavatore di trincea I




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Scavatore di trincea II




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Scavatore di trincea II




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Scavatore di trincea II




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Allucinazione di Fowler




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
double calculateValue() {
                                     Allucinazione di Fowler
     if(_type == BTP) {
            Connection result = null;
            try {
                   Context initialContext = new InitialContext();
                   if ( initialContext == null){
                   log("JNDI problem. Cannot get InitialContext.");
                   }
                   DataSource datasource =
                            (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);
                   if (datasource != null) {
                            result = datasource.getConnection();
                   } else { log("Failed to lookup datasource."); }
            } catch ( NamingException ex ) {
                   log("Cannot get connection: " + ex);
            } catch(SQLException ex){
                   log("Cannot get connection: " + ex);
            }
            ...
            for (int i = 0; i ...) { ... } ... return result; }
     else if(_type == BOT) {
            for (int i = 0; i ...) { ... } ...
            return result;
     }
     for (int i = 0; i ...) { ... } ...
     return result;                            Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
}                                                                    Javaday Roma III Edizione – 24 gennaio 2009
Allucinazione di Fowler




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Allucinazione di Fowler




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Prospettive terapeutiche riabilitative




      Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                          Javaday Roma III Edizione – 24 gennaio 2009
Prospettive terapeutiche riabilitative




Noi diventiamo ciò che pensiamo
                                - Buddha




           Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                               Javaday Roma III Edizione – 24 gennaio 2009
Portatore di IF Conclamato




   Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                       Javaday Roma III Edizione – 24 gennaio 2009
Ricetta anti-if#2




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Anche tu puoi aderire




Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                    Javaday Roma III Edizione – 24 gennaio 2009
Domande?


Riferimenti:
• Campagna Anti IF *sito corrente:
  http://www.metodiagili.it/iniziative/campagna-anti-if/index.html


• Campagna Anti IF *nuovo sito (da metà febbraio):
  http://www.antiifcampaign.com
• AgileLetter di XPLabs:
  http://www.xplabs.it/agileletter.html


                              Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                                                  Javaday Roma III Edizione – 24 gennaio 2009
Ricette per Eliminare gli IF

        Francesco Cirillo




           Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL
                               Javaday Roma III Edizione – 24 gennaio 2009

More Related Content

Similar to 20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]

Virginio Desktop Codifica
Virginio Desktop   CodificaVirginio Desktop   Codifica
Virginio Desktop Codifica
Alartzero
 
Progetto informatica
Progetto informaticaProgetto informatica
Progetto informatica
giosca94
 

Similar to 20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA] (15)

Virginio Desktop Codifica
Virginio Desktop   CodificaVirginio Desktop   Codifica
Virginio Desktop Codifica
 
Eccezioni in java
Eccezioni in javaEccezioni in java
Eccezioni in java
 
Javaday 2006: Java 5
Javaday 2006: Java 5Javaday 2006: Java 5
Javaday 2006: Java 5
 
Dal C a Java (2/3)
Dal C a Java (2/3)Dal C a Java (2/3)
Dal C a Java (2/3)
 
Progetto informatica
Progetto informaticaProgetto informatica
Progetto informatica
 
Spring @Aspect e @Controller
Spring @Aspect e @Controller Spring @Aspect e @Controller
Spring @Aspect e @Controller
 
Real Spring Aop Recipes For Your Everyday Job
Real Spring Aop Recipes For Your Everyday JobReal Spring Aop Recipes For Your Everyday Job
Real Spring Aop Recipes For Your Everyday Job
 
Java Symbolic Regression - Machine Learining
Java Symbolic Regression - Machine LeariningJava Symbolic Regression - Machine Learining
Java Symbolic Regression - Machine Learining
 
Matematica, un approccio algoritmico
Matematica, un approccio algoritmicoMatematica, un approccio algoritmico
Matematica, un approccio algoritmico
 
"Come è piccolo il mondo" - Seminario: Matematica, un approccio algoritmico
"Come è piccolo il mondo" - Seminario: Matematica, un approccio algoritmico"Come è piccolo il mondo" - Seminario: Matematica, un approccio algoritmico
"Come è piccolo il mondo" - Seminario: Matematica, un approccio algoritmico
 
iContract
iContractiContract
iContract
 
Googletest, tdd e mock
Googletest, tdd e mockGoogletest, tdd e mock
Googletest, tdd e mock
 
Object Oriented JavaScript con TypeScript
Object Oriented JavaScript con TypeScriptObject Oriented JavaScript con TypeScript
Object Oriented JavaScript con TypeScript
 
Corso pratico di C# - 2013
Corso pratico di C# - 2013Corso pratico di C# - 2013
Corso pratico di C# - 2013
 
Java Unit Testing - JUnit (2)
Java Unit Testing - JUnit (2)Java Unit Testing - JUnit (2)
Java Unit Testing - JUnit (2)
 

More from Francesco Cirillo

20071123 XPLabs Tour07 Bonsai @ItalianAgileDay2007 Bologna-IT [ITA]
20071123 XPLabs Tour07 Bonsai @ItalianAgileDay2007 Bologna-IT [ITA]20071123 XPLabs Tour07 Bonsai @ItalianAgileDay2007 Bologna-IT [ITA]
20071123 XPLabs Tour07 Bonsai @ItalianAgileDay2007 Bologna-IT [ITA]
Francesco Cirillo
 
20071027 XPLabs Tour Bonsai @LinuxDayRoma2007 Roma-IT [ITA]
20071027 XPLabs Tour Bonsai @LinuxDayRoma2007 Roma-IT [ITA]20071027 XPLabs Tour Bonsai @LinuxDayRoma2007 Roma-IT [ITA]
20071027 XPLabs Tour Bonsai @LinuxDayRoma2007 Roma-IT [ITA]
Francesco Cirillo
 
20061028 XPLabs Tour06 Bonsai @LinuxDayRoma2006 Roma-IT [ITA]
20061028 XPLabs Tour06 Bonsai @LinuxDayRoma2006 Roma-IT [ITA]20061028 XPLabs Tour06 Bonsai @LinuxDayRoma2006 Roma-IT [ITA]
20061028 XPLabs Tour06 Bonsai @LinuxDayRoma2006 Roma-IT [ITA]
Francesco Cirillo
 
20060703 XP Values and Principles @Essap2006 Varese-IT [ITA]
20060703 XP Values and Principles @Essap2006 Varese-IT [ITA]20060703 XP Values and Principles @Essap2006 Varese-IT [ITA]
20060703 XP Values and Principles @Essap2006 Varese-IT [ITA]
Francesco Cirillo
 
20050621 Ridurre il Costo del Cambiamento Applicando il Design Object Oriente...
20050621 Ridurre il Costo del Cambiamento Applicando il Design Object Oriente...20050621 Ridurre il Costo del Cambiamento Applicando il Design Object Oriente...
20050621 Ridurre il Costo del Cambiamento Applicando il Design Object Oriente...
Francesco Cirillo
 
20040503 Easy Tracking @AICA2004 Milano-IT [ITA]
20040503 Easy Tracking @AICA2004 Milano-IT [ITA]20040503 Easy Tracking @AICA2004 Milano-IT [ITA]
20040503 Easy Tracking @AICA2004 Milano-IT [ITA]
Francesco Cirillo
 

More from Francesco Cirillo (12)

20091203 Design Emergente Più Cambiamenti Più Profitti @UxConference2009 Luga...
20091203 Design Emergente Più Cambiamenti Più Profitti @UxConference2009 Luga...20091203 Design Emergente Più Cambiamenti Più Profitti @UxConference2009 Luga...
20091203 Design Emergente Più Cambiamenti Più Profitti @UxConference2009 Luga...
 
20090507 Metodi Agili e Aumento del Roi @Better Software2009 Firenze IT [ITA]
20090507 Metodi Agili e Aumento del Roi @Better Software2009 Firenze IT [ITA]20090507 Metodi Agili e Aumento del Roi @Better Software2009 Firenze IT [ITA]
20090507 Metodi Agili e Aumento del Roi @Better Software2009 Firenze IT [ITA]
 
20080124 XPLabs Tour08 @UniAQ.it L'Aquila-IT [ITA]
20080124 XPLabs Tour08 @UniAQ.it L'Aquila-IT [ITA]20080124 XPLabs Tour08 @UniAQ.it L'Aquila-IT [ITA]
20080124 XPLabs Tour08 @UniAQ.it L'Aquila-IT [ITA]
 
20071201 Eliminare For @JavaDayRoma2 Roma-IT [ITA]
20071201 Eliminare For @JavaDayRoma2 Roma-IT [ITA]20071201 Eliminare For @JavaDayRoma2 Roma-IT [ITA]
20071201 Eliminare For @JavaDayRoma2 Roma-IT [ITA]
 
20071123 XPLabs Tour07 Bonsai @ItalianAgileDay2007 Bologna-IT [ITA]
20071123 XPLabs Tour07 Bonsai @ItalianAgileDay2007 Bologna-IT [ITA]20071123 XPLabs Tour07 Bonsai @ItalianAgileDay2007 Bologna-IT [ITA]
20071123 XPLabs Tour07 Bonsai @ItalianAgileDay2007 Bologna-IT [ITA]
 
20071027 XPLabs Tour Bonsai @LinuxDayRoma2007 Roma-IT [ITA]
20071027 XPLabs Tour Bonsai @LinuxDayRoma2007 Roma-IT [ITA]20071027 XPLabs Tour Bonsai @LinuxDayRoma2007 Roma-IT [ITA]
20071027 XPLabs Tour Bonsai @LinuxDayRoma2007 Roma-IT [ITA]
 
20061028 XPLabs Tour06 Bonsai @LinuxDayRoma2006 Roma-IT [ITA]
20061028 XPLabs Tour06 Bonsai @LinuxDayRoma2006 Roma-IT [ITA]20061028 XPLabs Tour06 Bonsai @LinuxDayRoma2006 Roma-IT [ITA]
20061028 XPLabs Tour06 Bonsai @LinuxDayRoma2006 Roma-IT [ITA]
 
20060703 XP Values and Principles @Essap2006 Varese-IT [ITA]
20060703 XP Values and Principles @Essap2006 Varese-IT [ITA]20060703 XP Values and Principles @Essap2006 Varese-IT [ITA]
20060703 XP Values and Principles @Essap2006 Varese-IT [ITA]
 
20060627 SOA @JavaConference2006 Milano-IT [ITA]
20060627 SOA @JavaConference2006 Milano-IT [ITA]20060627 SOA @JavaConference2006 Milano-IT [ITA]
20060627 SOA @JavaConference2006 Milano-IT [ITA]
 
20051216 Il Prossimo Passo @Italian AgileDay2005 Milano-IT [ITA]
20051216 Il Prossimo Passo @Italian AgileDay2005 Milano-IT [ITA]20051216 Il Prossimo Passo @Italian AgileDay2005 Milano-IT [ITA]
20051216 Il Prossimo Passo @Italian AgileDay2005 Milano-IT [ITA]
 
20050621 Ridurre il Costo del Cambiamento Applicando il Design Object Oriente...
20050621 Ridurre il Costo del Cambiamento Applicando il Design Object Oriente...20050621 Ridurre il Costo del Cambiamento Applicando il Design Object Oriente...
20050621 Ridurre il Costo del Cambiamento Applicando il Design Object Oriente...
 
20040503 Easy Tracking @AICA2004 Milano-IT [ITA]
20040503 Easy Tracking @AICA2004 Milano-IT [ITA]20040503 Easy Tracking @AICA2004 Milano-IT [ITA]
20040503 Easy Tracking @AICA2004 Milano-IT [ITA]
 

20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]

  • 1. Ricette per Eliminare gli IF Francesco Cirillo Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 2. La Campagna Anti-IF Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 3. I sostenitori Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 4. Anche tu puoi aderire Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 5. Il nuovo sito Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 6. Ricette per eliminare gli IF Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 7. Ricetta anti-if#1: Il navigatore Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 8. Ricetta anti-if#1: Il navigatore if(command.equals("start")) { ... ... } else if(command.equals("stop") { ... ... } if(command.equals("start")) { parseAndExecuteStartRequest(); } else if(command.equals("stop") { parseAndExecuteStopRequest(); } if(command.equals("start")) { new StartRequest().parseAndExecute(); } else if(command.equals("stop") { new StopRequest().parseAndExecute(); } Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 9. Ricetta anti-if#1: Il navigatore if(command.equals("start")) { new StartRequest().parseAndExecute(); } else if(command.equals("stop") { new StopRequest().parseAndExecute(); } if(command.equals("start")) { _command1.parseAndExecute(); } else if(command.equals("stop") { _command2.parseAndExecute(); } public Navigator(Command start, Command stop) { _command1 = start; _command2 = stop; } navigator.commandFor("start").parseAndExecute(); Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 10. Ricetta anti-if#1: Il navigatore if(command.equals("start")) { ... ... } else if(command.equals("stop") { ... ... } navigator.commandFor("start").parseAndExecute(); public Command commandFor(String aCommandName) { return _commands.get(aCommandName); } navigator.put("start",new StartRequest()); navigator.put("stop",new StopRequest()); Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 11. Ricetta anti-if#1: Il navigatore if(command.equals("start")) { ... ... } else if(command.equals("stop") { ... ... } navigator.commandFor("start").parseAndExecute(); public Command commandFor(String aCommandName) { if(!_commands.contains(aCommandName) return _defaultCommand; return _commands.get(aCommandName); } public Navigator(Command defaultCommand) { _defaultCommand = defaultCommand; … } Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 12. Sintomi Sindrome IF Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 13. Attacco alla diligenza Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 14. Attacco alla diligenza private void mouseClicked(MouseEvent evt) { long start = System.currentTimeMillis(); System.out.println("Inizio " + _operation + ": " + Calendar.getInstance().getTime().toString()); String[] parameters = new String[]{_command, getField_remote_export().getText(), getJTextFieldCommentoRelease().getText().replaceAll(" ","_"), _location}; _project = getField_directory().getText()); try { if(_inProd) _project = “project”; Process process = Runtime.getRuntime().exec( parameters, null, new File(_project)); process.waitFor(); } catch (Exception e) { e.printStackTrace(); } System.out.println(this._command + " eseguito in: " + (System.currentTimeMillis() - start) + " ms"); Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL } Javaday Roma III Edizione – 24 gennaio 2009
  • 15. Attacco alla diligenza private void mouseClicked(MouseEvent evt) { long start = System.currentTimeMillis(); System.out.println("Inizio " + _operation + ": " + Calendar.getInstance().getTime().toString()); String[] parameters = new String[]{_command, getField_remote_export().getText(), getJTextFieldCommentoRelease().getText().replaceAll(" ","_"), _location}; _project = getField_directory().getText()); try { if(_inProd) _project = “project”; Process process = Runtime.getRuntime().exec( parameters, null, new File(_project)); process.waitFor(); } catch (Exception e) { e.printStackTrace(); } System.out.println(this._command + " eseguito in: " + (System.currentTimeMillis() - start) + " ms"); Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL } Javaday Roma III Edizione – 24 gennaio 2009
  • 16. One Class One Method Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 17. One Class One Method Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 18. private String getMcCabeValue() { One Class One Method String max = null; NodeList metriche = _doc.getElementsByTagName("Metric"); int numeroMetriche = metriche.getLength(); for(int i=0;i<numeroMetriche;i++){ Node metrica = metriche.item(i); if (metrica.getNodeType()==Node.ELEMENT_NODE){ Element Emetrica = (Element)metrica; String id =Emetrica.getAttribute("id"); //mi stampo tutti i tipi di metriche System.out.println(id); if(id.equals("VG")){ NodeList values = metrica.getChildNodes(); for(int j=0;j<values.getLength();j++){ Node value = values.item(j); if(value.getNodeType()==Node.ELEMENT_NODE){ Element Evalue = (Element)value; max = Evalue.getAttribute("max"); // mi stampa il massimo di McCabe Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL System.out.println(max); } } } } } Javaday Roma III Edizione – 24 gennaio 2009 return max; }
  • 19. private String getMcCabeValue() { One Class One Method String max = null; NodeList metriche = _doc.getElementsByTagName("Metric"); int numeroMetriche = metriche.getLength(); for(int i=0;i<numeroMetriche;i++){ Node metrica = metriche.item(i); if (metrica.getNodeType()==Node.ELEMENT_NODE){ Element Emetrica = (Element)metrica; String id =Emetrica.getAttribute("id"); //mi stampo tutti i tipi di metriche System.out.println(id); if(id.equals("VG")){ NodeList values = metrica.getChildNodes(); for(int j=0;j<values.getLength();j++){ Node value = values.item(j); if(value.getNodeType()==Node.ELEMENT_NODE){ Element Evalue = (Element)value; max = Evalue.getAttribute("max"); // mi stampa il massimo di McCabe Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL System.out.println(max); } } } } } Javaday Roma III Edizione – 24 gennaio 2009 return max; }
  • 20. Arpione Programming Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 21. double calculateValue() { if(_type == BTP) { Connection result = null; Arpione Programming try { Context initialContext = new InitialContext(); if ( initialContext == null){ log("JNDI problem. Cannot get InitialContext."); } DataSource datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT); if (datasource != null) { result = datasource.getConnection(); } else { log("Failed to lookup datasource."); } } catch ( NamingException ex ) { log("Cannot get connection: " + ex); } catch(SQLException ex){ log("Cannot get connection: " + ex); } ... for (int i = 0; i ...) { ... } ... return result; } else if(_type == BOT) { for (int i = 0; i ...) { ... } ... return result; } for (int i = 0; i ...) { ... } ... Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL return result; Javaday Roma III Edizione – 24 gennaio 2009 }
  • 22. double calculateValue() { if(_type == BTP) { Connection result = null; Arpione Programming try { Context initialContext = new InitialContext(); if ( initialContext == null){ log("JNDI problem. Cannot get InitialContext."); } DataSource datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT); if (datasource != null) { result = datasource.getConnection(); } else { log("Failed to lookup datasource."); } } catch ( NamingException ex ) { log("Cannot get connection: " + ex); } catch(SQLException ex){ log("Cannot get connection: " + ex); } ... for (int i = 0; i ...) { ... } ... return result; } else if(_type == BOT) { for (int i = 0; i ...) { ... } ... return result; } for (int i = 0; i ...) { ... } ... Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL return result; Javaday Roma III Edizione – 24 gennaio 2009 }
  • 23. Log-Driven Programming DEBUG: [2009-01-09 16:40:04,657] debug - Effettuo la copia fisica del file tramite stream DEBUG: [2009-01-09 16:40:04,657] debug - Creo la directory in cui copiare il file DEBUG: [2009-01-09 16:40:27,801] debug - Elimino il file temporaneo /tmp/temp_11-12-2008_12-29-14.xml DEBUG: [2009-01-09 16:40:27,802] debug - Aggiorno nella history il file uploadato. Il nuovo stato e' 10 DEBUG: [2009-01-09 16:40:27,812] debug - Effettuo l'update DEBUG: [2009-01-09 16:40:27,940] debug - Aggiornamento history completato ERROR: [2009-01-09 16:40:27,941] error - CaricaFileAction: [KO] DEBUG: [2009-01-09 16:40:27,942] debug - nome actionForward: upload DEBUG: [2009-01-09 16:40:27,984] debug - pulizia sessione terminata con successo DEBUG: [2009-01-09 16:40:27,986] debug - --- LISTA_FILE_RICERCATI DEBUG: [2009-01-09 16:40:27,986] debug - --- session_user DEBUG: [2009-01-09 16:40:27,987] debug - --- org.apache.struts.action.LOCALE DEBUG: [2009-01-09 16:40:27,988] debug - --- MACROSERVIZIO DEBUG: [2009-01-09 16:40:27,989] debug - --- org.apache.struts.action.ACTION_MESSAGE DEBUG: [2009-01-09 16:40:27,990] debug - --- FILE_DA_UPLOADARE DEBUG: [2009-01-09 16:40:27,991] debug - entry point: VisualizzaCaricamentoFileAction DEBUG: [2009-01-09 16:40:27,992] debug - id servizio: 4 DEBUG: [2009-01-09 16:40:28,037] debug - utente abilitato al servizio richiesto DEBUG: [2009-01-09 16:40:28,066] debug - id servizio: 4 DEBUG: [2009-01-09 16:40:28,067] debug - Caricamento dati relativi al servizio: 4 DEBUG: [2009-01-09 16:40:28,191] debug - ms richiesto: true DEBUG: [2009-01-09 16:40:28,191] debug - ms presente: true DEBUG: [2009-01-09 16:40:28,204] debug - pulizia sessione terminata con successo DEBUG: [2009-01-09 16:40:28,205] debug - --- session_user DEBUG: [2009-01-09 16:40:28,206] debug - --- org.apache.struts.action.LOCALE DEBUG: [2009-01-09 16:40:28,207] debug - --- MACROSERVIZIO DEBUG: [2009-01-09 16:40:28,207] debug - --- org.apache.struts.action.ACTION_MESSAGE DEBUG: [2009-01-09 16:40:28,208] debug - Carico la dimensione massima del file in upload DEBUG: [2009-01-09 16:40:28,209] debug - Imposto ad 1 il numero di file da uploadare DEBUG: [2009-01-09 16:40:28,210] debug - Carico i dettagli degli ultimi 10 file uploadati DEBUG: [2009-01-09 16:40:28,219] debug - Effettuo la query DEBUG: [2009-01-09 16:40:29,149] debug - Caricamento file completato DEBUG: [2009-01-09 16:40:29,150] debug - VisualizzaCaricamentoFileAction: [OK] DEBUG: [2009-01-09 16:40:29,151] debug - nome actionForward: upload DEBUG: [2009-01-09 16:40:34,210] debug - entry point: AbilitaProcessazioneFileAction DEBUG: [2009-01-09 16:40:34,214] debug - id servizio: 4 DEBUG: [2009-01-09 16:40:34,452] debug - utente abilitato al servizio richiesto DEBUG: [2009-01-09 16:40:34,497] debug - Effettuo il passaggio di stato del file con id 177 per abilitarne la processazione DEBUG: [2009-01-09 16:40:34,506] debug - Invio Jms ID[177] DEBUG: [2009-01-09 16:40:34,624] debug - Invio Jms OK! DEBUG: [2009-01-09 16:40:34,630] debug - Effettuo l'update DEBUG: [2009-01-09 16:40:34,728] debug - Aggiornamento stato completato DEBUG: [2009-01-09 16:40:34,729] debug - AbilitaProcessazioneFileAction: [OK] DEBUG: [2009-01-09 16:40:34,729] debug - nome actionForward: upload Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 24. Arpione Programming Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 25. Log-Driven Programming - Avanzato Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 26. Log-Driven Programming - Avanzato DEBUG: [2009-01-09 16:40:04,657] debug - Effettuo la copia fisica del file tramite stream DEBUG: [2009-01-09 16:40:04,657] debug - Creo la directory in cui copiare il file DEBUG: [2009-01-09 16:40:27,801] debug - Elimino il file temporaneo /tmp/temp_11-12-2008_12-29-14.xml DEBUG: [2009-01-09 16:40:27,802] debug - Aggiorno nella history il file uploadato. Il nuovo stato e' 10 DEBUG: [2009-01-09 16:40:27,812] debug - Effettuo l'update DEBUG: [2009-01-09 16:40:27,940] debug - Aggiornamento history completato ERROR: [2009-01-09 16:40:27,941] error - CaricaFileAction: [KO] DEBUG: [2009-01-09 16:40:27,942] debug - nome actionForward: upload DEBUG: [2009-01-09 16:40:27,984] debug - pulizia sessione terminata con successo DEBUG: [2009-01-09 16:40:27,986] debug - --- LISTA_FILE_RICERCATI DEBUG: [2009-01-09 16:40:27,986] debug - --- session_user DEBUG: [2009-01-09 16:40:27,987] debug - --- org.apache.struts.action.LOCALE [#|2008-12-15T14:55:03.074+0100|INFO|sun-appserver9.1|javax.resourceadapter.mqjmsra.lifecycle|_ThreadID=10;_ThreadName=main;|MQJM DEBUG: [2009-01-09 16:40:27,988] debug - --- MACROSERVIZIO [#|2008-12-15T14:55:03.438+0100|WARNING|sun-appserver9.1|javax.jms|_ThreadID=10;_ThreadName=main;_RequestID=d4f04750-1fdc-4896 DEBUG: [2009-01-09 16:40:27,989] debug - --- org.apache.struts.action.ACTION_MESSAGE ion refused|#] DEBUG: [2009-01-09 16:40:27,990] debug - --- FILE_DA_UPLOADARE [#|2008-12-15T14:55:04.675+0100|WARNING|sun-appserver9.1|javax.jms|_ThreadID=10;_ThreadName=main;_RequestID=d4f04750-1fdc-4896 DEBUG: [2009-01-09 16:40:27,991] debug - entry point: VisualizzaCaricamentoFileAction ion refused|#] DEBUG: [2009-01-09 16:40:27,992] debug - id servizio: 4 [#|2008-12-15T14:55:05.749+0100|WARNING|sun-appserver9.1|javax.jms|_ThreadID=10;_ThreadName=main;_RequestID=d4f04750-1fdc-4896 DEBUG: [2009-01-09 16:40:28,037] debug - utente abilitato al servizio richiesto ion refused|#] DEBUG: [2009-01-09 16:40:28,066] debug - id servizio: 4 [#|2008-12-15T14:55:09.311+0100|INFO|sun-appserver9.1|javax.resourceadapter.mqjmsra.lifecycle|_ThreadID=10;_ThreadName=main;|MQJM DEBUG: [2009-01-09 16:40:28,067] debug - Caricamento dati relativi al servizio: 4 [#|2008-12-15T14:55:11.097+0100|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=10;_ThreadName=main;|ADM1079: DEBUG: [2009-01-09 16:40:28,191] debug - ms richiesto: true [#|2008-12-15T14:55:13.578+0100|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=12;_ThreadName=Thread-21;servic DEBUG: [2009-01-09 16:40:28,191] debug - ms presente: true [service:jmx:rmi:///jndi/rmi://sin-svil-app1:59440/jmxrmi]. This is where the remote administrative clients should connect using the standard DEBUG: [2009-01-09 16:40:28,204] debug - pulizia sessione terminata con successo [#|2008-12-15T14:55:13.595+0100|INFO|sun-appserver9.1|javax.enterprise.system.tools.admin|_ThreadID=12;_ThreadName=Thread-21;true;|A DEBUG: [2009-01-09 16:40:28,205] debug - --- session_user [#|2008-12-15T14:55:16.466+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=10;_ThreadName=main;|WEB030 DEBUG: [2009-01-09 16:40:28,206] debug - --- org.apache.struts.action.LOCALE [#|2008-12-15T14:55:16.954+0100|INFO|sun-appserver9.1|com.sun.jbi.framework|_ThreadID=13;_ThreadName=pool-1-thread-4;|JBIFW0010: J DEBUG: [2009-01-09 16:40:28,207] debug - --- MACROSERVIZIO [#|2008-12-15T14:55:18.656+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=10;_ThreadName=main;38182;|W DEBUG: [2009-01-09 16:40:28,207] debug - --- org.apache.struts.action.ACTION_MESSAGE [#|2008-12-15T14:55:18.979+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=10;_ThreadName=main;4849;|WE DEBUG: [2009-01-09 16:40:28,208] debug - Carico la dimensione massima del file in upload [#|2008-12-15T14:55:22.432+0100|INFO|sun-appserver9.1|org.apache.catalina.loader.WebappClassLoader|_ThreadID=14;_ThreadName=pool DEBUG: [2009-01-09 16:40:28,209] debug - Imposto ad 1 il numero di file da uploadare B-INF/lib/javaee-1.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class|#] DEBUG: [2009-01-09 16:40:28,210] debug - Carico i dettagli degli ultimi 10 file uploadati [#|2008-12-15T14:55:22.440+0100|INFO|sun-appserver9.1|org.apache.catalina.loader.WebappClassLoader|_ThreadID=14;_ThreadName=pool DEBUG: [2009-01-09 16:40:28,219] debug - Effettuo la query B-INF/lib/servlet-api-2.4.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class|#] DEBUG: [2009-01-09 16:40:29,149] debug - Caricamento file completato [#|2008-12-15T14:55:50.373+0100|INFO|sun-appserver9.1|javax.enterprise.system.core.selfmanagement|_ThreadID=10;_ThreadName=main;|S DEBUG: [2009-01-09 16:40:29,150] debug - VisualizzaCaricamentoFileAction: [OK] [#|2008-12-15T14:55:50.626+0100|INFO|sun-appserver9.1|javax.enterprise.system.core|_ThreadID=10;_ThreadName=main;|Application serve DEBUG: [2009-01-09 16:40:29,151] debug - nome actionForward: upload [#|2008-12-15T15:00:23.009+0100|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=15;_ThreadName=httpWorkerT DEBUG: [2009-01-09 16:40:34,210] debug - entry point: AbilitaProcessazioneFileAction ruts.util.PropertyMessageResources).|#] DEBUG: [2009-01-09 16:40:34,214] debug - id servizio: 4 [#|2008-12-15T15:00:23.026+0100|WARNING|sun-appserver9.1|javax.enterprise.system.stream.err|_ThreadID=15;_ThreadName=httpWorkerT DEBUG: [2009-01-09 16:40:34,452] debug - utente abilitato al servizio richiesto log4j:WARN Please initialize the log4j system properly.|# DEBUG: [2009-01-09 16:40:34,497] debug - Effettuo il passaggio di stato del file con id 177 per abilitarne la processazione [#|2008-12-15T15:07:37.139+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=15;_ThreadName=httpWorkerThre DEBUG: [2009-01-09 16:40:34,506] debug - Invio Jms ID[177] [#|2008-12-15T15:07:39.533+0100|INFO|sun-appserver9.1|javax.enterprise.system.core.transaction|_ThreadID=15;_ThreadName=httpWorkerT DEBUG: [2009-01-09 16:40:34,624] debug - Invio Jms OK! [#|2008-12-15T15:07:39.717+0100|INFO|sun-appserver9.1|javax.enterprise.system.core|_ThreadID=15;_ThreadName=httpWorkerThread-3818 DEBUG: [2009-01-09 16:40:34,630] debug - Effettuo l'update [#|2008-12-15T15:07:42.837+0100|INFO|sun-appserver9.1|javax.enterprise.resource.corba|_ThreadID=15;_ThreadName=httpWorkerThread-38 DEBUG: [2009-01-09 16:40:34,728] debug - Aggiornamento stato completato [#|2008-12-15T15:07:42.839+0100|INFO|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=15;_ThreadName=httpWorkerThre DEBUG: [2009-01-09 16:40:34,729] debug - AbilitaProcessazioneFileAction: [OK] DEBUG: [2009-01-09 16:40:34,729] debug - nome actionForward: upload Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 27. Scavatore di trincea Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 28. Scavatore di trincea I Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 29. Scavatore di trincea II Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 30. Scavatore di trincea II Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 31. Scavatore di trincea II Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 32. Allucinazione di Fowler Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 33. double calculateValue() { Allucinazione di Fowler if(_type == BTP) { Connection result = null; try { Context initialContext = new InitialContext(); if ( initialContext == null){ log("JNDI problem. Cannot get InitialContext."); } DataSource datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT); if (datasource != null) { result = datasource.getConnection(); } else { log("Failed to lookup datasource."); } } catch ( NamingException ex ) { log("Cannot get connection: " + ex); } catch(SQLException ex){ log("Cannot get connection: " + ex); } ... for (int i = 0; i ...) { ... } ... return result; } else if(_type == BOT) { for (int i = 0; i ...) { ... } ... return result; } for (int i = 0; i ...) { ... } ... return result; Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL } Javaday Roma III Edizione – 24 gennaio 2009
  • 34. Allucinazione di Fowler Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 35. Allucinazione di Fowler Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 36. Prospettive terapeutiche riabilitative Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 37. Prospettive terapeutiche riabilitative Noi diventiamo ciò che pensiamo - Buddha Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 38. Portatore di IF Conclamato Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 39. Ricetta anti-if#2 Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 40. Anche tu puoi aderire Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 41. Domande? Riferimenti: • Campagna Anti IF *sito corrente: http://www.metodiagili.it/iniziative/campagna-anti-if/index.html • Campagna Anti IF *nuovo sito (da metà febbraio): http://www.antiifcampaign.com • AgileLetter di XPLabs: http://www.xplabs.it/agileletter.html Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009
  • 42. Ricette per Eliminare gli IF Francesco Cirillo Francesco Cirillo – formazione@metodiagili.it – XPLabs SRL Javaday Roma III Edizione – 24 gennaio 2009