SlideShare una empresa de Scribd logo
1 de 121
Descargar para leer sin conexión
DCI
                              Data, Context and
                                 Interaction
                             Fabrizio Giudici, Senior Java Architect
                          Tidalwave s.a.s - fabrizio.giudici@tidalwave.it



Wednesday, May 18, 2011
About the speaker




   DCI                                        2
Wednesday, May 18, 2011
About the speaker

      •       Senior Software Architect, Mentor, Technical Writer
      •       Fourteen years of Java experience (JSE, JEE, JME, etc...)
      •       Sun partner since 1998, Oracle consultant since 2010
      •       Author of a number of open source projects
      •       Speaker at JavaOne, Devoxx, Jazoon, JAX and other events
      •       Member of the NetBeans Dream Team
      •       Co-leader of JUG Milano
      •       Java.Net blogger at http://www.java.net/blogs/fabriziogiudici

   DCI                                                                        2
Wednesday, May 18, 2011
Agenda




   DCI                             3
Wednesday, May 18, 2011
Agenda



      •       A real world example




   DCI                                        3
Wednesday, May 18, 2011
Agenda



      •       A real world example
      •       DCI - Basic concepts




   DCI                                        3
Wednesday, May 18, 2011
Agenda



      •       A real world example
      •       DCI - Basic concepts
      •       DCI - How to implement?




   DCI                                        3
Wednesday, May 18, 2011
Agenda



      •       A real world example
      •       DCI - Basic concepts
      •       DCI - How to implement?
      •       Some simple examples




   DCI                                        3
Wednesday, May 18, 2011
A real world example




Wednesday, May 18, 2011
Shameless Plug




   DCI                                     5
Wednesday, May 18, 2011
Shameless Plug



      •       Exercises of Design - my design book...




   DCI                                                  5
Wednesday, May 18, 2011
Shameless Plug



      •       Exercises of Design - my design book...
            •      Just started!




   DCI                                                  5
Wednesday, May 18, 2011
Shameless Plug



      •       Exercises of Design - my design book...
            •      Just started!

      •       http://exercisesofdesign.java.net




   DCI                                                  5
Wednesday, May 18, 2011
The Observation API



      •       A core component of blueBill Mobile
      •       An application about recording bird observations
      •       Designed with a high degree of abstraction




   DCI                                                           6
Wednesday, May 18, 2011
The Observation API



      •       A core component of blueBill Mobile
      •       An application about recording bird observations
      •       Designed with a high degree of abstraction




   DCI                                                           6
Wednesday, May 18, 2011
The Observation API



      •       A core component of blueBill Mobile
      •       An application about recording bird observations
      •       Designed with a high degree of abstraction




   DCI                                                           6
Wednesday, May 18, 2011
DCI                    7
Wednesday, May 18, 2011
The Taxonomy API




      •       Models the taxonomy of a philogenetic tree
            •      The standard way of biology for representing (bird) species




   DCI                                                                           8
Wednesday, May 18, 2011
DCI                    9
Wednesday, May 18, 2011
So, what about a Bird?




   DCI                                             10
Wednesday, May 18, 2011
So, what about a Bird?

      •       Both a Taxon and an Observable




   DCI                                             10
Wednesday, May 18, 2011
So, what about a Bird?

      •       Both a Taxon and an Observable
      •       Multiple inheritance?




   DCI                                             10
Wednesday, May 18, 2011
So, what about a Bird?

      •       Both a Taxon and an Observable
      •       Multiple inheritance?
      •       Multiple interface implementation?




   DCI                                             10
Wednesday, May 18, 2011
So, what about a Bird?

      •       Both a Taxon and an Observable
      •       Multiple inheritance?
      •       Multiple interface implementation?
      •       Composition




   DCI                                             10
Wednesday, May 18, 2011
So, what about a Bird?

      •       Both a Taxon and an Observable
      •       Multiple inheritance?
      •       Multiple interface implementation?
      •       Composition
            •      Taxon and Observable are roles




   DCI                                              10
Wednesday, May 18, 2011
So, what about a Bird?

      •       Both a Taxon and an Observable
      •       Multiple inheritance?
      •       Multiple interface implementation?
      •       Composition
            •      Taxon and Observable are roles
            •      A Bird, in some contexts, could be a Taxon and/or an
                   Observable


   DCI                                                                    10
Wednesday, May 18, 2011
DCI - Basic Concepts




Wednesday, May 18, 2011
Data, Context and Interaction




   DCI                                                12
Wednesday, May 18, 2011
Data, Context and Interaction


      •       OOD best practice formalized by Trygve Reenskaug




   DCI                                                           12
Wednesday, May 18, 2011
Data, Context and Interaction


      •       OOD best practice formalized by Trygve Reenskaug
            •      The formalizer of MVC




   DCI                                                           12
Wednesday, May 18, 2011
Data, Context and Interaction


      •       OOD best practice formalized by Trygve Reenskaug
            •      The formalizer of MVC

      •       Seen by somebody as an evolution of MVC




   DCI                                                           12
Wednesday, May 18, 2011
Data, Context and Interaction


      •       OOD best practice formalized by Trygve Reenskaug
            •      The formalizer of MVC

      •       Seen by somebody as an evolution of MVC
            •      But it doesn’t replace it




   DCI                                                           12
Wednesday, May 18, 2011
Data, Context and Interaction


      •       OOD best practice formalized by Trygve Reenskaug
            •      The formalizer of MVC

      •       Seen by somebody as an evolution of MVC
            •      But it doesn’t replace it
            •      It rather broadens the analysis scope




   DCI                                                           12
Wednesday, May 18, 2011
Data, Context and Interaction


      •       OOD best practice formalized by Trygve Reenskaug
            •      The formalizer of MVC

      •       Seen by somebody as an evolution of MVC
            •      But it doesn’t replace it
            •      It rather broadens the analysis scope

      •       http://www.artima.com/articles/dci_vision.html



   DCI                                                           12
Wednesday, May 18, 2011
DCI - aims




   DCI                                 13
Wednesday, May 18, 2011
DCI - aims

      •       Improve readability of a OO system




   DCI                                             13
Wednesday, May 18, 2011
DCI - aims

      •       Improve readability of a OO system
      •       Give system behaviour first-class status




   DCI                                                  13
Wednesday, May 18, 2011
DCI - aims

      •       Improve readability of a OO system
      •       Give system behaviour first-class status
            •      Recover readability of system properties on the whole




   DCI                                                                     13
Wednesday, May 18, 2011
DCI - aims

      •       Improve readability of a OO system
      •       Give system behaviour first-class status
            •      Recover readability of system properties on the whole

      •       Separate responsibilities for behaviour and domain




   DCI                                                                     13
Wednesday, May 18, 2011
DCI - aims

      •       Improve readability of a OO system
      •       Give system behaviour first-class status
            •      Recover readability of system properties on the whole

      •       Separate responsibilities for behaviour and domain
            •      Behaviour: what the system does




   DCI                                                                     13
