SlideShare una empresa de Scribd logo
1 de 30
Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License




             Campagna Anti-IF:
              Java e i linguaggi dinamici,
              incrementare le potenzialità
              espressive di Java
              [“Eliminare” i FOR]

Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Campagna Anti-IF
                                                     Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License




Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Obiettivo
                                                     Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License


        Più potere a Java “senza” i FOR
          −   Paper su come “eliminare” i FOR
        Esperienza di design evolutivo
          −   Attraverso il refactoring
          −   Usando i principi di design
        Far vincere qualche maglietta :)



Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Sviluppo Java Web: lento!
                                                     Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License


        News Aggregator@xpug.it
      http://it.groups.yahoo.com/group/extremeprogramming-it/message/4485:
       http://it.groups.yahoo.com/group/extremeprogramming-it/message/4485:
      ……
      > E poi detta tutta java a sviluppo web non è così tanto veloce in una
       > E poi detta tutta java a sviluppo web non è così tanto veloce in una
      > giornata non si riesce.
       > giornata non si riesce.
      su questo no :-) Direi che una prima iterazione con tutte le funzionalita'
       su questo no :-) Direi che una prima iterazione con tutte le funzionalita'
      di base in una giornata con 2 coppie si riesce a fare.
       di base in una giornata con 2 coppie si riesce a fare.
      > Con Rails in mezza o 1/4 :) ma non entriamo in guerre di religione.
       > Con Rails in mezza o 1/4 :) ma non entriamo in guerre di religione.
      Se non si riesce probabilmente le storie non sono state spezzate in modo
       Se non si riesce probabilmente le storie non sono state spezzate in modo
      iterativo-incrementale/verticale ;-)
       iterativo-incrementale/verticale ;-)
      ……




Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Il problema
 ////class Department
      class Department                               Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
 public void printSlips() {{
   public void printSlips()
        Resource resource = null;
         Resource resource = null;                           (resources select: inForce) do: printSlip.
                                                              (resources select: inForce) do: printSlip.
        for(int i=0; i i< _resources.size();i++) {{
         for(int i=0; < _resources.size();i++)
              resource = (Resource)_resources.get(i);
               resource = (Resource)_resources.get(i);
              if(resource.lastContract().deadline().after(new Date())) {{
               if(resource.lastContract().deadline().after(new Date()))
                    System.out.println(resource.name());
                     System.out.println(resource.name());
                    System.out.println(resource.salary());
                     System.out.println(resource.salary());
              }}
        }}
        public void printSlips() {{
         public void printSlips()
 }}          for (Resource eachResource: _resources) {{
              for (Resource eachResource: _resources)
                   if(eachResource.lastContract().deadline().after(new Date()) )){{
                    if(eachResource.lastContract().deadline().after(new Date())
                         System.out.println(eachResource.name());
                          System.out.println(eachResource.name());
  “Our job is to solve problems, not spoonfeed compilers (…)
   “Our job is to solve problems, not spoonfeed compilers (…)
                         System.out.println(eachResource.salary());
  We need clarity soSystem.out.println(eachResource.salary());
   We need clarity sowe can communicate using our code. We
                           we can communicate using our code. We
                   }}
  value conciseness and the ability to express aarequirement in
   value conciseness and the ability to express requirement in
             }}
  code accurately and efficiently”.
   code accurately and efficiently”.
                                                --Dave Thomas
                                                 --Dave Thomas
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Parliamo di design
 ////class Department
      class Department                          Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
 public void printSlips() {{
   public void printSlips()
        Resource resource = null;
         Resource resource = null;
        for(int i=0; i i< _resources.size();i++) {{
         for(int i=0; < _resources.size();i++)
              resource = (Resource)_resources.get(i);
               resource = (Resource)_resources.get(i);
              if(resource.lastContract().deadline().after(new Date())) {{
               if(resource.lastContract().deadline().after(new Date()))
                    System.out.println(resource.name());
                     System.out.println(resource.name());
                    System.out.println(resource.salary());
                     System.out.println(resource.salary());
              }}
        }}
 }}




Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Parliamo di design
   ////class Department
        class Department                          Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
   public void printSlips() {{
     public void printSlips()
          Resource resource = null;
           Resource resource = null;                 Ciclo?+Navigazione?
                                                     Ciclo?+Navigazione?
                                                      Ciclo?+Navigazione?
          for(int i=0; i i< _resources.size();i++) {{
           for(int i=0; < _resources.size();i++)
                resource = (Resource)_resources.get(i);
                 resource = (Resource)_resources.get(i);
Selezione?
 Selezione?     if(resource.lastContract().deadline().after(new Date())) {{
                 if(resource.lastContract().deadline().after(new Date()))
                      System.out.println(resource.name()); Contenuti?
                       System.out.println(resource.name()); Contenuti?
        Media?
         Media?
                      System.out.println(resource.salary());
                       System.out.println(resource.salary());
                }}
          }}
                                       Layout?
                                        Layout?
   }}

        public void printSlipForEach() { {
         public void printSlipForEach()                                                    Ciclo?
                                                                                            Ciclo?
              for (Resource eachResource: _resources) { {
                for (Resource eachResource: _resources)
                      if(eachResource.lastContract().deadline().after(new Date()) ) ){ {
                        if(eachResource.lastContract().deadline().after(new Date())
                              System.out.println(eachResource.name());
                               System.out.println(eachResource.name());
                              System.out.println(eachResource.salary());
                               System.out.println(eachResource.salary());
                      }}
              }}
        }}
 Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
 Javaday Roma - 01/12/2007
Abbassare la complessità
                                                     Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License



          Il Refactoring:
           −   Aumentare la capacità del codice di rivelare le
Lightweight
               intenzioni di design, a qualsiasi membro del team,
 Lightweight
               alla prima occhiata
           −   Migliorare la struttura interna del sistema,
               consentendo alle necessarie astrazioni di emergere
           “Our job is to solve problems, not spoonfeed compilers (…)
            “Our job is to solve problems, not spoonfeed compilers (…)
           We need clarity so we can communicate using our code. We
            We need clarity so we can communicate using our code. We
           value conciseness and the ability to express aarequirement in
            value conciseness and the ability to express requirement in
           code accurately and efficiently”.
            code accurately and efficiently”.
                                                 --Dave Thomas
                                                  --Dave Thomas
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 1: Separare le logiche
   ////class Department Department
                      ////class
        class Department Department
                           class                       Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
                      public void printSlips() {{
   public void printSlips() {{ printSlips()
                        public void
     public void printSlips()
                             Resource eachResource = null;
          Resource resource = null;
                              Resource eachResource = null;
           Resource resource = null;
                             List inforces = new ArrayList();
          for(int i=0; i i< _resources.size();i++) {{
                              List inforces = new ArrayList();
           for(int i=0; < _resources.size();i++)
                resource for(int i=0; i i< _resources.size();i++) {{
                 resource= (Resource)_resources.get(i);
                              for(int i=0; < _resources.size();i++)
                              = (Resource)_resources.get(i);
Selezione?                         eachResource = (Resource)_resources.get(i);
                if(resource.lastContract().deadline().after(new Date())) {{
                                    eachResource = (Resource)_resources.get(i);
 Selezione?      if(resource.lastContract().deadline().after(new Date()))
                                   if(eachResource.lastContract().deadline().after(new Date()) )){{
                      System.out.println(resource.name()); Stampa busta?
                                    if(eachResource.lastContract().deadline().after(new Date())
                       System.out.println(resource.name()); Stampa busta?
                                               inforces.add(eachResource);
                      System.out.println(resource.salary());
                                                inforces.add(eachResource);
                       System.out.println(resource.salary());
                }}                 }}
          }}                 }}
   }}                        Resource eachInForce = null;
                              Resource eachInForce = null;
                             for(int i=0; i i< inforces.size();i++) {{
                              for(int i=0; < inforces.size();i++)
                                   eachInForce = (Resource)inforces.get(i);
                                    eachInForce = (Resource)inforces.get(i);
                                   System.out.println(eachInForce.name());
                                    System.out.println(eachInForce.name());
                                   System.out.println(eachInForce.salary());
                                    System.out.println(eachInForce.salary());

                           }}
 Francesco Cirillo – }}
                     francesco.cirillo@metodiagili.it- MetodiAgili.it
 Javaday Roma - 01/12/2007
Step 2: Semplificare il FOR
 ////class Department
      class Department                            Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
 public void printSlips() {{
   public void printSlips()
        ……
        ……
        Resource eachInForce = null;
         Resource eachInForce = null;
        for(int i=0; i i< inforces.size();i++) {{
         for(int i=0; < inforces.size();i++)                  Ciclo ++navigazione
                                                               Ciclo navigazione
              eachInForce = (Resource)inforces.get(i);
               eachInForce = (Resource)inforces.get(i);
              System.out.println(eachInForce.name());
               System.out.println(eachInForce.name()); Logica i-esima   i-
              System.out.println(eachInForce.salary()); Logica i-esima
               System.out.println(eachInForce.salary());
        }}
 }}
            new Block() {{
             new Block()
                  public void evaluate(Resource each) {{
                   public void evaluate(Resource each)
                        System.out.println(each.name());
                         System.out.println(each.name());
                        System.out.println(each.salary());
                         System.out.println(each.salary());
                  }}.evaluate(eachInForce);
                   }}.evaluate(eachInForce);

Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 2: Semplificare il FOR
 ////class Department
      class Department                            Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
 public void printSlips() {{
   public void printSlips()
        ……
        ……
        Resource eachInForce = null;
         Resource eachInForce = null;
        for(int i=0; i i< inforces.size();i++) {{
         for(int i=0; < inforces.size();i++)                  Ciclo ++navigazione
                                                               Ciclo navigazione
              eachInForce = (Resource)inforces.get(i);
               eachInForce = (Resource)inforces.get(i);
               new Block() {{
                new Block()
                   public void evaluate(Resource each) {{
                    public void evaluate(Resource each)
                                                                       Logica i-i-esima
                                                                        Logicai-esima
                          System.out.println(each.name());
                           System.out.println(each.name());
                          System.out.println(each.salary());
                           System.out.println(each.salary());
                   }}.evaluate(eachInForce);
                    }}.evaluate(eachInForce);
        }}
 }}




Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 2: Semplificare il FOR
 ////class Department
      class Department                            Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
 public void printSlips() {{
   public void printSlips()
        ……
        ……
        Resource eachInForce = null;
         Resource eachInForce = null;
                                                              Ciclo ++navigazione
        for(int i=0; i i< inforces.size();i++) {{
         for(int i=0; < inforces.size();i++)                   Ciclo navigazione

              eachInForce = (Resource)inforces.get(i);
               eachInForce = (Resource)inforces.get(i);
              new PrintSlip().evaluate(eachInForce); Logica i-i-esima
               new PrintSlip().evaluate(eachInForce); Logicai-esima
        }}
 }}

                                         public class PrintSlip implements Block {{
                                          public class PrintSlip implements Block
                                             public void evaluate(Resource aResource) {{
                                              public void evaluate(Resource aResource)
                                                   System.out.println(aResource.name());
                                                   System.out.println(aResource.name());
                                                   System.out.println(aResource.salary());
                                                   System.out.println(aResource.salary());
                                             }}
                                         }}
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 3: Eliminare il FOR
 ////class Department
      class Department                            Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
 public void printSlips() {{
   public void printSlips()
        ……
        ……
        Resource eachInForce = null;
         Resource eachInForce = null;
                                                              Ciclo ++navigazione
        for(int i=0; i i< inforces.size();i++) {{
         for(int i=0; < inforces.size();i++)                   Ciclo navigazione

              eachInForce = (Resource)inforces.get(i);
               eachInForce = (Resource)inforces.get(i);
              new PrintSlip().evaluate(eachInForce); Logica i-i-esima
               new PrintSlip().evaluate(eachInForce); Logicai-esima
        }}
 }}

                                         public class PrintSlip implements Block {{
                                          public class PrintSlip implements Block
                                             public void evaluate(Resource aResource) {{
                                              public void evaluate(Resource aResource)
                                                   System.out.println(aResource.name());
                                                   System.out.println(aResource.name());
                                                   System.out.println(aResource.salary());
                                                   System.out.println(aResource.salary());
                                             }}
                                         }}
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 3: Eliminare il FOR
 ////class Department
      class Department                           Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
 public void printSlips() {{
   public void printSlips()
        ……
        ……
        Iterator iterator = inforces.iterator();
         Iterator iterator = inforces.iterator();                  Ciclo
                                                                    Ciclo
        while(iterator.hasNext()) {{
         while(iterator.hasNext())
              new PrintSlip().evaluate(iterator.next()); Logica i-i-esima
               new PrintSlip().evaluate(iterator.next()); Logicai-esima
        }}
 }}


                                         public class PrintSlip implements Block {{
                                          public class PrintSlip implements Block
                                             public void evaluate(Resource aResource) {{
                                              public void evaluate(Resource aResource)
                                                   System.out.println(aResource.name());
                                                   System.out.println(aResource.name());
                                                   System.out.println(aResource.salary());
                                                   System.out.println(aResource.salary());
                                             }}
                                         }}
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 3: Eliminare il FOR
 ////class Department
      class Department                           Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
 public void printSlips(…) {{
   public void printSlips(…)
        ……
        ……
        Iterator iterator = inforces.iterator();
         Iterator iterator = inforces.iterator();                  Ciclo
                                                                    Ciclo
        while(iterator.hasNext()) {{
         while(iterator.hasNext())
              aBlock.evaluate(iterator.next());
               aBlock.evaluate(iterator.next());              Logica i-i-esima
                                                               Logicai-esima
        }}
 }}


                                         public class PrintSlip implements Block {{
                                          public class PrintSlip implements Block
                                             public void evaluate(Resource aResource) {{
                                              public void evaluate(Resource aResource)
                                                   System.out.println(aResource.name());
                                                   System.out.println(aResource.name());
                                                   System.out.println(aResource.salary());
                                                   System.out.println(aResource.salary());
                                             }}
                                         }}
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 3: Eliminare il FOR
 public class ResourceOrderedCollection {{
  public class ResourceOrderedCollection
      private Collection _items;
       private Collection _items;                   Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License


       public ResourceOrderedCollection(Collection items) {{
        public ResourceOrderedCollection(Collection items)             Navigazione
                                                                        Navigazione
            _items ==items;
             _items items;
       }}

      public void forEachDo(Block aBlock) {{
       public void forEachDo(Block aBlock)
            Iterator iterator ==_items.iterator();
             Iterator iterator _items.iterator();                             Ciclo
                                                                               Ciclo
            while(iterator.hasNext()) {{
             while(iterator.hasNext())
                   aBlock.evaluate((Resource)iterator.next());
                    aBlock.evaluate((Resource)iterator.next());
            }}
      }}                public void printSlips() {{
                         public void printSlips()
 }}                           Resource eachResource ==null;
                               Resource eachResource null;
                              List inforces ==new ArrayList();
                               List inforces new ArrayList();
                              for(int i=0; i i<<_resources.size();i++) {{
                               for(int i=0; _resources.size();i++)
                                     eachResource ==(Resource)_resources.get(i);
                                      eachResource (Resource)_resources.get(i);
                                           if(eachResource.lastContract().deadline().after(new Date()) ) ){{
                                              if(eachResource.lastContract().deadline().after(new Date())
                                                                          inforces.add(eachResource);
                                                                           inforces.add(eachResource);
                                           }}
                                     }}
                                     new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
                                      new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
                              }}
Javaday Roma - 01/12/2007
Step 4: E la selezione
   public void printSlips() {{
    public void printSlips()                                      Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
                 Resource eachResource ==null;
                  Resource eachResource null;
                 List inforces ==new ArrayList();
                  List inforces new ArrayList();                             Ciclo ++navigazione
                                                                              Ciclo navigazione
                 for(int i=0; i i<<_resources.size();i++) {{
                  for(int i=0; _resources.size();i++)
                        eachResource ==(Resource)_resources.get(i);
                         eachResource (Resource)_resources.get(i);
                        if(eachResource.lastContract().deadline().after(new Date()) ) ){{                Selezione
                                                                                                          Selezione
Logica i-i-esima
 Logicai-esima           if(eachResource.lastContract().deadline().after(new Date())
                               inforces.add(eachResource);
                                 inforces.add(eachResource);                    Addizione
                                                                                 Addizione
                        }}
                 }} public void printSlips() {{
                     public void printSlips()
                 new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
                                   Resource eachResource ==null;
                  new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
                                    Resource eachResource null;
           }}                      List inforces ==new ArrayList();
                                    List inforces new ArrayList();
                                   for(int i=0; i i<<_resources.size();i++) {{
                                    for(int i=0; _resources.size();i++)
                                          eachResource ==(Resource)_resources.get(i);
                                           eachResource (Resource)_resources.get(i);
                                          if(new PredicateBlock() {{
                                           if(new PredicateBlock()
                                                public boolean is(Resource each) {{
                                                   public boolean is(Resource each)
                                                         return each.lastContract().deadline().after(new Date());
                                                          return each.lastContract().deadline().after(new Date());
                                                }}.is(eachResource) {{
                                                   }}.is(eachResource)
                                                inforces.add(eachResource);
                                                   inforces.add(eachResource);
                                          }}
                                   }}
                                   new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
                                    new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
  Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
                            }}
  Javaday Roma - 01/12/2007
Step 4: E la selezione
public void printSlips() {{
 public void printSlips()                              Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
           Resource eachResource ==null;
            Resource eachResource null;
           List inforces ==new ArrayList();
            List inforces new ArrayList();              Ciclo ++navigazione
                                                         Ciclo navigazione
           for(int i=0; i i<<_resources.size();i++) {{
            for(int i=0; _resources.size();i++)
                  eachResource ==(Resource)_resources.get(i);
                   eachResource (Resource)_resources.get(i);
                  if(new InForcePredicate().is(eachResource)) {{
                   if(new InForcePredicate().is(eachResource))
                        inforces.add(eachResource);
                           inforces.add(eachResource);                   Addizione
                                                                          Addizione
                  }}
           }}
           new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
            new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
     }}



             public class InForcePredicate implements PredicateBlock {{
              public class InForcePredicate implements PredicateBlock
                  public boolean is(Resource each) {{
                   public boolean is(Resource each)                                          Selezione
                                                                                              Selezione
                        return each.lastContract().deadline().after(new Date());
                         return each.lastContract().deadline().after(new Date());
                  }}
             }}


Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 4: E la selezione
public void printSlips() {{
 public void printSlips()                      Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
           Collection inforces ==new ResourceOrderedCollection(_resources).select(new InForce());
            Collection inforces new ResourceOrderedCollection(_resources).select(new InForce());
           new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
            new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
     }}

  public Collection select(PredicateBlock aBlock) {{
   public Collection select(PredicateBlock aBlock)
             Collection result ==new ArrayList();
              Collection result new ArrayList();
             Iterator iterator ==_items.iterator();
              Iterator iterator _items.iterator();            Navigazione
                                                               Navigazione
             while(iterator.hasNext()) {{                                        Ciclo
                                                                                  Ciclo
              while(iterator.hasNext())
                   Resource resource ==(Resource)iterator.next();
                     Resource resource (Resource)iterator.next();
                   ifif(aBlock.is(resource)) result.add(resource);
                        (aBlock.is(resource)) result.add(resource);          Addizione
                                                                              Addizione
             }}
             return result;
              return result;
       }}


                      public class InForcePredicate implements PredicateBlock {{
                       public class InForcePredicate implements PredicateBlock
                           public boolean is(Resource each) {{
                            public boolean is(Resource each)                                  Selezione
                                                                                               Selezione
                                  return each.lastContract().deadline().after(new Date());
                                   return each.lastContract().deadline().after(new Date());
                           }}
                      }}
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 5: Per leggere meglio
public void printSlips() {{
 public void printSlips()                              Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
     Collection inforces ==new ResourceOrderedCollection(_resources).select(new InForce());
      Collection inforces new ResourceOrderedCollection(_resources).select(new InForce());
     new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
      new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip());
}} public void printSlips() {
    public void printSlips() {
         (new ResourceOrderedCollection(_resources).select(new InForce()).forEachDo(new PrintSlip());
          (new ResourceOrderedCollection(_resources).select(new InForce()).forEachDo(new PrintSlip());
   }} public ResourceOrderedCollection select(PredicateBlock aBlock) {
          public ResourceOrderedCollection select(PredicateBlock aBlock) {
               ResourceOrderedCollection result ==new ResourceOrderedCollection();
                ResourceOrderedCollection result new ResourceOrderedCollection();
               Iterator iterator ==_items.iterator();
                Iterator iterator _items.iterator();
               while(iterator.hasNext()) {{
                while(iterator.hasNext())
                     Resource resource ==(Resource)iterator.next();
                       Resource resource (Resource)iterator.next();
                     ifif(aBlock.is(resource)) result.add(resource);
                          (aBlock.is(resource)) result.add(resource);
               }}
               return result;
                return result;
        }}
public void printSlips() {{
 public void printSlips()
            Predicate isInForce ==new InForce();
             Predicate isInForce new InForce();
            Block printSlip ==new PrintSlip();
             Block printSlip new PrintSlip();
            ResourceOrderedCollection resources ==new ResourceOrderedCollection(_resources);
             ResourceOrderedCollection resources new ResourceOrderedCollection(_resources);
            resources.select(isInForce).forEachDo(printSlip);
             resources.select(isInForce).forEachDo(printSlip);
}}
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 5: Per leggere meglio
  public void printSlips() {{
   public void printSlips()                       Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
             Predicate isInForce ==new InForce();
              Predicate isInForce new InForce();
             Block printSlip ==new PrintSlip();
              Block printSlip new PrintSlip();
             ResourceOrderedCollection resources ==new ResourceOrderedCollection(_resources);
              ResourceOrderedCollection resources new ResourceOrderedCollection(_resources);
             resources.select(isInForce).forEachDo(printSlip);
              resources.select(isInForce).forEachDo(printSlip);
  }}

     public void printSlips() {{
      public void printSlips()
          printSlipsUsing(new InForce(),new PrintSlip());
            printSlipsUsing(new InForce(),new PrintSlip());
     }}
           private void printSlipsUsing(Predicate aCriterium, Block anAction) {{
            private void printSlipsUsing(Predicate aCriterium, Block anAction)
                 new ResourceOrderedCollection(_resources).select(aCriterium).forEachDo(anAction);
                  new ResourceOrderedCollection(_resources).select(aCriterium).forEachDo(anAction);
           }}


     public void printSlipsUsing(Predicate aCriterium, Block anAction) {{
      public void printSlipsUsing(Predicate aCriterium, Block anAction)
          _resources.select(aCriterium).forEachDo(anAction);
           _resources.select(aCriterium).forEachDo(anAction);
     }}
             private ResourceOrderedCollection _resources;
              private ResourceOrderedCollection _resources;


Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 6: Generalizzare
    new ResourceOrderedCollection(resources).select(isInForce).forEachDo(printSlip);
                                       Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
     new ResourceOrderedCollection(resources).select(isInForce).forEachDo(printSlip);
 public class ResourceOrderedCollection { {
  public class ResourceOrderedCollection
       ……
       public void forEachDo(Block aBlock) { {
        public void forEachDo(Block aBlock)
              Iterator iterator ==_items.iterator();
                Iterator iterator _items.iterator();
              while(iterator.hasNext()) { {                               public class PrintSlip implements Block { {
                                                                           public class PrintSlip implements Block
                while(iterator.hasNext())
                      aBlock.evaluate((Resource)iterator.next());                public void evaluate(Resource aResource) { {
                                                                                  public void evaluate(Resource aResource)
                        aBlock.evaluate((Resource)iterator.next());
              }}                                                                       System.out.println(aResource.name());
                                                                                        System.out.println(aResource.name());
       }}                                                                              System.out.println(aResource.salary());
                                                                                        System.out.println(aResource.salary());
       public ResourceOrderedCollection select(Predicate aBlock) { {             }}
        public ResourceOrderedCollection select(Predicate aBlock)
              ResourceOrderedCollection result ==
                ResourceOrderedCollection result                          }}
                      new ResourceOrderedCollection();
                        new ResourceOrderedCollection();
              Iterator iterator ==_items.iterator();
                Iterator iterator _items.iterator();
              while(iterator.hasNext()) { {
                while(iterator.hasNext())
                      Resource resource ==(Resource)iterator.next();
                        Resource resource (Resource)iterator.next();
                      ifif(aBlock.is(resource)) result.add(resource);
                           (aBlock.is(resource)) result.add(resource);
              }}
              return result;
                return result;
       }}                                                    public class InForcePredicate implements PredicateBlock { {
                                                              public class InForcePredicate implements PredicateBlock
 }}                                                                public boolean is(Resource each) { {
                                                                    public boolean is(Resource each)
                                                                          return each.lastContract().deadline().after(new Date());
                                                                           return each.lastContract().deadline().after(new Date());
                                                                   }}
                                                             }}
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Step 6: Generalizzare
     new ResourceOrderedCollection(resources).select(isInForce).forEachDo(printSlip);
                                        Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
      new ResourceOrderedCollection(resources).select(isInForce).forEachDo(printSlip);
 public class ResourceOrderedCollection { {
  public class ResourceOrderedCollection
       …                                                                 public class OrderedCollection { {
                                                                          public class OrderedCollection
         …                                                                     ……
       public void forEachDo(Block aBlock) {class InForcePredicate implements Predicate {
         public void forEachDo(Block aBlock) {class InForcePredicate implements Predicate {
                                           public
                                            public                             public void forEachDo(Block aBlock) { {
              Iterator iterator ==_items.iterator(); boolean is(Object anObject) { forEachDo(Block aBlock)
                                                                                public void
                Iterator iterator _items.iterator(); boolean is(Object anObject) { iterator = _items.iterator();
                                                   public
              while(iterator.hasNext()) { {         public                            Iterator iterator = _items.iterator();
                                                                                        Iterator
                while(iterator.hasNext())                 return ((Resource)anObject).lastContract().deadline().after(new Date());
                                                                                      while(iterator.hasNext()) { {
                                                           return ((Resource)anObject).lastContract().deadline().after(new Date());
                      aBlock.evaluate((Resource)iterator.next());
                        aBlock.evaluate((Resource)iterator.next());                     while(iterator.hasNext())
                                                   }}                                         aBlock.evaluate(iterator.next());
              }}                                                                                aBlock.evaluate(iterator.next());
                                           }}                                         }}
       }}
       public class PrintSlip implements Block {
       public ResourceOrderedCollection Block {
         public class PrintSlip implements                                     }}
         public ResourceOrderedCollectionselect(Predicate aBlock) { { public OrderedCollection select(Predicate aBlock) {
                                                 select(Predicate aBlock)
              public void evaluate(Resource aResource) { {
                public void evaluate(Resource aResource)
              ResourceOrderedCollection result ==                               public OrderedCollection select(Predicate aBlock) {
                ResourceOrderedCollection result
                      System.out.println(aResource.name());                           OrderedCollection result ==
                        System.out.println(aResource.name());
                      new ResourceOrderedCollection();                                  OrderedCollection result
                        new ResourceOrderedCollection();
                      System.out.println(aResource.salary());                                 new OrderedCollection();
              Iterator System.out.println(aResource.salary());
                Iteratoriterator ==_items.iterator();
                           iterator _items.iterator();                                          new OrderedCollection();
              }}
              while(iterator.hasNext()) { {                                           Iterator iterator ==_items.iterator();
                                                                                        Iterator iterator _items.iterator();
       }}       while(iterator.hasNext())                                             while(iterator.hasNext()) { {
                      Resource resource ==(Resource)iterator.next();                    while(iterator.hasNext())
                        Resource resource (Resource)iterator.next(); PrintSlip implements Block { = iterator.next();
                                                               public class PrintSlip implements object { = iterator.next();
                      ifif(aBlock.is(resource)) result.add(resource);
                                                                public class                  Object Block
                                                                                                Object object
                            (aBlock.is(resource)) result.add(resource);
              }}                                                     public void evaluate(Object anObject) { { result.add(object);
                                                                                              ifif(aBlock.is(object)) result.add(object);
                                                                                                   (aBlock.is(object))
                                                                      public void evaluate(Object anObject)
              return result;                                                          }}
                                                                            System.out.println(((Resource)anObject).name());
                return result;                                               System.out.println(((Resource)anObject).name());
                                                                                      return result;
       }}                                                                   System.out.println(((Resource)anObject).salary());}
                                                                                        return result;
                                                                             System.out.println(((Resource)anObject).salary());}
 }}                                                            }}              }}
 public class InForcePredicate implements PredicateBlock { { }
  public class InForcePredicate implements PredicateBlock
       public boolean is(Resource each) { {                               }
         public boolean is(Resource each)
              return each.lastContract().deadline().after(new Date());
                return each.lastContract().deadline().after(new Date());
       } } Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Francesco
 }}
Javaday Roma - 01/12/2007
Dove siamo
    ////class Department
         class Department                          Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
    public void printSlips() {{
      public void printSlips()
           Resource resource = null;
            Resource resource = null;                    Navigazione?
                                                          Navigazione?
           for(int i=0; i i< _resources.size();i++) {{
            for(int i=0; < _resources.size();i++)
                 resource = (Resource)_resources.get(i);
                  resource = (Resource)_resources.get(i);
Selezione?
 Selezione?      if(resource.lastContract().deadline().after(new Date())) {{
                  if(resource.lastContract().deadline().after(new Date()))
                       System.out.println(resource.name()); Contenuti?
                        System.out.println(resource.name()); Contenuti?
         Media?
          Media?
                       System.out.println(resource.salary());
                        System.out.println(resource.salary());
                 }}
           }}
                                        Layout?
                                         Layout?
    }}

                          _resources.select(onlyWomen).forEachDo(printReport);
                          _resources.select(isInForce).forEachDo(printSlip);
                           _resources.select(onlyWomen).forEachDo(printReport);
                           _resources.select(isInForce).forEachDo(printSlip);

                                                                               Contenuti+
                                                                                Contenuti+
                             Navigazione
                              Navigazione           Selezione
                                                     Selezione                   Media+
                                                                                  Media+
                                                                                 Layout
                                                                                  Layout

  Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
  Javaday Roma - 01/12/2007
////class Department
       class Department
  public void printSlips() { {
                  Review & ToDoList
    public void printSlips()
           Resource resource ==null;
            Resource resource null;
           for(int i=0; i i<<_resources.size();i++) { {
            for(int i=0; _resources.size();i++)
                                                                  Navigazione?
                                                                   Navigazione?

                    resource ==(Resource)_resources.get(i);
                      resource (Resource)_resources.get(i);
Selezione?
 Selezione?         if(resource.lastContract().deadline().after(new Date())) { {
                      if(resource.lastContract().deadline().after(new Date()))
                             System.out.println(resource.name());
                              System.out.println(resource.name());       Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
            Media?           System.out.println(resource.salary());       Contenuti?
                                                                           Contenuti?
             Media?           System.out.println(resource.salary());
                    }}
           }}
  }}
                                       Layout?
                                        Layout?


                                                                               10/01-10/11/2007:Contract


                                                                           Andrea:Employee

                                                                                    “Andrea”:String
                      :Department
                                                                            Federica:Manager

                                                                                             1/9/2007-10/10/2008:Contract


                                                                                        “Federica”:String
                                         System.out:PrintStream



 Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
 Javaday Roma - 01/12/2007
Review & ToDoList
public OrderedCollection select(Predicate aBlock) { {
 public OrderedCollection select(Predicate aBlock)
       OrderedCollection result ==new                      publicCreative Commons Attribution-NonCommercial-ShareAlike 2.5 License
         OrderedCollection result new
OrderedCollection();                                        publicboolean is(Object each) { {
                                                                   boolean is(Object each)
 OrderedCollection();
   _resources.select(isInForce).forEachDo(printSlip);            return ((Resource)each).lastContract().deadline().after(new Date());
                                                                  return ((Resource)each).lastContract().deadline().after(new Date());
    _resources.select(isInForce).forEachDo(printSlip);
       Iterator iterator ==_items.iterator();
         Iterator iterator _items.iterator();              }}
       while(iterator.hasNext()) { {
         while(iterator.hasNext())
               Object object ==iterator.next();
                 Object object iterator.next();
               ifif(aBlock.is(object)) result.add(object);
                    (aBlock.is(object)) result.add(object);
       }}
       return result;                                                          10/01-10/11/2007:Contract
         return result;
}}

                             resources:OrderedCollection                 Andrea:Employee

                                                      :InForce                    “Andrea”:String
                     :Department
                                   inForce:OrderedCollection              Federica:Manager

                                                                                          1/9/2007-10/10/2008:Contract
                                                       :PrintSlip

                                                                                     “Federica”:String

                                        System.out:PrintStream


Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Review & ToDoList
                                                            public OrderedCollection select(Predicate aBlock) { {
                                                             public class PrintSlip implements Block { { aBlock)
                                                             public OrderedCollection select(Predicate
                                                                   OrderedCollection result ==new
                                                               public class PrintSlip implements Block
    public void forEachDo(Block aBlock) { {
     public void forEachDo(Block aBlock)                            public void evaluate(Objectnew
                                                                     OrderedCollection result anObject) {
                                                              Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License
                                                            OrderedCollection();
                                                                      public void evaluate(Object anObject) {
          Iterator iterator ==_items.iterator();
            Iterator iterator _items.iterator();             OrderedCollection();
                                                                   IteratorSystem.out.println(((Resource)anObject).name());
                                                                     Iteratoriterator ==_items.iterator();
                                                                               System.out.println(((Resource)anObject).name());
                                                                                iterator _items.iterator();
          while(iterator.hasNext()) { {
            while(iterator.hasNext())                                        System.out.println(((Resource)anObject).salary());
                                                                   while(iterator.hasNext()) { {
                                                                               System.out.println(((Resource)anObject).salary());
                                                                     while(iterator.hasNext())
                  aBlock.evaluate(iterator.next());
                   aBlock.evaluate(iterator.next());                } } Object object ==iterator.next();
                                                                             Object object iterator.next();
          }}                                                 }}            ifif(aBlock.is(object)) result.add(object);
    }}                                                                           (aBlock.is(object)) result.add(object);
                                                                   }}
                                                                   return result;
                                                                     return result;
                                                                                  10/01-10/11/2007:Contract
                                                            }}


                            resources:OrderedCollection                 Andrea:Employee

                                                       :InForce                 “Andrea”:String
                   :Department
                                  inForce:OrderedCollection              Federica:Manager

                                                                                        1/9/2007-10/10/2008:Contract
                                                        :PrintSlip

                                                                                   “Federica”:String

                                      System.out:PrintStream


Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Riferimenti blocchi e
              chiusure
                                                     Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License

     Blocchi in Java
       −   http://www.c2.com/cgi/wiki?BlocksInJava
     Blocchi e chiusure in Ruby
       −   http://www.artima.com/intv/closuresP.html
     Chiusure nel linguaggio Java
       −   http://www.javac.info/closures-v03.html
     Esempi di librerie
       −   http://jaggregate.sourceforge.net

Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Segui la Campagna Anti-IF
                                                     Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License




Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007
Domande
                                                     Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License

  Risorse:
     http://www.xplabs.it/risorse.html
     http://www.metodiagili.it/campagna-anti-if.html

  Tecnica del Pomodoro:
     http://www.tecnicadelpomodoro.it

  EasyTracking:
     http://www.myagileprojects.com

  Gruppo XPLabs’ Friends- Italia:
     http://it.groups.yahoo.com/group/xplabs-friends/

  Extreme Programming User Group – Italia:
     http://www.xpug.it/
Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it
Javaday Roma - 01/12/2007

Más contenido relacionado

La actualidad más candente

The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsBaruch Sadogursky
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch
 
Python 표준 라이브러리
Python 표준 라이브러리Python 표준 라이브러리
Python 표준 라이브러리용 최
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIjagriti srivastava
 
The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.5.2 book - Part 76 of 181The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.5.2 book - Part 76 of 181Mahmoud Samir Fayed
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...julien.ponge
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202Mahmoud Samir Fayed
 
Clojure: The Art of Abstraction
Clojure: The Art of AbstractionClojure: The Art of Abstraction
Clojure: The Art of AbstractionAlex Miller
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeDaniel Wellman
 
Programming Java - Lection 04 - Generics and Lambdas - Lavrentyev Fedor
Programming Java - Lection 04 - Generics and Lambdas - Lavrentyev FedorProgramming Java - Lection 04 - Generics and Lambdas - Lavrentyev Fedor
Programming Java - Lection 04 - Generics and Lambdas - Lavrentyev FedorFedor Lavrentyev
 

La actualidad más candente (20)

The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
 
Into Clojure
Into ClojureInto Clojure
Into Clojure
 
Object - Based Programming
Object - Based ProgrammingObject - Based Programming
Object - Based Programming
 
Python 표준 라이브러리
Python 표준 라이브러리Python 표준 라이브러리
Python 표준 라이브러리
 
Java File
Java FileJava File
Java File
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
 
The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.5.2 book - Part 76 of 181The Ring programming language version 1.5.2 book - Part 76 of 181
The Ring programming language version 1.5.2 book - Part 76 of 181
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Clojure: The Art of Abstraction
Clojure: The Art of AbstractionClojure: The Art of Abstraction
Clojure: The Art of Abstraction
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
How to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy CodeHow to Start Test-Driven Development in Legacy Code
How to Start Test-Driven Development in Legacy Code
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
 
Programming Java - Lection 04 - Generics and Lambdas - Lavrentyev Fedor
Programming Java - Lection 04 - Generics and Lambdas - Lavrentyev FedorProgramming Java - Lection 04 - Generics and Lambdas - Lavrentyev Fedor
Programming Java - Lection 04 - Generics and Lambdas - Lavrentyev Fedor
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
 
Clojure class
Clojure classClojure class
Clojure class
 
L03 Software Design
L03 Software DesignL03 Software Design
L03 Software Design
 

Destacado

Getting Things Done and the Pomodoro Technique
Getting Things Done and the Pomodoro TechniqueGetting Things Done and the Pomodoro Technique
Getting Things Done and the Pomodoro TechniqueQaiser Mazhar
 
Getting things done presentation
Getting things done presentationGetting things done presentation
Getting things done presentationSameer Mathur
 
GTD Getting things done presentation 06-2015
GTD Getting things done presentation 06-2015GTD Getting things done presentation 06-2015
GTD Getting things done presentation 06-2015Raphael Monteiro
 
Getting Things Done - David Allen - Book Summary -Chapters 1-6
Getting Things Done - David Allen - Book Summary -Chapters 1-6Getting Things Done - David Allen - Book Summary -Chapters 1-6
Getting Things Done - David Allen - Book Summary -Chapters 1-6Sameer Mathur
 
Getting Things Done (GTD) by David Allen
Getting Things Done (GTD) by David AllenGetting Things Done (GTD) by David Allen
Getting Things Done (GTD) by David AllenDanny Holtschke
 
GTD 101 - Getting Things Done
GTD 101 - Getting Things DoneGTD 101 - Getting Things Done
GTD 101 - Getting Things DoneDerek Neighbors
 
Getting Things Done with "Getting Things Done"
Getting Things Done with "Getting Things Done"Getting Things Done with "Getting Things Done"
Getting Things Done with "Getting Things Done"Pongsakorn U-chupala
 

Destacado (7)

Getting Things Done and the Pomodoro Technique
Getting Things Done and the Pomodoro TechniqueGetting Things Done and the Pomodoro Technique
Getting Things Done and the Pomodoro Technique
 
Getting things done presentation
Getting things done presentationGetting things done presentation
Getting things done presentation
 
GTD Getting things done presentation 06-2015
GTD Getting things done presentation 06-2015GTD Getting things done presentation 06-2015
GTD Getting things done presentation 06-2015
 
Getting Things Done - David Allen - Book Summary -Chapters 1-6
Getting Things Done - David Allen - Book Summary -Chapters 1-6Getting Things Done - David Allen - Book Summary -Chapters 1-6
Getting Things Done - David Allen - Book Summary -Chapters 1-6
 
Getting Things Done (GTD) by David Allen
Getting Things Done (GTD) by David AllenGetting Things Done (GTD) by David Allen
Getting Things Done (GTD) by David Allen
 
GTD 101 - Getting Things Done
GTD 101 - Getting Things DoneGTD 101 - Getting Things Done
GTD 101 - Getting Things Done
 
Getting Things Done with "Getting Things Done"
Getting Things Done with "Getting Things Done"Getting Things Done with "Getting Things Done"
Getting Things Done with "Getting Things Done"
 

Similar a Eliminating FOR Loops in Java Code

A brief overview of java frameworks
A brief overview of java frameworksA brief overview of java frameworks
A brief overview of java frameworksMD Sayem Ahmed
 
Ekoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's MethodologyEkoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's Methodologybugcrowd
 
Next.ml Boston: Data Science Dev Ops
Next.ml Boston: Data Science Dev OpsNext.ml Boston: Data Science Dev Ops
Next.ml Boston: Data Science Dev OpsEric Chiang
 
200612_BioPackathon_ss
200612_BioPackathon_ss200612_BioPackathon_ss
200612_BioPackathon_ssSatoshi Kume
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?Ben Hall
 
Working with the Scalding Type-Safe API
Working with the Scalding Type-Safe API Working with the Scalding Type-Safe API
Working with the Scalding Type-Safe API Criteolabs
 
Manipulating object-behavior-at-runtime
Manipulating object-behavior-at-runtimeManipulating object-behavior-at-runtime
Manipulating object-behavior-at-runtimeAndrei Ursan
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Refactoring legacy code guided by tests in WordPress
Refactoring legacy code guided by tests in WordPressRefactoring legacy code guided by tests in WordPress
Refactoring legacy code guided by tests in WordPressLuca Tumedei
 
Php interview-questions and answers
Php interview-questions and answersPhp interview-questions and answers
Php interview-questions and answerssheibansari
 
Crm saturday madrid 2017 jordi montaña - test automation
Crm saturday madrid 2017   jordi montaña - test automationCrm saturday madrid 2017   jordi montaña - test automation
Crm saturday madrid 2017 jordi montaña - test automationDemian Raschkovan
 

Similar a Eliminating FOR Loops in Java Code (20)

A brief overview of java frameworks
A brief overview of java frameworksA brief overview of java frameworks
A brief overview of java frameworks
 
Ekoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's MethodologyEkoparty 2017 - The Bug Hunter's Methodology
Ekoparty 2017 - The Bug Hunter's Methodology
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
Next.ml Boston: Data Science Dev Ops
Next.ml Boston: Data Science Dev OpsNext.ml Boston: Data Science Dev Ops
Next.ml Boston: Data Science Dev Ops
 
L04 Software Design 2
L04 Software Design 2L04 Software Design 2
L04 Software Design 2
 
200612_BioPackathon_ss
200612_BioPackathon_ss200612_BioPackathon_ss
200612_BioPackathon_ss
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?
 
6tips web-perf
6tips web-perf6tips web-perf
6tips web-perf
 
Introduction to Domain-Driven Design
Introduction to Domain-Driven DesignIntroduction to Domain-Driven Design
Introduction to Domain-Driven Design
 
SCALA - Functional domain
SCALA -  Functional domainSCALA -  Functional domain
SCALA - Functional domain
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Working with the Scalding Type -Safe API
Working with the Scalding Type -Safe APIWorking with the Scalding Type -Safe API
Working with the Scalding Type -Safe API
 
Working with the Scalding Type-Safe API
Working with the Scalding Type-Safe API Working with the Scalding Type-Safe API
Working with the Scalding Type-Safe API
 
oops-1
oops-1oops-1
oops-1
 
Unit i
Unit iUnit i
Unit i
 
Manipulating object-behavior-at-runtime
Manipulating object-behavior-at-runtimeManipulating object-behavior-at-runtime
Manipulating object-behavior-at-runtime
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Refactoring legacy code guided by tests in WordPress
Refactoring legacy code guided by tests in WordPressRefactoring legacy code guided by tests in WordPress
Refactoring legacy code guided by tests in WordPress
 
Php interview-questions and answers
Php interview-questions and answersPhp interview-questions and answers
Php interview-questions and answers
 
Crm saturday madrid 2017 jordi montaña - test automation
Crm saturday madrid 2017   jordi montaña - test automationCrm saturday madrid 2017   jordi montaña - test automation
Crm saturday madrid 2017 jordi montaña - test automation
 

Más de Francesco Cirillo

20111117 Is Software Evolution really effective? @XPDayGE2011 Karlsruhe-GE [ENG]
20111117 Is Software Evolution really effective? @XPDayGE2011 Karlsruhe-GE [ENG]20111117 Is Software Evolution really effective? @XPDayGE2011 Karlsruhe-GE [ENG]
20111117 Is Software Evolution really effective? @XPDayGE2011 Karlsruhe-GE [ENG]Francesco Cirillo
 
20111119 Is Software Evolution really effective? @IAD2011 Rome-IT [ENG]
20111119 Is Software Evolution really effective? @IAD2011 Rome-IT [ENG]20111119 Is Software Evolution really effective? @IAD2011 Rome-IT [ENG]
20111119 Is Software Evolution really effective? @IAD2011 Rome-IT [ENG]Francesco Cirillo
 
20100506 Dinamiche di Team @BetterSoftware2010 Firenze-IT [ITA]
20100506 Dinamiche di Team @BetterSoftware2010 Firenze-IT [ITA]20100506 Dinamiche di Team @BetterSoftware2010 Firenze-IT [ITA]
20100506 Dinamiche di Team @BetterSoftware2010 Firenze-IT [ITA]Francesco Cirillo
 
20100302 Dinamiche di Team Brainstorming @UniRM3 Roma-IT [ITA]
20100302 Dinamiche di Team Brainstorming @UniRM3 Roma-IT [ITA]20100302 Dinamiche di Team Brainstorming @UniRM3 Roma-IT [ITA]
20100302 Dinamiche di Team Brainstorming @UniRM3 Roma-IT [ITA]Francesco Cirillo
 
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...Francesco Cirillo
 
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]Francesco Cirillo
 
20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]
20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]
20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]Francesco Cirillo
 
20080619 Diventare Agili Dalla Università ad un Team Agile @UniRM3 Roma-IT [ITA]
20080619 Diventare Agili Dalla Università ad un Team Agile @UniRM3 Roma-IT [ITA]20080619 Diventare Agili Dalla Università ad un Team Agile @UniRM3 Roma-IT [ITA]
20080619 Diventare Agili Dalla Università ad un Team Agile @UniRM3 Roma-IT [ITA]Francesco Cirillo
 
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]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
 
