SlideShare ist ein Scribd-Unternehmen logo
1 von 121
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

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