Wednesday, May 18, 2011
DCI - aims

      •       Improve readability of a OO system
      •       Give system behaviour first-class status
            •      Recover readability of system properties on the whole

      •       Separate responsibilities for behaviour and domain
            •      Behaviour: what the system does

            •      Domain: what the system is




   DCI                                                                     13
Wednesday, May 18, 2011
DCI - aims

      •       Improve readability of a OO system
      •       Give system behaviour first-class status
            •      Recover readability of system properties on the whole

      •       Separate responsibilities for behaviour and domain
            •      Behaviour: what the system does

            •      Domain: what the system is

      •       Be close to people’s mental model


   DCI                                                                     13
Wednesday, May 18, 2011
DCI - Data




   DCI                                 14
Wednesday, May 18, 2011
DCI - Data

      •       What the system is




   DCI                                      14
Wednesday, May 18, 2011
DCI - Data

      •       What the system is
      •       Relatively static with relations




   DCI                                           14
Wednesday, May 18, 2011
DCI - Data

      •       What the system is
      •       Relatively static with relations
            •      Domain structure implemented with “conventional” classes




   DCI                                                                        14
Wednesday, May 18, 2011
DCI - Data

      •       What the system is
      •       Relatively static with relations
            •      Domain structure implemented with “conventional” classes
                  •       Hmm... perhaps anemic classes?




   DCI                                                                        14
Wednesday, May 18, 2011
DCI - Data

      •       What the system is
      •       Relatively static with relations
            •      Domain structure implemented with “conventional” classes
                  •       Hmm... perhaps anemic classes?

            •      Typically it includes persistence




   DCI                                                                        14
Wednesday, May 18, 2011
DCI - Data

      •       What the system is
      •       Relatively static with relations
            •      Domain structure implemented with “conventional” classes
                  •       Hmm... perhaps anemic classes?

            •      Typically it includes persistence

      •       Comes from the mental model of system stakeholders




   DCI                                                                        14
Wednesday, May 18, 2011
DCI - Data

      •       What the system is
      •       Relatively static with relations
            •      Domain structure implemented with “conventional” classes
                  •       Hmm... perhaps anemic classes?

            •      Typically it includes persistence

      •       Comes from the mental model of system stakeholders
      •       Close to the “model” in MVC



   DCI                                                                        14
Wednesday, May 18, 2011
DCI - Data

      •       What the system is
      •       Relatively static with relations
            •      Domain structure implemented with “conventional” classes
                  •       Hmm... perhaps anemic classes?

            •      Typically it includes persistence

      •       Comes from the mental model of system stakeholders
      •       Close to the “model” in MVC
      •       E.g.: BankAccount with increase(), decrease(); no deposit()

   DCI                                                                        14
Wednesday, May 18, 2011
DCI - Context (and Roles)




   DCI                                                15
Wednesday, May 18, 2011
DCI - Context (and Roles)

      •       Associated to a use case, user story, scenario, or
              algorithm




   DCI                                                             15
Wednesday, May 18, 2011
DCI - Context (and Roles)

      •       Associated to a use case, user story, scenario, or
              algorithm
      •       Identifies objects participating in a scenario




   DCI                                                             15
Wednesday, May 18, 2011
DCI - Context (and Roles)

      •       Associated to a use case, user story, scenario, or
              algorithm
      •       Identifies objects participating in a scenario
      •       Assign to each object one or more stateless roles




   DCI                                                             15
Wednesday, May 18, 2011
DCI - Context (and Roles)

      •       Associated to a use case, user story, scenario, or
              algorithm
      •       Identifies objects participating in a scenario
      •       Assign to each object one or more stateless roles
            •      Objects can have multiple roles at the same time




   DCI                                                                15
Wednesday, May 18, 2011
DCI - Context (and Roles)

      •       Associated to a use case, user story, scenario, or
              algorithm
      •       Identifies objects participating in a scenario
      •       Assign to each object one or more stateless roles
            •      Objects can have multiple roles at the same time

      •       Decompose the scenario into roles, not objects




   DCI                                                                15
Wednesday, May 18, 2011
DCI - Context (and Roles)

      •       Associated to a use case, user story, scenario, or
              algorithm
      •       Identifies objects participating in a scenario
      •       Assign to each object one or more stateless roles
            •      Objects can have multiple roles at the same time

      •       Decompose the scenario into roles, not objects
            •      Contrast this with polymorphism and classic OO decomposition




   DCI                                                                            15
Wednesday, May 18, 2011
DCI - Context (and Roles)

      •       Associated to a use case, user story, scenario, or
              algorithm
      •       Identifies objects participating in a scenario
      •       Assign to each object one or more stateless roles
            •      Objects can have multiple roles at the same time

      •       Decompose the scenario into roles, not objects
            •      Contrast this with polymorphism and classic OO decomposition

      •       E.g.: MoneyTransfer.{.withDraw(),.deposit()} with srcAccount
              and destAccount

   DCI                                                                            15
Wednesday, May 18, 2011
Quick terminology note




   DCI                                             16
Wednesday, May 18, 2011
Quick terminology note



      •       Methodless role: abstract role




   DCI                                             16
Wednesday, May 18, 2011
Quick terminology note



      •       Methodless role: abstract role
            •      Interface, abstract class




   DCI                                             16
Wednesday, May 18, 2011
Quick terminology note



      •       Methodless role: abstract role
            •      Interface, abstract class

      •       Methodful role: concrete role




   DCI                                             16
Wednesday, May 18, 2011
Quick terminology note



      •       Methodless role: abstract role
            •      Interface, abstract class

      •       Methodful role: concrete role
            •      Concrete class




   DCI                                             16
Wednesday, May 18, 2011
DCI - Interaction




   DCI                                        17
Wednesday, May 18, 2011
DCI - Interaction

      •       What the system does




   DCI                                        17
Wednesday, May 18, 2011
DCI - Interaction

      •       What the system does
      •       Occurs among roles, which act as adapters among objects




   DCI                                                              17
Wednesday, May 18, 2011
DCI - Interaction

      •       What the system does
      •       Occurs among roles, which act as adapters among objects
      •       Roles are bound in different ways for each context




   DCI                                                              17
Wednesday, May 18, 2011
DCI - Interaction

      •       What the system does
      •       Occurs among roles, which act as adapters among objects
      •       Roles are bound in different ways for each context
            •      Roles life cycle is likely to be bound to a given interaction




   DCI                                                                             17
Wednesday, May 18, 2011
DCI - Interaction

      •       What the system does
      •       Occurs among roles, which act as adapters among objects
      •       Roles are bound in different ways for each context
            •      Roles life cycle is likely to be bound to a given interaction

      •       Roles should be generic




   DCI                                                                             17
Wednesday, May 18, 2011
DCI - Interaction

      •       What the system does
      •       Occurs among roles, which act as adapters among objects
      •       Roles are bound in different ways for each context
            •      Roles life cycle is likely to be bound to a given interaction

      •       Roles should be generic
      •       Interaction should be explicit given roles nature



   DCI                                                                             17