20060627 SOA @JavaConference2006 Milano-IT [ITA]
20060627 SOA @JavaConference2006 Milano-IT [ITA]20060627 SOA @JavaConference2006 Milano-IT [ITA]
20060627 SOA @JavaConference2006 Milano-IT [ITA]Francesco Cirillo
 
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]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
 

Más de Francesco Cirillo (17)

20111117 Is Software Evolution really effective? @XPDayGE2011 Karlsruhe-GE [ENG]
20111117 Is Software Evolution really effective? @XPDayGE2011 Karlsruhe-GE [ENG]20111117 Is Software Evolution really effective? @XPDayGE2011 Karlsruhe-GE [ENG]
20111117 Is Software Evolution really effective? @XPDayGE2011 Karlsruhe-GE [ENG]
 
20111119 Is Software Evolution really effective? @IAD2011 Rome-IT [ENG]
20111119 Is Software Evolution really effective? @IAD2011 Rome-IT [ENG]20111119 Is Software Evolution really effective? @IAD2011 Rome-IT [ENG]
20111119 Is Software Evolution really effective? @IAD2011 Rome-IT [ENG]
 
20100506 Dinamiche di Team @BetterSoftware2010 Firenze-IT [ITA]
20100506 Dinamiche di Team @BetterSoftware2010 Firenze-IT [ITA]20100506 Dinamiche di Team @BetterSoftware2010 Firenze-IT [ITA]
20100506 Dinamiche di Team @BetterSoftware2010 Firenze-IT [ITA]
 
