DCI                              Data, Context and                                 Interaction                            ...
About the speaker   DCI                                        2Wednesday, May 18, 2011
About the speaker      •       Senior Software Architect, Mentor, Technical Writer      •       Fourteen years of Java exp...
Agenda   DCI                             3Wednesday, May 18, 2011
Agenda      •       A real world example   DCI                                        3Wednesday, May 18, 2011
Agenda      •       A real world example      •       DCI - Basic concepts   DCI                                        3W...
Agenda      •       A real world example      •       DCI - Basic concepts      •       DCI - How to implement?   DCI     ...
Agenda      •       A real world example      •       DCI - Basic concepts      •       DCI - How to implement?      •    ...
A real world exampleWednesday, May 18, 2011
Shameless Plug   DCI                                     5Wednesday, May 18, 2011
Shameless Plug      •       Exercises of Design - my design book...   DCI                                                 ...
Shameless Plug      •       Exercises of Design - my design book...            •      Just started!   DCI                 ...
Shameless Plug      •       Exercises of Design - my design book...            •      Just started!      •       http://ex...
The Observation API      •       A core component of blueBill Mobile      •       An application about recording bird obse...
The Observation API      •       A core component of blueBill Mobile      •       An application about recording bird obse...
The Observation API      •       A core component of blueBill Mobile      •       An application about recording bird obse...
DCI                    7Wednesday, May 18, 2011
The Taxonomy API      •       Models the taxonomy of a philogenetic tree            •      The standard way of biology for...
DCI                    9Wednesday, May 18, 2011
So, what about a Bird?   DCI                                             10Wednesday, May 18, 2011
So, what about a Bird?      •       Both a Taxon and an Observable   DCI                                             10Wed...
So, what about a Bird?      •       Both a Taxon and an Observable      •       Multiple inheritance?   DCI               ...
So, what about a Bird?      •       Both a Taxon and an Observable      •       Multiple inheritance?      •       Multipl...
So, what about a Bird?      •       Both a Taxon and an Observable      •       Multiple inheritance?      •       Multipl...
So, what about a Bird?      •       Both a Taxon and an Observable      •       Multiple inheritance?      •       Multipl...
So, what about a Bird?      •       Both a Taxon and an Observable      •       Multiple inheritance?      •       Multipl...
DCI - Basic ConceptsWednesday, May 18, 2011
Data, Context and Interaction   DCI                                                12Wednesday, May 18, 2011
Data, Context and Interaction      •       OOD best practice formalized by Trygve Reenskaug   DCI                         ...
Data, Context and Interaction      •       OOD best practice formalized by Trygve Reenskaug            •      The formaliz...
Data, Context and Interaction      •       OOD best practice formalized by Trygve Reenskaug            •      The formaliz...
Data, Context and Interaction      •       OOD best practice formalized by Trygve Reenskaug            •      The formaliz...
Data, Context and Interaction      •       OOD best practice formalized by Trygve Reenskaug            •      The formaliz...
Data, Context and Interaction      •       OOD best practice formalized by Trygve Reenskaug            •      The formaliz...
DCI - aims   DCI                                 13Wednesday, May 18, 2011
DCI - aims      •       Improve readability of a OO system   DCI                                             13Wednesday, ...
DCI - aims      •       Improve readability of a OO system      •       Give system behaviour first-class status   DCI     ...
DCI - aims      •       Improve readability of a OO system      •       Give system behaviour first-class status           ...
DCI - aims      •       Improve readability of a OO system      •       Give system behaviour first-class status           ...
DCI - aims      •       Improve readability of a OO system      •       Give system behaviour first-class status           ...
DCI - aims      •       Improve readability of a OO system      •       Give system behaviour first-class status           ...
DCI - aims      •       Improve readability of a OO system      •       Give system behaviour first-class status           ...
DCI - Data   DCI                                 14Wednesday, May 18, 2011
DCI - Data      •       What the system is   DCI                                      14Wednesday, May 18, 2011
DCI - Data      •       What the system is      •       Relatively static with relations   DCI                            ...
DCI - Data      •       What the system is      •       Relatively static with relations            •      Domain structur...
DCI - Data      •       What the system is      •       Relatively static with relations            •      Domain structur...
DCI - Data      •       What the system is      •       Relatively static with relations            •      Domain structur...
DCI - Data      •       What the system is      •       Relatively static with relations            •      Domain structur...
DCI - Data      •       What the system is      •       Relatively static with relations            •      Domain structur...
DCI - Data      •       What the system is      •       Relatively static with relations            •      Domain structur...
DCI - Context (and Roles)   DCI                                                15Wednesday, May 18, 2011
DCI - Context (and Roles)      •       Associated to a use case, user story, scenario, or              algorithm   DCI    ...
DCI - Context (and Roles)      •       Associated to a use case, user story, scenario, or              algorithm      •   ...
DCI - Context (and Roles)      •       Associated to a use case, user story, scenario, or              algorithm      •   ...
DCI - Context (and Roles)      •       Associated to a use case, user story, scenario, or              algorithm      •   ...
DCI - Context (and Roles)      •       Associated to a use case, user story, scenario, or              algorithm      •   ...
DCI - Context (and Roles)      •       Associated to a use case, user story, scenario, or              algorithm      •   ...
DCI - Context (and Roles)      •       Associated to a use case, user story, scenario, or              algorithm      •   ...
Quick terminology note   DCI                                             16Wednesday, May 18, 2011
Quick terminology note      •       Methodless role: abstract role   DCI                                             16Wed...
Quick terminology note      •       Methodless role: abstract role            •      Interface, abstract class   DCI      ...
Quick terminology note      •       Methodless role: abstract role            •      Interface, abstract class      •     ...
Quick terminology note      •       Methodless role: abstract role            •      Interface, abstract class      •     ...
DCI - Interaction   DCI                                        17Wednesday, May 18, 2011
DCI - Interaction      •       What the system does   DCI                                        17Wednesday, May 18, 2011
DCI - Interaction      •       What the system does      •       Occurs among roles, which act as adapters among objects  ...
DCI - Interaction      •       What the system does      •       Occurs among roles, which act as adapters among objects  ...
DCI - Interaction      •       What the system does      •       Occurs among roles, which act as adapters among objects  ...
DCI - Interaction      •       What the system does      •       Occurs among roles, which act as adapters among objects  ...
DCI - Interaction      •       What the system does      •       Occurs among roles, which act as adapters among objects  ...
DCI - Interaction      •       What the system does      •       Occurs among roles, which act as adapters among objects  ...
DCI - Execution Model   DCI                                            18Wednesday, May 18, 2011
DCI - Execution Model      •       The Context finds object participants   DCI                                             ...
DCI - Execution Model      •       The Context finds object participants      •       Then, it assigns (injects?) roles to ...
DCI - Execution Model      •       The Context finds object participants      •       Then, it assigns (injects?) roles to ...
DCI - Execution Model      •       The Context finds object participants      •       Then, it assigns (injects?) roles to ...
DCI - Execution Model      •       The Context finds object participants      •       Then, it assigns (injects?) roles to ...
Some issues   DCI                                  19Wednesday, May 18, 2011
Some issues      •       What about anemic objects?   DCI                                      19Wednesday, May 18, 2011
Some issues      •       What about anemic objects?            •      Perhaps not a problem considering clusters object + ...
Some issues      •       What about anemic objects?            •      Perhaps not a problem considering clusters object + ...
Some issues      •       What about anemic objects?            •      Perhaps not a problem considering clusters object + ...
Some issues      •       What about anemic objects?            •      Perhaps not a problem considering clusters object + ...
Some issues      •       What about anemic objects?            •      Perhaps not a problem considering clusters object + ...
Some issues      •       What about anemic objects?            •      Perhaps not a problem considering clusters object + ...
Some issues      •       What about anemic objects?            •      Perhaps not a problem considering clusters object + ...
DCI - How to                           implement?Wednesday, May 18, 2011
Implementation issues   DCI                                            21Wednesday, May 18, 2011
Implementation issues      •       Static vs dynamic   DCI                                            21Wednesday, May 18,...
Implementation issues      •       Static vs dynamic      •       Java   DCI                                            21...
Implementation issues      •       Static vs dynamic      •       Java            •      AOP, annotation-driven code gener...
Implementation issues      •       Static vs dynamic      •       Java            •      AOP, annotation-driven code gener...
Implementation issues      •       Static vs dynamic      •       Java            •      AOP, annotation-driven code gener...
Implementation issues      •       Static vs dynamic      •       Java            •      AOP, annotation-driven code gener...
Implementation issues      •       Static vs dynamic      •       Java            •      AOP, annotation-driven code gener...
Implementation issues      •       Static vs dynamic      •       Java            •      AOP, annotation-driven code gener...
Implementation issues      •       Static vs dynamic      •       Java            •      AOP, annotation-driven code gener...
Abstracting and sweetening      •       Would be nice to be technology independent      •       Would be nice to have some...
NetBeans Platform Lookup; as()   DCI                                              23Wednesday, May 18, 2011
NetBeans Platform Lookup; as()      •       Role role = object.getLookup().lookup(Role.class) ...   DCI                   ...
NetBeans Platform Lookup; as()      •       Role role = object.getLookup().lookup(Role.class) ...            •      NetBea...
NetBeans Platform Lookup; as()      •       Role role = object.getLookup().lookup(Role.class) ...            •      NetBea...
NetBeans Platform Lookup; as()      •       Role role = object.getLookup().lookup(Role.class) ...            •      NetBea...
NetBeans Platform Lookup; as()      •       Role role = object.getLookup().lookup(Role.class) ...            •      NetBea...
Some examplesWednesday, May 18, 2011
Some example reusable roles   DCI                                                  25Wednesday, May 18, 2011
Some example reusable roles      •       Displayable:   DCI                                                  25Wednesday, ...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles      •       Displayable:            •      String s = myObject.as(Displayable).getDisplayName...
Some example reusable roles                                     Roles can be dynamically injected,      •       Displayabl...
Examples from blueBill      •       ObservationSet set = ... ;              set.as(ObservationSetTraverser)               ...
Example: decorating roles   DCI                                                27Wednesday, May 18, 2011
Q &A      •       Question Time   DCI                               28Wednesday, May 18, 2011
Upcoming SlideShare
Loading in...5
×

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