Wednesday, May 18, 2011
DCI - Interaction

      •       What the system does
      •       Occurs among roles, which act as adapters among objects
      •       Roles are bound in different ways for each context
            •      Roles life cycle is likely to be bound to a given interaction

      •       Roles should be generic
      •       Interaction should be explicit given roles nature
            •      Hmm.... rather than emergent as in agile design?


   DCI                                                                             17
Wednesday, May 18, 2011
DCI - Execution Model




   DCI                                            18
Wednesday, May 18, 2011
DCI - Execution Model


      •       The Context finds object participants




   DCI                                               18
Wednesday, May 18, 2011
DCI - Execution Model


      •       The Context finds object participants
      •       Then, it assigns (injects?) roles to them




   DCI                                                    18
Wednesday, May 18, 2011
DCI - Execution Model


      •       The Context finds object participants
      •       Then, it assigns (injects?) roles to them
            •      Roles are discovered by type (methodless roles)




   DCI                                                               18
Wednesday, May 18, 2011
DCI - Execution Model


      •       The Context finds object participants
      •       Then, it assigns (injects?) roles to them
            •      Roles are discovered by type (methodless roles)

      •       Then, it triggers a method on the first role




   DCI                                                               18
Wednesday, May 18, 2011
DCI - Execution Model


      •       The Context finds object participants
      •       Then, it assigns (injects?) roles to them
            •      Roles are discovered by type (methodless roles)

      •       Then, it triggers a method on the first role
      •       Interaction goes on among other roles until the job is done



   DCI                                                                      18
Wednesday, May 18, 2011
Some issues




   DCI                                  19
Wednesday, May 18, 2011
Some issues

      •       What about anemic objects?




   DCI                                      19
Wednesday, May 18, 2011
Some issues

      •       What about anemic objects?
            •      Perhaps not a problem considering clusters object + roles




   DCI                                                                         19
Wednesday, May 18, 2011
Some issues

      •       What about anemic objects?
            •      Perhaps not a problem considering clusters object + roles

      •       Object schizophrenia




   DCI                                                                         19
Wednesday, May 18, 2011
Some issues

      •       What about anemic objects?
            •      Perhaps not a problem considering clusters object + roles

      •       Object schizophrenia
            •      Which is the identity of an object in a cluster?




   DCI                                                                         19
Wednesday, May 18, 2011
Some issues

      •       What about anemic objects?
            •      Perhaps not a problem considering clusters object + roles

      •       Object schizophrenia
            •      Which is the identity of an object in a cluster?
            •      What about equals() / hashcode()? Are roles parts of identity?




   DCI                                                                              19
Wednesday, May 18, 2011
Some issues

      •       What about anemic objects?
            •      Perhaps not a problem considering clusters object + roles

      •       Object schizophrenia
            •      Which is the identity of an object in a cluster?
            •      What about equals() / hashcode()? Are roles parts of identity?

            •      Possible solution is an Identifiable role




   DCI                                                                              19
Wednesday, May 18, 2011
Some issues

      •       What about anemic objects?
            •      Perhaps not a problem considering clusters object + roles

      •       Object schizophrenia
            •      Which is the identity of an object in a cluster?
            •      What about equals() / hashcode()? Are roles parts of identity?

            •      Possible solution is an Identifiable role
                  •       Injected by context




   DCI                                                                              19
Wednesday, May 18, 2011
Some issues

      •       What about anemic objects?
            •      Perhaps not a problem considering clusters object + roles

      •       Object schizophrenia
            •      Which is the identity of an object in a cluster?
            •      What about equals() / hashcode()? Are roles parts of identity?

            •      Possible solution is an Identifiable role
                  •       Injected by context

                  •       Objects with the same identity are “equals”


   DCI                                                                              19
Wednesday, May 18, 2011
DCI - How to
                           implement?




Wednesday, May 18, 2011
Implementation issues




   DCI                                            21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic




   DCI                                            21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic
      •       Java




   DCI                                            21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic
      •       Java
            •      AOP, annotation-driven code generation (e.g. Qi4J)




   DCI                                                                  21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic
      •       Java
            •      AOP, annotation-driven code generation (e.g. Qi4J)
      •       Other languages




   DCI                                                                  21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic
      •       Java
            •      AOP, annotation-driven code generation (e.g. Qi4J)
      •       Other languages
            •      Traits, mix-ins




   DCI                                                                  21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic
      •       Java
            •      AOP, annotation-driven code generation (e.g. Qi4J)
      •       Other languages
            •      Traits, mix-ins

      •       First, acknowledge that DCI is a best practice




   DCI                                                                  21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic
      •       Java
            •      AOP, annotation-driven code generation (e.g. Qi4J)
      •       Other languages
            •      Traits, mix-ins

      •       First, acknowledge that DCI is a best practice
            •      Some languages can fit better than others




   DCI                                                                  21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic
      •       Java
            •      AOP, annotation-driven code generation (e.g. Qi4J)
      •       Other languages
            •      Traits, mix-ins

      •       First, acknowledge that DCI is a best practice
            •      Some languages can fit better than others
            •      Frameworks might help... but they force a new nature


   DCI                                                                    21
Wednesday, May 18, 2011
Implementation issues
      •       Static vs dynamic
      •       Java
            •      AOP, annotation-driven code generation (e.g. Qi4J)
      •       Other languages
            •      Traits, mix-ins

      •       First, acknowledge that DCI is a best practice
            •      Some languages can fit better than others
            •      Frameworks might help... but they force a new nature

            •      My point: DCI must be addressed in design
   DCI                                                                    21
Wednesday, May 18, 2011
Abstracting and sweetening


      •       Would be nice to be technology independent
      •       Would be nice to have some syntactic sugar


      •       Note: not central in this presentation, but needed for code
              examples




   DCI                                                                      22
Wednesday, May 18, 2011
NetBeans Platform Lookup; as()




   DCI                                              23
Wednesday, May 18, 2011
NetBeans Platform Lookup; as()
      •       Role role = object.getLookup().lookup(Role.class) ...




   DCI                                                                23
Wednesday, May 18, 2011
NetBeans Platform Lookup; as()
      •       Role role = object.getLookup().lookup(Role.class) ...
            •      NetBeans Platform’s Lookup, as a bag of roles




   DCI                                                                23
Wednesday, May 18, 2011
NetBeans Platform Lookup; as()
      •       Role role = object.getLookup().lookup(Role.class) ...
            •      NetBeans Platform’s Lookup, as a bag of roles
            •      Allows both static implementation and dynamic injection




   DCI                                                                       23
Wednesday, May 18, 2011
NetBeans Platform Lookup; as()
      •       Role role = object.getLookup().lookup(Role.class) ...
            •      NetBeans Platform’s Lookup, as a bag of roles
            •      Allows both static implementation and dynamic injection

      •       Role role = object.as(Role);




   DCI                                                                       23