20100302 Dinamiche di Team Brainstorming @UniRM3 Roma-IT [ITA]
20100302 Dinamiche di Team Brainstorming @UniRM3 Roma-IT [ITA]20100302 Dinamiche di Team Brainstorming @UniRM3 Roma-IT [ITA]
20100302 Dinamiche di Team Brainstorming @UniRM3 Roma-IT [ITA]
 
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]
 
20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]
20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]
20090124 Ricette per Eliminare gli IF @JavaDay3 Roma-IT [ITA]
 
20080619 Diventare Agili Dalla Università ad un Team Agile @UniRM3 Roma-IT [ITA]
20080619 Diventare Agili Dalla Università ad un Team Agile @UniRM3 Roma-IT [ITA]20080619 Diventare Agili Dalla Università ad un Team Agile @UniRM3 Roma-IT [ITA]
20080619 Diventare Agili Dalla Università ad un Team Agile @UniRM3 Roma-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]
 
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]
 

Último

Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Roland Driesen
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyEthan lee
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...lizamodels9
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageMatteo Carbone
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxpriyanshujha201
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLSeo
 
9599632723 Top Call Girls in Delhi at your Door Step Available 24x7 Delhi
9599632723 Top Call Girls in Delhi at your Door Step Available 24x7 Delhi9599632723 Top Call Girls in Delhi at your Door Step Available 24x7 Delhi
9599632723 Top Call Girls in Delhi at your Door Step Available 24x7 DelhiCall Girls in Delhi
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMANIlamathiKannappan
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayNZSG
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...anilsa9823
 