2,285

Published on

My personal take on the Data, Context and Interaction best practice.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,285
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
64
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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

  1. 1. DCI Data, Context and Interaction Fabrizio Giudici, Senior Java Architect Tidalwave s.a.s - fabrizio.giudici@tidalwave.itWednesday, May 18, 2011
  2. 2. About the speaker DCI 2Wednesday, May 18, 2011
  3. 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 2Wednesday, May 18, 2011
  4. 4. Agenda DCI 3Wednesday, May 18, 2011
  5. 5. Agenda • A real world example DCI 3Wednesday, May 18, 2011
  6. 6. Agenda • A real world example • DCI - Basic concepts DCI 3Wednesday, May 18, 2011
  7. 7. Agenda • A real world example • DCI - Basic concepts • DCI - How to implement? DCI 3Wednesday, May 18, 2011
  8. 8. Agenda • A real world example • DCI - Basic concepts • DCI - How to implement? • Some simple examples DCI 3Wednesday, May 18, 2011
  9. 9. A real world exampleWednesday, May 18, 2011
  10. 10. Shameless Plug DCI 5Wednesday, May 18, 2011
  11. 11. Shameless Plug • Exercises of Design - my design book... DCI 5Wednesday, May 18, 2011
  12. 12. Shameless Plug • Exercises of Design - my design book... • Just started! DCI 5Wednesday, May 18, 2011
  13. 13. Shameless Plug • Exercises of Design - my design book... • Just started! • http://exercisesofdesign.java.net DCI 5Wednesday, May 18, 2011
  14. 14. The Observation API • A core component of blueBill Mobile • An application about recording bird observations • Designed with a high degree of abstraction DCI 6Wednesday, May 18, 2011
  15. 15. The Observation API • A core component of blueBill Mobile • An application about recording bird observations • Designed with a high degree of abstraction DCI 6Wednesday, May 18, 2011
  16. 16. The Observation API • A core component of blueBill Mobile • An application about recording bird observations • Designed with a high degree of abstraction DCI 6Wednesday, May 18, 2011
  17. 17. DCI 7Wednesday, May 18, 2011
  18. 18. The Taxonomy API • Models the taxonomy of a philogenetic tree • The standard way of biology for representing (bird) species DCI 8Wednesday, May 18, 2011
  19. 19. DCI 9Wednesday, May 18, 2011
  20. 20. So, what about a Bird? DCI 10Wednesday, May 18, 2011
  21. 21. So, what about a Bird? • Both a Taxon and an Observable DCI 10Wednesday, May 18, 2011
  22. 22. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? DCI 10Wednesday, May 18, 2011
  23. 23. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? • Multiple interface implementation? DCI 10Wednesday, May 18, 2011
  24. 24. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? • Multiple interface implementation? • Composition DCI 10Wednesday, May 18, 2011
  25. 25. So, what about a Bird? • Both a Taxon and an Observable • Multiple inheritance? • Multiple interface implementation? • Composition • Taxon and Observable are roles DCI 10Wednesday, May 18, 2011
  26. 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 10Wednesday, May 18, 2011
  27. 27. DCI - Basic ConceptsWednesday, May 18, 2011
  28. 28. Data, Context and Interaction DCI 12Wednesday, May 18, 2011
  29. 29. Data, Context and Interaction • OOD best practice formalized by Trygve Reenskaug DCI 12Wednesday, May 18, 2011
  30. 30. Data, Context and Interaction • OOD best practice formalized by Trygve Reenskaug • The formalizer of MVC DCI 12Wednesday, May 18, 2011
  31. 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 12Wednesday, May 18, 2011
  32. 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 12Wednesday, May 18, 2011
  33. 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 12Wednesday, May 18, 2011
  34. 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 12Wednesday, May 18, 2011
  35. 35. DCI - aims DCI 13Wednesday, May 18, 2011
  36. 36. DCI - aims • Improve readability of a OO system DCI 13Wednesday, May 18, 2011
  37. 37. DCI - aims • Improve readability of a OO system • Give system behaviour first-class status DCI 13Wednesday, May 18, 2011
  38. 38. DCI - aims • Improve readability of a OO system • Give system behaviour first-class status • Recover readability of system properties on the whole DCI 13Wednesday, May 18, 2011
  39. 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 13Wednesday, May 18, 2011
  40. 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 13Wednesday, May 18, 2011
  41. 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 13Wednesday, May 18, 2011
  42. 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 13Wednesday, May 18, 2011
  43. 43. DCI - Data DCI 14Wednesday, May 18, 2011
  44. 44. DCI - Data • What the system is DCI 14Wednesday, May 18, 2011
  45. 45. DCI - Data • What the system is • Relatively static with relations DCI 14Wednesday, May 18, 2011
  46. 46. DCI - Data • What the system is • Relatively static with relations • Domain structure implemented with “conventional” classes DCI 14Wednesday, May 18, 2011
  47. 47. DCI - Data • What the system is • Relatively static with relations • Domain structure implemented with “conventional” classes • Hmm... perhaps anemic classes? DCI 14Wednesday, May 18, 2011
  48. 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 14Wednesday, May 18, 2011
  49. 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 14Wednesday, May 18, 2011
  50. 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 14Wednesday, May 18, 2011
  51. 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 14Wednesday, May 18, 2011
  52. 52. DCI - Context (and Roles) DCI 15Wednesday, May 18, 2011
  53. 53. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm DCI 15Wednesday, May 18, 2011
  54. 54. DCI - Context (and Roles) • Associated to a use case, user story, scenario, or algorithm • Identifies objects participating in a scenario DCI 15Wednesday, May 18, 2011
  55. 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 15Wednesday, May 18, 2011
  56. 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 15Wednesday, May 18, 2011
  57. 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 15Wednesday, May 18, 2011
  58. 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 15Wednesday, May 18, 2011
  59. 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 15Wednesday, May 18, 2011
  60. 60. Quick terminology note DCI 16Wednesday, May 18, 2011
  61. 61. Quick terminology note • Methodless role: abstract role DCI 16Wednesday, May 18, 2011
  62. 62. Quick terminology note • Methodless role: abstract role • Interface, abstract class DCI 16Wednesday, May 18, 2011
  63. 63. Quick terminology note • Methodless role: abstract role • Interface, abstract class • Methodful role: concrete role DCI 16Wednesday, May 18, 2011
  64. 64. Quick terminology note • Methodless role: abstract role • Interface, abstract class • Methodful role: concrete role • Concrete class DCI 16Wednesday, May 18, 2011
  65. 65. DCI - Interaction DCI 17Wednesday, May 18, 2011
  66. 66. DCI - Interaction • What the system does DCI 17Wednesday, May 18, 2011
  67. 67. DCI - Interaction • What the system does • Occurs among roles, which act as adapters among objects DCI 17Wednesday, May 18, 2011
  68. 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 17Wednesday, May 18, 2011
  69. 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 17Wednesday, May 18, 2011
  70. 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 17Wednesday, May 18, 2011
  71. 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 17Wednesday, May 18, 2011
  72. 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 17Wednesday, May 18, 2011
  73. 73. DCI - Execution Model DCI 18Wednesday, May 18, 2011
  74. 74. DCI - Execution Model • The Context finds object participants DCI 18Wednesday, May 18, 2011
  75. 75. DCI - Execution Model • The Context finds object participants • Then, it assigns (injects?) roles to them DCI 18Wednesday, May 18, 2011
  76. 76. DCI - Execution Model • The Context finds object participants • Then, it assigns (injects?) roles to them • Roles are discovered by type (methodless roles) DCI 18Wednesday, May 18, 2011
  77. 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 18Wednesday, May 18, 2011
  78. 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 18Wednesday, May 18, 2011
  79. 79. Some issues DCI 19Wednesday, May 18, 2011
  80. 80. Some issues • What about anemic objects? DCI 19Wednesday, May 18, 2011
  81. 81. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles DCI 19Wednesday, May 18, 2011
  82. 82. Some issues • What about anemic objects? • Perhaps not a problem considering clusters object + roles • Object schizophrenia DCI 19Wednesday, May 18, 2011
  83. 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 19Wednesday, May 18, 2011
  84. 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 19Wednesday, May 18, 2011
  85. 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 19Wednesday, May 18, 2011
  86. 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 19Wednesday, May 18, 2011
  87. 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 19Wednesday, May 18, 2011
  88. 88. DCI - How to implement?Wednesday, May 18, 2011
  89. 89. Implementation issues DCI 21Wednesday, May 18, 2011
  90. 90. Implementation issues • Static vs dynamic DCI 21Wednesday, May 18, 2011
  91. 91. Implementation issues • Static vs dynamic • Java DCI 21Wednesday, May 18, 2011
  92. 92. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) DCI 21Wednesday, May 18, 2011
  93. 93. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) • Other languages DCI 21Wednesday, May 18, 2011
  94. 94. Implementation issues • Static vs dynamic • Java • AOP, annotation-driven code generation (e.g. Qi4J) • Other languages • Traits, mix-ins DCI 21Wednesday, May 18, 2011
  95. 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 21Wednesday, May 18, 2011
  96. 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 21Wednesday, May 18, 2011
  97. 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 21Wednesday, May 18, 2011
  98. 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 21Wednesday, May 18, 2011
  99. 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 22Wednesday, May 18, 2011
  100. 100. NetBeans Platform Lookup; as() DCI 23Wednesday, May 18, 2011
  101. 101. NetBeans Platform Lookup; as() • Role role = object.getLookup().lookup(Role.class) ... DCI 23Wednesday, May 18, 2011
  102. 102. NetBeans Platform Lookup; as() • Role role = object.getLookup().lookup(Role.class) ... • NetBeans Platform’s Lookup, as a bag of roles DCI 23Wednesday, May 18, 2011
  103. 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 23Wednesday, May 18, 2011
  104. 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 23Wednesday, May 18, 2011
  105. 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 23Wednesday, May 18, 2011
  106. 106. Some examplesWednesday, May 18, 2011
  107. 107. Some example reusable roles DCI 25Wednesday, May 18, 2011
  108. 108. Some example reusable roles • Displayable: DCI 25Wednesday, May 18, 2011
  109. 109. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); DCI 25Wednesday, May 18, 2011
  110. 110. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: DCI 25Wednesday, May 18, 2011
  111. 111. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: • Icon i = myObject.as(IconProvider).getIcon(16); DCI 25Wednesday, May 18, 2011
  112. 112. Some example reusable roles • Displayable: • String s = myObject.as(Displayable).getDisplayName(); • IconProvider: “ask” approach • Icon i = myObject.as(IconProvider).getIcon(16); DCI 25Wednesday, May 18, 2011
  113. 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 25Wednesday, May 18, 2011
  114. 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 25Wednesday, May 18, 2011
  115. 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 25Wednesday, May 18, 2011
  116. 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 25Wednesday, May 18, 2011
  117. 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 25Wednesday, May 18, 2011
  118. 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 25Wednesday, May 18, 2011
  119. 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 26Wednesday, May 18, 2011
  120. 120. Example: decorating roles DCI 27Wednesday, May 18, 2011
  121. 121. Q &A • Question Time DCI 28Wednesday, May 18, 2011
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×