Wednesday, May 18, 2011
NetBeans Platform Lookup; as()
      •       Role role = object.getLookup().lookup(Role.class) ...
            •      NetBeans Platform’s Lookup, as a bag of roles
            •      Allows both static implementation and dynamic injection

      •       Role role = object.as(Role);
            •      My syntactic sugar around Lookup




   DCI                                                                       23
Wednesday, May 18, 2011
Some examples




Wednesday, May 18, 2011
Some example reusable roles




   DCI                                                  25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:




   DCI                                                  25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();




   DCI                                                                     25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:




   DCI                                                                     25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:
            •      Icon i = myObject.as(IconProvider).getIcon(16);




   DCI                                                                     25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:                             “ask” approach
            •      Icon i = myObject.as(IconProvider).getIcon(16);




   DCI                                                                     25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:                             “ask” approach
            •      Icon i = myObject.as(IconProvider).getIcon(16);


                                                          “tell” approach




   DCI                                                                      25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:                             “ask” approach
            •      Icon i = myObject.as(IconProvider).getIcon(16);

      •       Renderable:
                                                          “tell” approach




   DCI                                                                      25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:                             “ask” approach
            •      Icon i = myObject.as(IconProvider).getIcon(16);

      •       Renderable:
            •      PrintWriter pw = ... //                 “tell”   approach
                   myObject.as(TextRenderable).render(pw);




   DCI                                                                         25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:                             “ask” approach
            •      Icon i = myObject.as(IconProvider).getIcon(16);

      •       Renderable:
            •      PrintWriter pw = ... //                 “tell”   approach
                   myObject.as(TextRenderable).render(pw);
            •      JLabel label = ... // from Swing
                   myObject.as(JLabelRenderable).render(label);



   DCI                                                                         25
Wednesday, May 18, 2011
Some example reusable roles
      •       Displayable:
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:                             “ask” approach
            •      Icon i = myObject.as(IconProvider).getIcon(16);

      •       Renderable:
            •      PrintWriter pw = ... //                 “tell”   approach
                   myObject.as(TextRenderable).render(pw);
            •      JLabel label = ... // from Swing
                   myObject.as(JLabelRenderable).render(label);
            •      TextView textView = ... // from Swing
                   myObject.as(TextViewRenderable).render(textView);
   DCI                                                                         25
Wednesday, May 18, 2011
Some example reusable roles
                                     Roles can be dynamically injected,
      •       Displayable:        so myObject does not depend on them
            •      String s = myObject.as(Displayable).getDisplayName();

      •       IconProvider:                             “ask” approach
            •      Icon i = myObject.as(IconProvider).getIcon(16);

      •       Renderable:
            •      PrintWriter pw = ... //                 “tell”   approach
                   myObject.as(TextRenderable).render(pw);
            •      JLabel label = ... // from Swing
                   myObject.as(JLabelRenderable).render(label);
            •      TextView textView = ... // from Swing
                   myObject.as(TextViewRenderable).render(textView);
   DCI                                                                         25
Wednesday, May 18, 2011
Examples from blueBill


      •       ObservationSet set = ... ;
              set.as(ObservationSetTraverser)
                 .visit(new KMLReportGenerator()); // visitor pattern
      •       ObservationItem item = ...;
              TextView textView = ...;
              item.as(Taxon)
                  .as(TextViewRenderable)
                  .render(textView);



   DCI                                                                  26
Wednesday, May 18, 2011
Example: decorating roles




   DCI                                                27
Wednesday, May 18, 2011
Q &A




      •       Question Time




   DCI                               28
Wednesday, May 18, 2011

Más contenido relacionado

Similar a DCI - Data, Context and Interaction @ Jug Lugano May 2011

S.P.A.C.E. Exploration for Software Engineering
 S.P.A.C.E. Exploration for Software Engineering S.P.A.C.E. Exploration for Software Engineering
S.P.A.C.E. Exploration for Software EngineeringCS, NcState
 
How to open source a project at Mega Corp (Geecon - May/2011)
How to open source a project at Mega Corp (Geecon - May/2011)How to open source a project at Mega Corp (Geecon - May/2011)
How to open source a project at Mega Corp (Geecon - May/2011)Martijn Verburg
 
Monitoring is easy, why are we so bad at it presentation
Monitoring is easy, why are we so bad at it  presentationMonitoring is easy, why are we so bad at it  presentation
Monitoring is easy, why are we so bad at it presentationTheo Schlossnagle
 
Devopsdays Goteborg 2011 - State of the Union
Devopsdays Goteborg 2011 - State of the UnionDevopsdays Goteborg 2011 - State of the Union
Devopsdays Goteborg 2011 - State of the UnionJohn Willis
 
Pardot Elevate 2011: Designing Content for your Marketing Machine
Pardot Elevate 2011: Designing Content for your Marketing MachinePardot Elevate 2011: Designing Content for your Marketing Machine
Pardot Elevate 2011: Designing Content for your Marketing MachinePardot
 
Why Your API Sucks
Why Your API SucksWhy Your API Sucks
Why Your API Sucksejesse
 
Impactful SE Research: Some Do's and More Don'ts
Impactful SE Research: Some Do's and More Don'tsImpactful SE Research: Some Do's and More Don'ts
Impactful SE Research: Some Do's and More Don'tsGail Murphy
 
Workshop 2 audiovisual conservation, preservation and digitisation
Workshop 2 audiovisual conservation, preservation and digitisationWorkshop 2 audiovisual conservation, preservation and digitisation
Workshop 2 audiovisual conservation, preservation and digitisationRichard Wright
 
A Virtuous Cycle of Semantics and Participation
A Virtuous Cycle of Semantics and ParticipationA Virtuous Cycle of Semantics and Participation
A Virtuous Cycle of Semantics and ParticipationDavide Eynard
 
Kin Global Kellogg 2011 Chicago
Kin Global Kellogg 2011 ChicagoKin Global Kellogg 2011 Chicago
Kin Global Kellogg 2011 ChicagoCarlos Dominguez
 
2005 10 20 IVT ELN Cost
2005 10 20 IVT ELN Cost2005 10 20 IVT ELN Cost
2005 10 20 IVT ELN CostSimon Coles
 
The Handover Project - Improving the Continuity of patient care Through Ident...
The Handover Project - Improving the Continuity of patient care Through Ident...The Handover Project - Improving the Continuity of patient care Through Ident...
The Handover Project - Improving the Continuity of patient care Through Ident...Hendrik Drachsler
 

Similar a DCI - Data, Context and Interaction @ Jug Lugano May 2011 (20)

S.P.A.C.E. Exploration for Software Engineering
 S.P.A.C.E. Exploration for Software Engineering S.P.A.C.E. Exploration for Software Engineering
S.P.A.C.E. Exploration for Software Engineering
 
How to open source a project at Mega Corp (Geecon - May/2011)
How to open source a project at Mega Corp (Geecon - May/2011)How to open source a project at Mega Corp (Geecon - May/2011)
How to open source a project at Mega Corp (Geecon - May/2011)
 