Progress Report - Oracle Database Analyst Summit
Progress  Report - Oracle Database Analyst SummitProgress  Report - Oracle Database Analyst Summit
Progress Report - Oracle Database Analyst SummitHolger Mueller
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
HONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsHONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsMichael W. Hawkins
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxWorkforce Group
 
A305_A2_file_Batkhuu progress report.pdf
A305_A2_file_Batkhuu progress report.pdfA305_A2_file_Batkhuu progress report.pdf
A305_A2_file_Batkhuu progress report.pdftbatkhuu1
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Lviv Startup Club
 

Último (20)

Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRLMONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
MONA 98765-12871 CALL GIRLS IN LUDHIANA LUDHIANA CALL GIRL
 
9599632723 Top Call Girls in Delhi at your Door Step Available 24x7 Delhi
9599632723 Top Call Girls in Delhi at your Door Step Available 24x7 Delhi9599632723 Top Call Girls in Delhi at your Door Step Available 24x7 Delhi
9599632723 Top Call Girls in Delhi at your Door Step Available 24x7 Delhi
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
It will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 MayIt will be International Nurses' Day on 12 May
It will be International Nurses' Day on 12 May
 
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
Lucknow 💋 Escorts in Lucknow - 450+ Call Girl Cash Payment 8923113531 Neha Th...
 