Monitoring is easy, why are we so bad at it presentation
Monitoring is easy, why are we so bad at it  presentationMonitoring is easy, why are we so bad at it  presentation
Monitoring is easy, why are we so bad at it presentation
 
When machines think
When machines thinkWhen machines think
When machines think
 
Devopsdays Goteborg 2011 - State of the Union
Devopsdays Goteborg 2011 - State of the UnionDevopsdays Goteborg 2011 - State of the Union
Devopsdays Goteborg 2011 - State of the Union
 
Pardot Elevate 2011: Designing Content for your Marketing Machine
Pardot Elevate 2011: Designing Content for your Marketing MachinePardot Elevate 2011: Designing Content for your Marketing Machine
Pardot Elevate 2011: Designing Content for your Marketing Machine
 
Data Archive Considerations for Customer Communication Management
Data Archive Considerations for Customer Communication ManagementData Archive Considerations for Customer Communication Management
Data Archive Considerations for Customer Communication Management
 
Why Your API Sucks
Why Your API SucksWhy Your API Sucks
Why Your API Sucks
 
Geolinkeddata 07042011 1
Geolinkeddata 07042011 1Geolinkeddata 07042011 1
Geolinkeddata 07042011 1
 
GeoLinkedData
GeoLinkedDataGeoLinkedData
GeoLinkedData
 
Impactful SE Research: Some Do's and More Don'ts
Impactful SE Research: Some Do's and More Don'tsImpactful SE Research: Some Do's and More Don'ts
Impactful SE Research: Some Do's and More Don'ts
 
Workshop 2 audiovisual conservation, preservation and digitisation
Workshop 2 audiovisual conservation, preservation and digitisationWorkshop 2 audiovisual conservation, preservation and digitisation
Workshop 2 audiovisual conservation, preservation and digitisation
 
Promise notes
Promise notesPromise notes
Promise notes
 
STI Summit 2011 - Linked Data & Ontologies
STI Summit 2011 - Linked Data & OntologiesSTI Summit 2011 - Linked Data & Ontologies
STI Summit 2011 - Linked Data & Ontologies
 
A Virtuous Cycle of Semantics and Participation
A Virtuous Cycle of Semantics and ParticipationA Virtuous Cycle of Semantics and Participation
A Virtuous Cycle of Semantics and Participation
 
Kin Global Kellogg 2011 Chicago
Kin Global Kellogg 2011 ChicagoKin Global Kellogg 2011 Chicago
Kin Global Kellogg 2011 Chicago
 
2005 10 20 IVT ELN Cost
2005 10 20 IVT ELN Cost2005 10 20 IVT ELN Cost
2005 10 20 IVT ELN Cost
 
The Handover Project - Improving the Continuity of patient care Through Ident...
The Handover Project - Improving the Continuity of patient care Through Ident...The Handover Project - Improving the Continuity of patient care Through Ident...
The Handover Project - Improving the Continuity of patient care Through Ident...
 
Steve Bennett
Steve BennettSteve Bennett
Steve Bennett
 
Steve Bennett
Steve BennettSteve Bennett
Steve Bennett
 

Más de Fabrizio Giudici

Building Android apps with Maven
Building Android apps with MavenBuilding Android apps with Maven
Building Android apps with MavenFabrizio Giudici
 
NOSQL also means RDF stores: an Android case study
NOSQL also means RDF stores: an Android case studyNOSQL also means RDF stores: an Android case study
NOSQL also means RDF stores: an Android case studyFabrizio Giudici
 
Tools for an effective software factory
Tools for an effective software factoryTools for an effective software factory
Tools for an effective software factoryFabrizio Giudici
 
Parallel Computing Scenarios and the new challenges for the Software Architect
Parallel Computing Scenarios  and the new challenges for the Software ArchitectParallel Computing Scenarios  and the new challenges for the Software Architect
Parallel Computing Scenarios and the new challenges for the Software ArchitectFabrizio Giudici
 
blueMarine a desktop app for the open source photographic workflow
blueMarine  a desktop app for the open source photographic workflowblueMarine  a desktop app for the open source photographic workflow
blueMarine a desktop app for the open source photographic workflowFabrizio Giudici
 
blueMarine photographic workflow with Java
blueMarine photographic workflow with JavablueMarine photographic workflow with Java
blueMarine photographic workflow with JavaFabrizio Giudici
 
blueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans PlatformblueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans PlatformFabrizio Giudici
 
NASA World Wind for Java API Overview
NASA World Wind for Java  API OverviewNASA World Wind for Java  API Overview
NASA World Wind for Java API OverviewFabrizio Giudici
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans Fabrizio Giudici
 
Web Development with Apache Struts 2
Web Development with  Apache Struts 2Web Development with  Apache Struts 2
Web Development with Apache Struts 2Fabrizio Giudici
 
blueMarine Or Why You Should Really Ship Swing Applications
blueMarine  Or Why You Should Really Ship Swing  Applications blueMarine  Or Why You Should Really Ship Swing  Applications
blueMarine Or Why You Should Really Ship Swing Applications Fabrizio Giudici
 
Designing a JavaFX Mobile application
Designing a JavaFX Mobile applicationDesigning a JavaFX Mobile application
Designing a JavaFX Mobile applicationFabrizio Giudici
 
Android java fx-jme@jug-lugano
Android java fx-jme@jug-luganoAndroid java fx-jme@jug-lugano
Android java fx-jme@jug-luganoFabrizio Giudici
 

Más de Fabrizio Giudici (16)

Building Android apps with Maven
Building Android apps with MavenBuilding Android apps with Maven
Building Android apps with Maven
 
NOSQL also means RDF stores: an Android case study
NOSQL also means RDF stores: an Android case studyNOSQL also means RDF stores: an Android case study
NOSQL also means RDF stores: an Android case study
 
Netbeans+platform+maven
Netbeans+platform+mavenNetbeans+platform+maven
Netbeans+platform+maven
 
Tools for an effective software factory
Tools for an effective software factoryTools for an effective software factory
Tools for an effective software factory
 
Parallel Computing Scenarios and the new challenges for the Software Architect
Parallel Computing Scenarios  and the new challenges for the Software ArchitectParallel Computing Scenarios  and the new challenges for the Software Architect
Parallel Computing Scenarios and the new challenges for the Software Architect
 
blueMarine a desktop app for the open source photographic workflow
blueMarine  a desktop app for the open source photographic workflowblueMarine  a desktop app for the open source photographic workflow
blueMarine a desktop app for the open source photographic workflow
 
blueMarine photographic workflow with Java
blueMarine photographic workflow with JavablueMarine photographic workflow with Java
blueMarine photographic workflow with Java
 
blueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans PlatformblueMarine Sailing with NetBeans Platform
blueMarine Sailing with NetBeans Platform
 
NASA World Wind for Java API Overview
NASA World Wind for Java  API OverviewNASA World Wind for Java  API Overview
NASA World Wind for Java API Overview
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
 
The VRC Project
The VRC ProjectThe VRC Project
The VRC Project
 