Progress Report - Oracle Database Analyst Summit
Progress  Report - Oracle Database Analyst SummitProgress  Report - Oracle Database Analyst Summit
Progress Report - Oracle Database Analyst Summit
 
Forklift Operations: Safety through Cartoons
Forklift Operations: Safety through CartoonsForklift Operations: Safety through Cartoons
Forklift Operations: Safety through Cartoons
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
HONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsHONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael Hawkins
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 
A305_A2_file_Batkhuu progress report.pdf
A305_A2_file_Batkhuu progress report.pdfA305_A2_file_Batkhuu progress report.pdf
A305_A2_file_Batkhuu progress report.pdf
 
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
Yaroslav Rozhankivskyy: Три складові і три передумови максимальної продуктивн...
 

Eliminating FOR Loops in Java Code

  • 1. Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Campagna Anti-IF: Java e i linguaggi dinamici, incrementare le potenzialità espressive di Java [“Eliminare” i FOR] Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 2. Campagna Anti-IF Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 3. Obiettivo Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Più potere a Java “senza” i FOR − Paper su come “eliminare” i FOR Esperienza di design evolutivo − Attraverso il refactoring − Usando i principi di design Far vincere qualche maglietta :) Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 4. Sviluppo Java Web: lento! Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License News Aggregator@xpug.it http://it.groups.yahoo.com/group/extremeprogramming-it/message/4485: http://it.groups.yahoo.com/group/extremeprogramming-it/message/4485: …… > E poi detta tutta java a sviluppo web non è così tanto veloce in una > E poi detta tutta java a sviluppo web non è così tanto veloce in una > giornata non si riesce. > giornata non si riesce. su questo no :-) Direi che una prima iterazione con tutte le funzionalita' su questo no :-) Direi che una prima iterazione con tutte le funzionalita' di base in una giornata con 2 coppie si riesce a fare. di base in una giornata con 2 coppie si riesce a fare. > Con Rails in mezza o 1/4 :) ma non entriamo in guerre di religione. > Con Rails in mezza o 1/4 :) ma non entriamo in guerre di religione. Se non si riesce probabilmente le storie non sono state spezzate in modo Se non si riesce probabilmente le storie non sono state spezzate in modo iterativo-incrementale/verticale ;-) iterativo-incrementale/verticale ;-) …… Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 5. Il problema ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() Resource resource = null; Resource resource = null; (resources select: inForce) do: printSlip. (resources select: inForce) do: printSlip. for(int i=0; i i< _resources.size();i++) {{ for(int i=0; < _resources.size();i++) resource = (Resource)_resources.get(i); resource = (Resource)_resources.get(i); if(resource.lastContract().deadline().after(new Date())) {{ if(resource.lastContract().deadline().after(new Date())) System.out.println(resource.name()); System.out.println(resource.name()); System.out.println(resource.salary()); System.out.println(resource.salary()); }} }} public void printSlips() {{ public void printSlips() }} for (Resource eachResource: _resources) {{ for (Resource eachResource: _resources) if(eachResource.lastContract().deadline().after(new Date()) )){{ if(eachResource.lastContract().deadline().after(new Date()) System.out.println(eachResource.name()); System.out.println(eachResource.name()); “Our job is to solve problems, not spoonfeed compilers (…) “Our job is to solve problems, not spoonfeed compilers (…) System.out.println(eachResource.salary()); We need clarity soSystem.out.println(eachResource.salary()); We need clarity sowe can communicate using our code. We we can communicate using our code. We }} value conciseness and the ability to express aarequirement in value conciseness and the ability to express requirement in }} code accurately and efficiently”. code accurately and efficiently”. --Dave Thomas --Dave Thomas Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 6. Parliamo di design ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() Resource resource = null; Resource resource = null; for(int i=0; i i< _resources.size();i++) {{ for(int i=0; < _resources.size();i++) resource = (Resource)_resources.get(i); resource = (Resource)_resources.get(i); if(resource.lastContract().deadline().after(new Date())) {{ if(resource.lastContract().deadline().after(new Date())) System.out.println(resource.name()); System.out.println(resource.name()); System.out.println(resource.salary()); System.out.println(resource.salary()); }} }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 7. Parliamo di design ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() Resource resource = null; Resource resource = null; Ciclo?+Navigazione? Ciclo?+Navigazione? Ciclo?+Navigazione? for(int i=0; i i< _resources.size();i++) {{ for(int i=0; < _resources.size();i++) resource = (Resource)_resources.get(i); resource = (Resource)_resources.get(i); Selezione? Selezione? if(resource.lastContract().deadline().after(new Date())) {{ if(resource.lastContract().deadline().after(new Date())) System.out.println(resource.name()); Contenuti? System.out.println(resource.name()); Contenuti? Media? Media? System.out.println(resource.salary()); System.out.println(resource.salary()); }} }} Layout? Layout? }} public void printSlipForEach() { { public void printSlipForEach() Ciclo? Ciclo? for (Resource eachResource: _resources) { { for (Resource eachResource: _resources) if(eachResource.lastContract().deadline().after(new Date()) ) ){ { if(eachResource.lastContract().deadline().after(new Date()) System.out.println(eachResource.name()); System.out.println(eachResource.name()); System.out.println(eachResource.salary()); System.out.println(eachResource.salary()); }} }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 8. Abbassare la complessità Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Il Refactoring: − Aumentare la capacità del codice di rivelare le Lightweight intenzioni di design, a qualsiasi membro del team, Lightweight alla prima occhiata − Migliorare la struttura interna del sistema, consentendo alle necessarie astrazioni di emergere “Our job is to solve problems, not spoonfeed compilers (…) “Our job is to solve problems, not spoonfeed compilers (…) We need clarity so we can communicate using our code. We We need clarity so we can communicate using our code. We value conciseness and the ability to express aarequirement in value conciseness and the ability to express requirement in code accurately and efficiently”. code accurately and efficiently”. --Dave Thomas --Dave Thomas Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 9. Step 1: Separare le logiche ////class Department Department ////class class Department Department class Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() {{ printSlips() public void public void printSlips() Resource eachResource = null; Resource resource = null; Resource eachResource = null; Resource resource = null; List inforces = new ArrayList(); for(int i=0; i i< _resources.size();i++) {{ List inforces = new ArrayList(); for(int i=0; < _resources.size();i++) resource for(int i=0; i i< _resources.size();i++) {{ resource= (Resource)_resources.get(i); for(int i=0; < _resources.size();i++) = (Resource)_resources.get(i); Selezione? eachResource = (Resource)_resources.get(i); if(resource.lastContract().deadline().after(new Date())) {{ eachResource = (Resource)_resources.get(i); Selezione? if(resource.lastContract().deadline().after(new Date())) if(eachResource.lastContract().deadline().after(new Date()) )){{ System.out.println(resource.name()); Stampa busta? if(eachResource.lastContract().deadline().after(new Date()) System.out.println(resource.name()); Stampa busta? inforces.add(eachResource); System.out.println(resource.salary()); inforces.add(eachResource); System.out.println(resource.salary()); }} }} }} }} }} Resource eachInForce = null; Resource eachInForce = null; for(int i=0; i i< inforces.size();i++) {{ for(int i=0; < inforces.size();i++) eachInForce = (Resource)inforces.get(i); eachInForce = (Resource)inforces.get(i); System.out.println(eachInForce.name()); System.out.println(eachInForce.name()); System.out.println(eachInForce.salary()); System.out.println(eachInForce.salary()); }} Francesco Cirillo – }} francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 10. Step 2: Semplificare il FOR ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() …… …… Resource eachInForce = null; Resource eachInForce = null; for(int i=0; i i< inforces.size();i++) {{ for(int i=0; < inforces.size();i++) Ciclo ++navigazione Ciclo navigazione eachInForce = (Resource)inforces.get(i); eachInForce = (Resource)inforces.get(i); System.out.println(eachInForce.name()); System.out.println(eachInForce.name()); Logica i-esima i- System.out.println(eachInForce.salary()); Logica i-esima System.out.println(eachInForce.salary()); }} }} new Block() {{ new Block() public void evaluate(Resource each) {{ public void evaluate(Resource each) System.out.println(each.name()); System.out.println(each.name()); System.out.println(each.salary()); System.out.println(each.salary()); }}.evaluate(eachInForce); }}.evaluate(eachInForce); Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 11. Step 2: Semplificare il FOR ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() …… …… Resource eachInForce = null; Resource eachInForce = null; for(int i=0; i i< inforces.size();i++) {{ for(int i=0; < inforces.size();i++) Ciclo ++navigazione Ciclo navigazione eachInForce = (Resource)inforces.get(i); eachInForce = (Resource)inforces.get(i); new Block() {{ new Block() public void evaluate(Resource each) {{ public void evaluate(Resource each) Logica i-i-esima Logicai-esima System.out.println(each.name()); System.out.println(each.name()); System.out.println(each.salary()); System.out.println(each.salary()); }}.evaluate(eachInForce); }}.evaluate(eachInForce); }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 12. Step 2: Semplificare il FOR ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() …… …… Resource eachInForce = null; Resource eachInForce = null; Ciclo ++navigazione for(int i=0; i i< inforces.size();i++) {{ for(int i=0; < inforces.size();i++) Ciclo navigazione eachInForce = (Resource)inforces.get(i); eachInForce = (Resource)inforces.get(i); new PrintSlip().evaluate(eachInForce); Logica i-i-esima new PrintSlip().evaluate(eachInForce); Logicai-esima }} }} public class PrintSlip implements Block {{ public class PrintSlip implements Block public void evaluate(Resource aResource) {{ public void evaluate(Resource aResource) System.out.println(aResource.name()); System.out.println(aResource.name()); System.out.println(aResource.salary()); System.out.println(aResource.salary()); }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 13. Step 3: Eliminare il FOR ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() …… …… Resource eachInForce = null; Resource eachInForce = null; Ciclo ++navigazione for(int i=0; i i< inforces.size();i++) {{ for(int i=0; < inforces.size();i++) Ciclo navigazione eachInForce = (Resource)inforces.get(i); eachInForce = (Resource)inforces.get(i); new PrintSlip().evaluate(eachInForce); Logica i-i-esima new PrintSlip().evaluate(eachInForce); Logicai-esima }} }} public class PrintSlip implements Block {{ public class PrintSlip implements Block public void evaluate(Resource aResource) {{ public void evaluate(Resource aResource) System.out.println(aResource.name()); System.out.println(aResource.name()); System.out.println(aResource.salary()); System.out.println(aResource.salary()); }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 14. Step 3: Eliminare il FOR ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() …… …… Iterator iterator = inforces.iterator(); Iterator iterator = inforces.iterator(); Ciclo Ciclo while(iterator.hasNext()) {{ while(iterator.hasNext()) new PrintSlip().evaluate(iterator.next()); Logica i-i-esima new PrintSlip().evaluate(iterator.next()); Logicai-esima }} }} public class PrintSlip implements Block {{ public class PrintSlip implements Block public void evaluate(Resource aResource) {{ public void evaluate(Resource aResource) System.out.println(aResource.name()); System.out.println(aResource.name()); System.out.println(aResource.salary()); System.out.println(aResource.salary()); }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 15. Step 3: Eliminare il FOR ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips(…) {{ public void printSlips(…) …… …… Iterator iterator = inforces.iterator(); Iterator iterator = inforces.iterator(); Ciclo Ciclo while(iterator.hasNext()) {{ while(iterator.hasNext()) aBlock.evaluate(iterator.next()); aBlock.evaluate(iterator.next()); Logica i-i-esima Logicai-esima }} }} public class PrintSlip implements Block {{ public class PrintSlip implements Block public void evaluate(Resource aResource) {{ public void evaluate(Resource aResource) System.out.println(aResource.name()); System.out.println(aResource.name()); System.out.println(aResource.salary()); System.out.println(aResource.salary()); }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 16. Step 3: Eliminare il FOR public class ResourceOrderedCollection {{ public class ResourceOrderedCollection private Collection _items; private Collection _items; Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public ResourceOrderedCollection(Collection items) {{ public ResourceOrderedCollection(Collection items) Navigazione Navigazione _items ==items; _items items; }} public void forEachDo(Block aBlock) {{ public void forEachDo(Block aBlock) Iterator iterator ==_items.iterator(); Iterator iterator _items.iterator(); Ciclo Ciclo while(iterator.hasNext()) {{ while(iterator.hasNext()) aBlock.evaluate((Resource)iterator.next()); aBlock.evaluate((Resource)iterator.next()); }} }} public void printSlips() {{ public void printSlips() }} Resource eachResource ==null; Resource eachResource null; List inforces ==new ArrayList(); List inforces new ArrayList(); for(int i=0; i i<<_resources.size();i++) {{ for(int i=0; _resources.size();i++) eachResource ==(Resource)_resources.get(i); eachResource (Resource)_resources.get(i); if(eachResource.lastContract().deadline().after(new Date()) ) ){{ if(eachResource.lastContract().deadline().after(new Date()) inforces.add(eachResource); inforces.add(eachResource); }} }} new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it }} Javaday Roma - 01/12/2007
  • 17. Step 4: E la selezione public void printSlips() {{ public void printSlips() Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Resource eachResource ==null; Resource eachResource null; List inforces ==new ArrayList(); List inforces new ArrayList(); Ciclo ++navigazione Ciclo navigazione for(int i=0; i i<<_resources.size();i++) {{ for(int i=0; _resources.size();i++) eachResource ==(Resource)_resources.get(i); eachResource (Resource)_resources.get(i); if(eachResource.lastContract().deadline().after(new Date()) ) ){{ Selezione Selezione Logica i-i-esima Logicai-esima if(eachResource.lastContract().deadline().after(new Date()) inforces.add(eachResource); inforces.add(eachResource); Addizione Addizione }} }} public void printSlips() {{ public void printSlips() new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); Resource eachResource ==null; new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); Resource eachResource null; }} List inforces ==new ArrayList(); List inforces new ArrayList(); for(int i=0; i i<<_resources.size();i++) {{ for(int i=0; _resources.size();i++) eachResource ==(Resource)_resources.get(i); eachResource (Resource)_resources.get(i); if(new PredicateBlock() {{ if(new PredicateBlock() public boolean is(Resource each) {{ public boolean is(Resource each) return each.lastContract().deadline().after(new Date()); return each.lastContract().deadline().after(new Date()); }}.is(eachResource) {{ }}.is(eachResource) inforces.add(eachResource); inforces.add(eachResource); }} }} new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it }} Javaday Roma - 01/12/2007
  • 18. Step 4: E la selezione public void printSlips() {{ public void printSlips() Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Resource eachResource ==null; Resource eachResource null; List inforces ==new ArrayList(); List inforces new ArrayList(); Ciclo ++navigazione Ciclo navigazione for(int i=0; i i<<_resources.size();i++) {{ for(int i=0; _resources.size();i++) eachResource ==(Resource)_resources.get(i); eachResource (Resource)_resources.get(i); if(new InForcePredicate().is(eachResource)) {{ if(new InForcePredicate().is(eachResource)) inforces.add(eachResource); inforces.add(eachResource); Addizione Addizione }} }} new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); }} public class InForcePredicate implements PredicateBlock {{ public class InForcePredicate implements PredicateBlock public boolean is(Resource each) {{ public boolean is(Resource each) Selezione Selezione return each.lastContract().deadline().after(new Date()); return each.lastContract().deadline().after(new Date()); }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 19. Step 4: E la selezione public void printSlips() {{ public void printSlips() Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Collection inforces ==new ResourceOrderedCollection(_resources).select(new InForce()); Collection inforces new ResourceOrderedCollection(_resources).select(new InForce()); new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); }} public Collection select(PredicateBlock aBlock) {{ public Collection select(PredicateBlock aBlock) Collection result ==new ArrayList(); Collection result new ArrayList(); Iterator iterator ==_items.iterator(); Iterator iterator _items.iterator(); Navigazione Navigazione while(iterator.hasNext()) {{ Ciclo Ciclo while(iterator.hasNext()) Resource resource ==(Resource)iterator.next(); Resource resource (Resource)iterator.next(); ifif(aBlock.is(resource)) result.add(resource); (aBlock.is(resource)) result.add(resource); Addizione Addizione }} return result; return result; }} public class InForcePredicate implements PredicateBlock {{ public class InForcePredicate implements PredicateBlock public boolean is(Resource each) {{ public boolean is(Resource each) Selezione Selezione return each.lastContract().deadline().after(new Date()); return each.lastContract().deadline().after(new Date()); }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 20. Step 5: Per leggere meglio public void printSlips() {{ public void printSlips() Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Collection inforces ==new ResourceOrderedCollection(_resources).select(new InForce()); Collection inforces new ResourceOrderedCollection(_resources).select(new InForce()); new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); new ResourceOrderedCollection(inforces).forEachDo(new PrintSlip()); }} public void printSlips() { public void printSlips() { (new ResourceOrderedCollection(_resources).select(new InForce()).forEachDo(new PrintSlip()); (new ResourceOrderedCollection(_resources).select(new InForce()).forEachDo(new PrintSlip()); }} public ResourceOrderedCollection select(PredicateBlock aBlock) { public ResourceOrderedCollection select(PredicateBlock aBlock) { ResourceOrderedCollection result ==new ResourceOrderedCollection(); ResourceOrderedCollection result new ResourceOrderedCollection(); Iterator iterator ==_items.iterator(); Iterator iterator _items.iterator(); while(iterator.hasNext()) {{ while(iterator.hasNext()) Resource resource ==(Resource)iterator.next(); Resource resource (Resource)iterator.next(); ifif(aBlock.is(resource)) result.add(resource); (aBlock.is(resource)) result.add(resource); }} return result; return result; }} public void printSlips() {{ public void printSlips() Predicate isInForce ==new InForce(); Predicate isInForce new InForce(); Block printSlip ==new PrintSlip(); Block printSlip new PrintSlip(); ResourceOrderedCollection resources ==new ResourceOrderedCollection(_resources); ResourceOrderedCollection resources new ResourceOrderedCollection(_resources); resources.select(isInForce).forEachDo(printSlip); resources.select(isInForce).forEachDo(printSlip); }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 21. Step 5: Per leggere meglio public void printSlips() {{ public void printSlips() Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Predicate isInForce ==new InForce(); Predicate isInForce new InForce(); Block printSlip ==new PrintSlip(); Block printSlip new PrintSlip(); ResourceOrderedCollection resources ==new ResourceOrderedCollection(_resources); ResourceOrderedCollection resources new ResourceOrderedCollection(_resources); resources.select(isInForce).forEachDo(printSlip); resources.select(isInForce).forEachDo(printSlip); }} public void printSlips() {{ public void printSlips() printSlipsUsing(new InForce(),new PrintSlip()); printSlipsUsing(new InForce(),new PrintSlip()); }} private void printSlipsUsing(Predicate aCriterium, Block anAction) {{ private void printSlipsUsing(Predicate aCriterium, Block anAction) new ResourceOrderedCollection(_resources).select(aCriterium).forEachDo(anAction); new ResourceOrderedCollection(_resources).select(aCriterium).forEachDo(anAction); }} public void printSlipsUsing(Predicate aCriterium, Block anAction) {{ public void printSlipsUsing(Predicate aCriterium, Block anAction) _resources.select(aCriterium).forEachDo(anAction); _resources.select(aCriterium).forEachDo(anAction); }} private ResourceOrderedCollection _resources; private ResourceOrderedCollection _resources; Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 22. Step 6: Generalizzare new ResourceOrderedCollection(resources).select(isInForce).forEachDo(printSlip); Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License new ResourceOrderedCollection(resources).select(isInForce).forEachDo(printSlip); public class ResourceOrderedCollection { { public class ResourceOrderedCollection …… public void forEachDo(Block aBlock) { { public void forEachDo(Block aBlock) Iterator iterator ==_items.iterator(); Iterator iterator _items.iterator(); while(iterator.hasNext()) { { public class PrintSlip implements Block { { public class PrintSlip implements Block while(iterator.hasNext()) aBlock.evaluate((Resource)iterator.next()); public void evaluate(Resource aResource) { { public void evaluate(Resource aResource) aBlock.evaluate((Resource)iterator.next()); }} System.out.println(aResource.name()); System.out.println(aResource.name()); }} System.out.println(aResource.salary()); System.out.println(aResource.salary()); public ResourceOrderedCollection select(Predicate aBlock) { { }} public ResourceOrderedCollection select(Predicate aBlock) ResourceOrderedCollection result == ResourceOrderedCollection result }} new ResourceOrderedCollection(); new ResourceOrderedCollection(); Iterator iterator ==_items.iterator(); Iterator iterator _items.iterator(); while(iterator.hasNext()) { { while(iterator.hasNext()) Resource resource ==(Resource)iterator.next(); Resource resource (Resource)iterator.next(); ifif(aBlock.is(resource)) result.add(resource); (aBlock.is(resource)) result.add(resource); }} return result; return result; }} public class InForcePredicate implements PredicateBlock { { public class InForcePredicate implements PredicateBlock }} public boolean is(Resource each) { { public boolean is(Resource each) return each.lastContract().deadline().after(new Date()); return each.lastContract().deadline().after(new Date()); }} }} Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 23. Step 6: Generalizzare new ResourceOrderedCollection(resources).select(isInForce).forEachDo(printSlip); Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License new ResourceOrderedCollection(resources).select(isInForce).forEachDo(printSlip); public class ResourceOrderedCollection { { public class ResourceOrderedCollection … public class OrderedCollection { { public class OrderedCollection … …… public void forEachDo(Block aBlock) {class InForcePredicate implements Predicate { public void forEachDo(Block aBlock) {class InForcePredicate implements Predicate { public public public void forEachDo(Block aBlock) { { Iterator iterator ==_items.iterator(); boolean is(Object anObject) { forEachDo(Block aBlock) public void Iterator iterator _items.iterator(); boolean is(Object anObject) { iterator = _items.iterator(); public while(iterator.hasNext()) { { public Iterator iterator = _items.iterator(); Iterator while(iterator.hasNext()) return ((Resource)anObject).lastContract().deadline().after(new Date()); while(iterator.hasNext()) { { return ((Resource)anObject).lastContract().deadline().after(new Date()); aBlock.evaluate((Resource)iterator.next()); aBlock.evaluate((Resource)iterator.next()); while(iterator.hasNext()) }} aBlock.evaluate(iterator.next()); }} aBlock.evaluate(iterator.next()); }} }} }} public class PrintSlip implements Block { public ResourceOrderedCollection Block { public class PrintSlip implements }} public ResourceOrderedCollectionselect(Predicate aBlock) { { public OrderedCollection select(Predicate aBlock) { select(Predicate aBlock) public void evaluate(Resource aResource) { { public void evaluate(Resource aResource) ResourceOrderedCollection result == public OrderedCollection select(Predicate aBlock) { ResourceOrderedCollection result System.out.println(aResource.name()); OrderedCollection result == System.out.println(aResource.name()); new ResourceOrderedCollection(); OrderedCollection result new ResourceOrderedCollection(); System.out.println(aResource.salary()); new OrderedCollection(); Iterator System.out.println(aResource.salary()); Iteratoriterator ==_items.iterator(); iterator _items.iterator(); new OrderedCollection(); }} while(iterator.hasNext()) { { Iterator iterator ==_items.iterator(); Iterator iterator _items.iterator(); }} while(iterator.hasNext()) while(iterator.hasNext()) { { Resource resource ==(Resource)iterator.next(); while(iterator.hasNext()) Resource resource (Resource)iterator.next(); PrintSlip implements Block { = iterator.next(); public class PrintSlip implements object { = iterator.next(); ifif(aBlock.is(resource)) result.add(resource); public class Object Block Object object (aBlock.is(resource)) result.add(resource); }} public void evaluate(Object anObject) { { result.add(object); ifif(aBlock.is(object)) result.add(object); (aBlock.is(object)) public void evaluate(Object anObject) return result; }} System.out.println(((Resource)anObject).name()); return result; System.out.println(((Resource)anObject).name()); return result; }} System.out.println(((Resource)anObject).salary());} return result; System.out.println(((Resource)anObject).salary());} }} }} }} public class InForcePredicate implements PredicateBlock { { } public class InForcePredicate implements PredicateBlock public boolean is(Resource each) { { } public boolean is(Resource each) return each.lastContract().deadline().after(new Date()); return each.lastContract().deadline().after(new Date()); } } Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Francesco }} Javaday Roma - 01/12/2007
  • 24. Dove siamo ////class Department class Department Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License public void printSlips() {{ public void printSlips() Resource resource = null; Resource resource = null; Navigazione? Navigazione? for(int i=0; i i< _resources.size();i++) {{ for(int i=0; < _resources.size();i++) resource = (Resource)_resources.get(i); resource = (Resource)_resources.get(i); Selezione? Selezione? if(resource.lastContract().deadline().after(new Date())) {{ if(resource.lastContract().deadline().after(new Date())) System.out.println(resource.name()); Contenuti? System.out.println(resource.name()); Contenuti? Media? Media? System.out.println(resource.salary()); System.out.println(resource.salary()); }} }} Layout? Layout? }} _resources.select(onlyWomen).forEachDo(printReport); _resources.select(isInForce).forEachDo(printSlip); _resources.select(onlyWomen).forEachDo(printReport); _resources.select(isInForce).forEachDo(printSlip); Contenuti+ Contenuti+ Navigazione Navigazione Selezione Selezione Media+ Media+ Layout Layout Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 25. ////class Department class Department public void printSlips() { { Review & ToDoList public void printSlips() Resource resource ==null; Resource resource null; for(int i=0; i i<<_resources.size();i++) { { for(int i=0; _resources.size();i++) Navigazione? Navigazione? resource ==(Resource)_resources.get(i); resource (Resource)_resources.get(i); Selezione? Selezione? if(resource.lastContract().deadline().after(new Date())) { { if(resource.lastContract().deadline().after(new Date())) System.out.println(resource.name()); System.out.println(resource.name()); Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Media? System.out.println(resource.salary()); Contenuti? Contenuti? Media? System.out.println(resource.salary()); }} }} }} Layout? Layout? 10/01-10/11/2007:Contract Andrea:Employee “Andrea”:String :Department Federica:Manager 1/9/2007-10/10/2008:Contract “Federica”:String System.out:PrintStream Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 26. Review & ToDoList public OrderedCollection select(Predicate aBlock) { { public OrderedCollection select(Predicate aBlock) OrderedCollection result ==new publicCreative Commons Attribution-NonCommercial-ShareAlike 2.5 License OrderedCollection result new OrderedCollection(); publicboolean is(Object each) { { boolean is(Object each) OrderedCollection(); _resources.select(isInForce).forEachDo(printSlip); return ((Resource)each).lastContract().deadline().after(new Date()); return ((Resource)each).lastContract().deadline().after(new Date()); _resources.select(isInForce).forEachDo(printSlip); Iterator iterator ==_items.iterator(); Iterator iterator _items.iterator(); }} while(iterator.hasNext()) { { while(iterator.hasNext()) Object object ==iterator.next(); Object object iterator.next(); ifif(aBlock.is(object)) result.add(object); (aBlock.is(object)) result.add(object); }} return result; 10/01-10/11/2007:Contract return result; }} resources:OrderedCollection Andrea:Employee :InForce “Andrea”:String :Department inForce:OrderedCollection Federica:Manager 1/9/2007-10/10/2008:Contract :PrintSlip “Federica”:String System.out:PrintStream Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 27. Review & ToDoList public OrderedCollection select(Predicate aBlock) { { public class PrintSlip implements Block { { aBlock) public OrderedCollection select(Predicate OrderedCollection result ==new public class PrintSlip implements Block public void forEachDo(Block aBlock) { { public void forEachDo(Block aBlock) public void evaluate(Objectnew OrderedCollection result anObject) { Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License OrderedCollection(); public void evaluate(Object anObject) { Iterator iterator ==_items.iterator(); Iterator iterator _items.iterator(); OrderedCollection(); IteratorSystem.out.println(((Resource)anObject).name()); Iteratoriterator ==_items.iterator(); System.out.println(((Resource)anObject).name()); iterator _items.iterator(); while(iterator.hasNext()) { { while(iterator.hasNext()) System.out.println(((Resource)anObject).salary()); while(iterator.hasNext()) { { System.out.println(((Resource)anObject).salary()); while(iterator.hasNext()) aBlock.evaluate(iterator.next()); aBlock.evaluate(iterator.next()); } } Object object ==iterator.next(); Object object iterator.next(); }} }} ifif(aBlock.is(object)) result.add(object); }} (aBlock.is(object)) result.add(object); }} return result; return result; 10/01-10/11/2007:Contract }} resources:OrderedCollection Andrea:Employee :InForce “Andrea”:String :Department inForce:OrderedCollection Federica:Manager 1/9/2007-10/10/2008:Contract :PrintSlip “Federica”:String System.out:PrintStream Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 28. Riferimenti blocchi e chiusure Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Blocchi in Java − http://www.c2.com/cgi/wiki?BlocksInJava Blocchi e chiusure in Ruby − http://www.artima.com/intv/closuresP.html Chiusure nel linguaggio Java − http://www.javac.info/closures-v03.html Esempi di librerie − http://jaggregate.sourceforge.net Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 29. Segui la Campagna Anti-IF Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007
  • 30. Domande Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License Risorse: http://www.xplabs.it/risorse.html http://www.metodiagili.it/campagna-anti-if.html Tecnica del Pomodoro: http://www.tecnicadelpomodoro.it EasyTracking: http://www.myagileprojects.com Gruppo XPLabs’ Friends- Italia: http://it.groups.yahoo.com/group/xplabs-friends/ Extreme Programming User Group – Italia: http://www.xpug.it/ Francesco Cirillo – francesco.cirillo@metodiagili.it- MetodiAgili.it Javaday Roma - 01/12/2007