Web Development with Apache Struts 2
Web Development with  Apache Struts 2Web Development with  Apache Struts 2
Web Development with Apache Struts 2
 
blueMarine Or Why You Should Really Ship Swing Applications
blueMarine  Or Why You Should Really Ship Swing  Applications blueMarine  Or Why You Should Really Ship Swing  Applications
blueMarine Or Why You Should Really Ship Swing Applications
 
Designing a JavaFX Mobile application
Designing a JavaFX Mobile applicationDesigning a JavaFX Mobile application
Designing a JavaFX Mobile application
 
Android java fx-jme@jug-lugano
Android java fx-jme@jug-luganoAndroid java fx-jme@jug-lugano
Android java fx-jme@jug-lugano
 
Mercurial
MercurialMercurial
Mercurial
 

Último

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 

Último (20)

Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 

DCI - Data, Context and Interaction @ Jug Lugano May 2011

  • 1. DCI Data, Context and Interaction Fabrizio Giudici, Senior Java Architect Tidalwave s.a.s - fabrizio.giudici@tidalwave.it Wednesday, May 18, 2011
  • 2. About the speaker DCI 2 Wednesday, May 18, 2011
  • 3. About the speaker • Senior Software Architect, Mentor, Technical Writer • Fourteen years of Java experience (JSE, JEE, JME, etc...) • Sun partner since 1998, Oracle consultant since 2010 • Author of a number of open source projects • Speaker at JavaOne, Devoxx, Jazoon, JAX and other events • Member of the NetBeans Dream Team • Co-leader of JUG Milano • Java.Net blogger at http://www.java.net/blogs/fabriziogiudici DCI 2 Wednesday, May 18, 2011
  • 4. Agenda DCI 3 Wednesday, May 18, 2011
  • 5. Agenda • A real world example DCI 3 Wednesday, May 18, 2011
  • 6. Agenda • A real world example • DCI - Basic concepts DCI 3 Wednesday, May 18, 2011
  • 7. Agenda • A real world example • DCI - Basic concepts • DCI - How to implement? DCI 3 Wednesday, May 18, 2011
  • 8. Agenda • A real world example • DCI - Basic concepts • DCI - How to implement? • Some simple examples DCI 3 Wednesday, May 18, 2011
  • 9. A real world example Wednesday, May 18, 2011
  • 10. Shameless Plug DCI 5 Wednesday, May 18, 2011
  • 11. Shameless Plug • Exercises of Design - my design book... DCI 5 Wednesday, May 18, 2011
  • 12. Shameless Plug • Exercises of Design - my design book... • Just started! DCI 5 Wednesday, May 18, 2011
  • 13. Shameless Plug • Exercises of Design - my design book... • Just started! • http://exercisesofdesign.java.net DCI 5 Wednesday, May 18, 2011
  • 14. The Observation API • A core component of blueBill Mobile • An application about recording bird observations • Designed with a high degree of abstraction DCI 6 Wednesday, May 18, 2011
  • 15. The Observation API • A core component of blueBill Mobile • An application about recording bird observations • Designed with a high degree of abstraction DCI 6 Wednesday, May 18, 2011
  • 16. The Observation API • A core component of blueBill Mobile • An application about recording bird observations • Designed with a high degree of abstraction DCI 6 Wednesday, May 18, 2011
  • 17. DCI 7 Wednesday, May 18, 2011
  • 18. The Taxonomy API • Models the taxonomy of a philogenetic tree • The standard way of biology for representing (bird) species DCI 8 Wednesday, May 18, 2011
  • 19. DCI 9 Wednesday, May 18, 2011
  • 20. So, what about a Bird? DCI 10 Wednesday, May 18, 2011
  • 21. So, what about a Bird? • Both a Taxon and an Observable DCI 10 Wednesday, May 18, 2011
  • 22. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? DCI 10 Wednesday, May 18, 2011
  • 23. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? • Multiple interface implementation? DCI 10 Wednesday, May 18, 2011
  • 24. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? • Multiple interface implementation? • Composition DCI 10 Wednesday, May 18, 2011
  • 25. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? • Multiple interface implementation? • Composition • Taxon and Observable are roles DCI 10 Wednesday, May 18, 2011
  • 26. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? • Multiple interface implementation? • Composition • Taxon and Observable are roles • A Bird, in some contexts, could be a Taxon and/or an Observable DCI 10 Wednesday, May 18, 2011
  • 27. DCI - Basic Concepts Wednesday, May 18, 2011
  • 28. Data, Context and Interaction DCI 12 Wednesday, May 18, 2011
  • 29. Data, Context and Interaction • OOD best practice formalized by Trygve Reenskaug DCI 12 Wednesday, May 18, 2011
  • 30. Data, Context and Interaction • OOD best practice formalized by Trygve Reenskaug • The formalizer of MVC DCI 12 Wednesday, May 18, 2011
  • 31. Data, Context and Interaction • OOD best practice formalized by Trygve Reenskaug • The formalizer of MVC • Seen by somebody as an evolution of MVC DCI 12 Wednesday, May 18, 2011
  • 32. Data, Context and Interaction • OOD best practice formalized by Trygve Reenskaug • The formalizer of MVC • Seen by somebody as an evolution of MVC • But it doesn’t replace it DCI 12 Wednesday, May 18, 2011
  • 33. Data, Context and Interaction • OOD best practice formalized by Trygve Reenskaug • The formalizer of MVC • Seen by somebody as an evolution of MVC • But it doesn’t replace it • It rather broadens the analysis scope DCI 12 Wednesday, May 18, 2011
  • 34. Data, Context and Interaction • OOD best practice formalized by Trygve Reenskaug • The formalizer of MVC • Seen by somebody as an evolution of MVC • But it doesn’t replace it • It rather broadens the analysis scope • http://www.artima.com/articles/dci_vision.html DCI 12 Wednesday, May 18, 2011
  • 35. DCI - aims DCI 13 Wednesday, May 18, 2011
  • 36. DCI - aims • Improve readability of a OO system DCI 13 Wednesday, May 18, 2011
  • 37. DCI - aims • Improve readability of a OO system • Give system behaviour first-class status DCI 13 Wednesday, May 18, 2011
  • 38. DCI - aims • Improve readability of a OO system • Give system behaviour first-class status • Recover readability of system properties on the whole DCI 13 Wednesday, May 18, 2011
  • 39. DCI - aims • Improve readability of a OO system • Give system behaviour first-class status • Recover readability of system properties on the whole • Separate responsibilities for behaviour and domain DCI 13 Wednesday, May 18, 2011
  • 40. DCI - aims • Improve readability of a OO system • Give system behaviour first-class status • Recover readability of system properties on the whole • Separate responsibilities for behaviour and domain • Behaviour: what the system does DCI 13 Wednesday, May 18, 2011
  • 41. DCI - aims • Improve readability of a OO system • Give system behaviour first-class status • Recover readability of system properties on the whole • Separate responsibilities for behaviour and domain • Behaviour: what the system does • Domain: what the system is DCI 13 Wednesday, May 18, 2011
  • 42. DCI - aims • Improve readability of a OO system • Give system behaviour first-class status • Recover readability of system properties on the whole • Separate responsibilities for behaviour and domain • Behaviour: what the system does • Domain: what the system is • Be close to people’s mental model DCI 13 Wednesday, May 18, 2011
  • 43. DCI - Data DCI 14 Wednesday, May 18, 2011
  • 44. DCI - Data • What the system is DCI 14 Wednesday, May 18, 2011
  • 45. DCI - Data • What the system is • Relatively static with relations DCI 14 Wednesday, May 18, 2011
  • 46. DCI - Data • What the system is • Relatively static with relations • Domain structure implemented with “conventional” classes DCI 14 Wednesday, May 18, 2011
  • 47. DCI - Data • What the system is • Relatively static with relations • Domain structure implemented with “conventional” classes • Hmm... perhaps anemic classes? DCI 14 Wednesday, May 18, 2011
  • 48. DCI - Data • What the system is • Relatively static with relations • Domain structure implemented with “conventional” classes • Hmm... perhaps anemic classes? • Typically it includes persistence DCI 14 Wednesday, May 18, 2011
  • 49. DCI - Data • What the system is • Relatively static with relations • Domain structure implemented with “conventional” classes • Hmm... perhaps anemic classes? • Typically it includes persistence • Comes from the mental model of system stakeholders DCI 14 Wednesday, May 18, 2011
  • 50. DCI - Data • What the system is • Relatively static with relations • Domain structure implemented with “conventional” classes • Hmm... perhaps anemic classes? • Typically it includes persistence • Comes from the mental model of system stakeholders • Close to the “model” in MVC DCI 14 Wednesday, May 18, 2011
  • 51. DCI - Data • What the system is • Relatively static with relations • Domain structure implemented with “conventional” classes • Hmm... perhaps anemic classes? • Typically it includes persistence • Comes from the mental model of system stakeholders • Close to the “model” in MVC • E.g.: BankAccount with increase(), decrease(); no deposit() DCI 14 Wednesday, May 18, 2011
  • 52. DCI - Context (and Roles) DCI 15 Wednesday, May 18, 2011
  • 53. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm DCI 15 Wednesday, May 18, 2011
  • 54. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm • Identifies objects participating in a scenario DCI 15 Wednesday, May 18, 2011
  • 55. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm • Identifies objects participating in a scenario • Assign to each object one or more stateless roles DCI 15 Wednesday, May 18, 2011
  • 56. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm • Identifies objects participating in a scenario • Assign to each object one or more stateless roles • Objects can have multiple roles at the same time DCI 15 Wednesday, May 18, 2011
  • 57. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm • Identifies objects participating in a scenario • Assign to each object one or more stateless roles • Objects can have multiple roles at the same time • Decompose the scenario into roles, not objects DCI 15 Wednesday, May 18, 2011
  • 58. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm • Identifies objects participating in a scenario • Assign to each object one or more stateless roles • Objects can have multiple roles at the same time • Decompose the scenario into roles, not objects • Contrast this with polymorphism and classic OO decomposition DCI 15 Wednesday, May 18, 2011
  • 59. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm • Identifies objects participating in a scenario • Assign to each object one or more stateless roles • Objects can have multiple roles at the same time • Decompose the scenario into roles, not objects • Contrast this with polymorphism and classic OO decomposition • E.g.: MoneyTransfer.{.withDraw(),.deposit()} with srcAccount and destAccount DCI 15 Wednesday, May 18, 2011
  • 60. Quick terminology note DCI 16 Wednesday, May 18, 2011
  • 61. Quick terminology note • Methodless role: abstract role DCI 16 Wednesday, May 18, 2011
  • 62. Quick terminology note • Methodless role: abstract role • Interface, abstract class DCI 16 Wednesday, May 18, 2011
  • 63. Quick terminology note • Methodless role: abstract role • Interface, abstract class • Methodful role: concrete role DCI 16 Wednesday, May 18, 2011
  • 64. Quick terminology note • Methodless role: abstract role • Interface, abstract class • Methodful role: concrete role • Concrete class DCI 16 Wednesday, May 18, 2011
  • 65. DCI - Interaction DCI 17 Wednesday, May 18, 2011
  • 66. DCI - Interaction • What the system does DCI 17 Wednesday, May 18, 2011
  • 67. DCI - Interaction • What the system does • Occurs among roles, which act as adapters among objects DCI 17 Wednesday, May 18, 2011
  • 68. DCI - Interaction • What the system does • Occurs among roles, which act as adapters among objects • Roles are bound in different ways for each context DCI 17 Wednesday, May 18, 2011
  • 69. DCI - Interaction • What the system does • Occurs among roles, which act as adapters among objects • Roles are bound in different ways for each context • Roles life cycle is likely to be bound to a given interaction DCI 17 Wednesday, May 18, 2011
  • 70. DCI - Interaction • What the system does • Occurs among roles, which act as adapters among objects • Roles are bound in different ways for each context • Roles life cycle is likely to be bound to a given interaction • Roles should be generic DCI 17 Wednesday, May 18, 2011
  • 71. DCI - Interaction • What the system does • Occurs among roles, which act as adapters among objects • Roles are bound in different ways for each context • Roles life cycle is likely to be bound to a given interaction • Roles should be generic • Interaction should be explicit given roles nature DCI 17 Wednesday, May 18, 2011
  • 72. DCI - Interaction • What the system does • Occurs among roles, which act as adapters among objects • Roles are bound in different ways for each context • Roles life cycle is likely to be bound to a given interaction • Roles should be generic • Interaction should be explicit given roles nature • Hmm.... rather than emergent as in agile design? DCI 17 Wednesday, May 18, 2011
  • 73. DCI - Execution Model DCI 18 Wednesday, May 18, 2011
  • 74. DCI - Execution Model • The Context finds object participants DCI 18 Wednesday, May 18, 2011
  • 75. DCI - Execution Model • The Context finds object participants • Then, it assigns (injects?) roles to them DCI 18 Wednesday, May 18, 2011
  • 76. DCI - Execution Model • The Context finds object participants • Then, it assigns (injects?) roles to them • Roles are discovered by type (methodless roles) DCI 18 Wednesday, May 18, 2011
  • 77. DCI - Execution Model • The Context finds object participants • Then, it assigns (injects?) roles to them • Roles are discovered by type (methodless roles) • Then, it triggers a method on the first role DCI 18 Wednesday, May 18, 2011
  • 78. DCI - Execution Model • The Context finds object participants • Then, it assigns (injects?) roles to them • Roles are discovered by type (methodless roles) • Then, it triggers a method on the first role • Interaction goes on among other roles until the job is done DCI 18 Wednesday, May 18, 2011
  • 79. Some issues DCI 19 Wednesday, May 18, 2011
  • 80. Some issues • What about anemic objects? DCI 19 Wednesday, May 18, 2011
  • 81. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles DCI 19 Wednesday, May 18, 2011
  • 82. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles • Object schizophrenia DCI 19 Wednesday, May 18, 2011
  • 83. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles • Object schizophrenia • Which is the identity of an object in a cluster? DCI 19 Wednesday, May 18, 2011
  • 84. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles • Object schizophrenia • Which is the identity of an object in a cluster? • What about equals() / hashcode()? Are roles parts of identity? DCI 19 Wednesday, May 18, 2011
  • 85. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles • Object schizophrenia • Which is the identity of an object in a cluster? • What about equals() / hashcode()? Are roles parts of identity? • Possible solution is an Identifiable role DCI 19 Wednesday, May 18, 2011
  • 86. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles • Object schizophrenia • Which is the identity of an object in a cluster? • What about equals() / hashcode()? Are roles parts of identity? • Possible solution is an Identifiable role • Injected by context DCI 19 Wednesday, May 18, 2011
  • 87. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles • Object schizophrenia • Which is the identity of an object in a cluster? • What about equals() / hashcode()? Are roles parts of identity? • Possible solution is an Identifiable role • Injected by context • Objects with the same identity are “equals” DCI 19 Wednesday, May 18, 2011
  • 88. DCI - How to implement? Wednesday, May 18, 2011
  • 89. Implementation issues DCI 21 Wednesday, May 18, 2011
  • 90. Implementation issues • Static vs dynamic DCI 21 Wednesday, May 18, 2011
  • 91. Implementation issues • Static vs dynamic • Java DCI 21 Wednesday, May 18, 2011
  • 92. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) DCI 21 Wednesday, May 18, 2011
  • 93. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) • Other languages DCI 21 Wednesday, May 18, 2011
  • 94. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) • Other languages • Traits, mix-ins DCI 21 Wednesday, May 18, 2011
  • 95. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) • Other languages • Traits, mix-ins • First, acknowledge that DCI is a best practice DCI 21 Wednesday, May 18, 2011
  • 96. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) • Other languages • Traits, mix-ins • First, acknowledge that DCI is a best practice • Some languages can fit better than others DCI 21 Wednesday, May 18, 2011
  • 97. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) • Other languages • Traits, mix-ins • First, acknowledge that DCI is a best practice • Some languages can fit better than others • Frameworks might help... but they force a new nature DCI 21 Wednesday, May 18, 2011
  • 98. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) • Other languages • Traits, mix-ins • First, acknowledge that DCI is a best practice • Some languages can fit better than others • Frameworks might help... but they force a new nature • My point: DCI must be addressed in design DCI 21 Wednesday, May 18, 2011
  • 99. Abstracting and sweetening • Would be nice to be technology independent • Would be nice to have some syntactic sugar • Note: not central in this presentation, but needed for code examples DCI 22 Wednesday, May 18, 2011
  • 100. NetBeans Platform Lookup; as() DCI 23 Wednesday, May 18, 2011
  • 101. NetBeans Platform Lookup; as() • Role role = object.getLookup().lookup(Role.class) ... DCI 23 Wednesday, May 18, 2011
  • 102. NetBeans Platform Lookup; as() • Role role = object.getLookup().lookup(Role.class) ... • NetBeans Platform’s Lookup, as a bag of roles DCI 23 Wednesday, May 18, 2011
  • 103. NetBeans Platform Lookup; as() • Role role = object.getLookup().lookup(Role.class) ... • NetBeans Platform’s Lookup, as a bag of roles • Allows both static implementation and dynamic injection DCI 23 Wednesday, May 18, 2011
  • 104. NetBeans Platform Lookup; as() • Role role = object.getLookup().lookup(Role.class) ... • NetBeans Platform’s Lookup, as a bag of roles • Allows both static implementation and dynamic injection • Role role = object.as(Role); DCI 23 Wednesday, May 18, 2011
  • 105. NetBeans Platform Lookup; as() • Role role = object.getLookup().lookup(Role.class) ... • NetBeans Platform’s Lookup, as a bag of roles • Allows both static implementation and dynamic injection • Role role = object.as(Role); • My syntactic sugar around Lookup DCI 23 Wednesday, May 18, 2011
  • 107. Some example reusable roles DCI 25 Wednesday, May 18, 2011
  • 108. Some example reusable roles • Displayable: DCI 25 Wednesday, May 18, 2011
  • 109. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); DCI 25 Wednesday, May 18, 2011
  • 110. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: DCI 25 Wednesday, May 18, 2011
  • 111. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: • Icon i = myObject.as(IconProvider).getIcon(16); DCI 25 Wednesday, May 18, 2011
  • 112. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: “ask” approach • Icon i = myObject.as(IconProvider).getIcon(16); DCI 25 Wednesday, May 18, 2011
  • 113. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: “ask” approach • Icon i = myObject.as(IconProvider).getIcon(16); “tell” approach DCI 25 Wednesday, May 18, 2011
  • 114. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: “ask” approach • Icon i = myObject.as(IconProvider).getIcon(16); • Renderable: “tell” approach DCI 25 Wednesday, May 18, 2011
  • 115. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: “ask” approach • Icon i = myObject.as(IconProvider).getIcon(16); • Renderable: • PrintWriter pw = ... // “tell” approach myObject.as(TextRenderable).render(pw); DCI 25 Wednesday, May 18, 2011
  • 116. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: “ask” approach • Icon i = myObject.as(IconProvider).getIcon(16); • Renderable: • PrintWriter pw = ... // “tell” approach myObject.as(TextRenderable).render(pw); • JLabel label = ... // from Swing myObject.as(JLabelRenderable).render(label); DCI 25 Wednesday, May 18, 2011
  • 117. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: “ask” approach • Icon i = myObject.as(IconProvider).getIcon(16); • Renderable: • PrintWriter pw = ... // “tell” approach myObject.as(TextRenderable).render(pw); • JLabel label = ... // from Swing myObject.as(JLabelRenderable).render(label); • TextView textView = ... // from Swing myObject.as(TextViewRenderable).render(textView); DCI 25 Wednesday, May 18, 2011
  • 118. Some example reusable roles Roles can be dynamically injected, • Displayable: so myObject does not depend on them • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: “ask” approach • Icon i = myObject.as(IconProvider).getIcon(16); • Renderable: • PrintWriter pw = ... // “tell” approach myObject.as(TextRenderable).render(pw); • JLabel label = ... // from Swing myObject.as(JLabelRenderable).render(label); • TextView textView = ... // from Swing myObject.as(TextViewRenderable).render(textView); DCI 25 Wednesday, May 18, 2011
  • 119. Examples from blueBill • ObservationSet set = ... ; set.as(ObservationSetTraverser) .visit(new KMLReportGenerator()); // visitor pattern • ObservationItem item = ...; TextView textView = ...; item.as(Taxon) .as(TextViewRenderable) .render(textView); DCI 26 Wednesday, May 18, 2011
  • 120. Example: decorating roles DCI 27 Wednesday, May 18, 2011
  • 121. Q &A • Question Time DCI 28 Wednesday, May 18, 2011