10. Conclusion
A question that sometimes drives me hazy:
am I or are the others crazy?
Albert Einstein

The goals of this thesis have all been reached. We have presented the basic theory necessary to understand the "Gang of Four" patterns with a practical approach focusing on Java 6. We have defined an evaluation approach on how to evaluate the "Gang of Four" patterns using a language as the catalyst. Using this approach, we have implemented the "Gang of Four" design patterns in Java 6, and performed a detailed and a comparative evaluation from the perspective of a practicing designer and/or developer. The evaluations and the conclusions have been presented in this thesis. A short evaluation of the defined evaluation approach has also been offered. This chapter presents the overall thesis results and conclusions from our established perspective. We outline ideas for future work, and end this thesis with a few final remarks regarding the project and work performed.

10.1.  Perspective
This thesis is a report on what has been achieved in this project. Its approach is experimental and practical, explanatory in nature. This is because we view the use of design patterns as a practical discipline based on the inclinations of the user. It is all about choices. The choice to use patterns as an aid in the design process, the choice of pattern to use for a given context, the choice of programming language. Patterns are all about interpretation. Interpretation of the pattern description, of the sample code, and ultimately of the pattern functionality in order to apply the pattern. Patterns are all about learning from experience. Utilising the experience of others prevents the need to reinvent the wheel. However, because choices and interpretations must be made, the use of patterns is also a learning process that augments the user's experience. While a design pattern is recorded by its author, the success and eventual applicability is based on the choices, interpretations, and experiences made by the user. The evaluation presented in this thesis is no different. Many choices and decisions have been made during the project, and a lot of valuable experience has been gained from the in—depth work with the "Gang of Four" patterns and Java 6. Several important issues related to their practical application have been learned. This thesis has strengthened our belief that the "Gang of Four" patterns can be a valuable aid in the design process and that they are applicable using languages other than C++ and Smalltalk. By using Java 6 as the programming language we have illustrated that the patterns can be implemented in a variety of ways that might differ greatly from the canonical "Gang of Four" implementations, including as far as we can tell novel approaches in several pattern implementations, while still expressing the pattern intent, qualities, and forces. However, the high level of abstraction combined with practical experience is a key issue as to why we do not believe built—in language support is possible for design patterns in general.

10.2.  Results
As stated in the initial goals, the primary objective of this Master's Thesis is for the undersigned to obtain a Master's Degree in Computer Science. This thesis represents a project with a formal workload of 30 ECTS, and it presents the work performed during the project. To obtain the degree, the project and thesis must be approved after an oral examination based on this thesis. We feel the work performed has been educational; we perceive it as comprehensive and satisfactory, rigorously presented, thereby warranting such an approval. The introduction defined a set of sub—goals, I-IV, for the work to be performed during the project. The goals have all been achieved and presented in this thesis:

  1. Theory and Background We have performed extensive research and presented theory and background related to OO development and patterns relevant to the implementation and evaluation, but with focus on practical application and Java 6 usage. We have explained how design patterns can be used as a practical tool in the development process regardless of the OO method used, and identified the OO concepts and themes relevant for the "Gang of Four" patterns, including their relation to Java 6. We have introduced the pattern theory on which the "Gang of Four" patterns are founded, and provided numerous examples to illustrate OO and pattern theory from a more practical and Java related view. We have presented the "Gang of Four" pattern system and established an informal classification of their relationships. We have examined and related several studies on how language features can influence the "Gang of Four" design patterns. The studies conclude that dynamic features and reflection can aid the pattern implementation, while static features can promote Structural pattern componentizations. We have shown this is a fine match to Java 6 with its mixture of static and dynamic features. We believe the extensive focus on practical aspects and Java 6 with regards to the theory and the "Gang of Four" patterns provides consistency throughout this thesis.
  2. Evaluation Approach We have defined a simple, but structured approach used to conduct the evaluation. The approach is general enough for reuse in similar evaluations, using other languages as catalysts. By specifically utilising pattern elements described by Gamma et al., the approach is closely tied to the "Gang of Four" patterns, but it makes it easier to verify the otherwise subjective results.
  3. Implementation We have implemented the "Gang of Four" patterns in Java 6 within the realm of the evaluation approach, fully documented in JavaDoc, with clearly identifiable pattern participants. Several reusable Meta classes help provide realistic pattern functionality. We have been methodical and thorough in merging "Best Practices" from the "Gang of Four" design patterns with that of Java. The quality of the implementations is therefore high and adhere to the concepts and themes defined by Gamma et al., but also to Java—specific issues described by Bloch [Bloch01].
  4. Evaluation We have performed a comparative as well as detailed evaluation of the pattern implementations using the defined approach. The detailed evaluation provides comprehensive UML class diagrams, description of pattern participants, but most importantly illustrates how practically all functionality described in the relevant "Gang of Four" pattern elements can be implemented in Java 6. The comparative evaluation provides an in—depth investigation on how Java 6 features and mechanisms are applied across all patterns to identify common traits and relationships. Based on the evaluations, we have identified the following high—lights:

We have also evaluated the evaluation approach and determined it to be useful, albeit found it wanting in certain respects. We have recommended improvements to make future evaluations even more thorough.

The contributions made by this thesis are:

10.3.  Future Work
Before a few final remarks, we list possible future studies related to the work presented in this thesis.

  1. Adjust the evaluation approach to include at least the Consequences element in favour Sample Code for a more thorough evaluation, because Sample Code in general did not provide additional information.
  2. Provide in—depth studies of the presented high—lights, including studies on possible language support for described patterns. For example, what will be the cost of adding a singleton keyword to Java to express Singleton functionality as when implemented using the Singleton—as—Single—Constant idiom? Are there patterns or language idioms that could be promoted to language features? Is it worth adding generic factories to the Java API? Is dynamic proxy usage viable in real—life systems? Annotations?
  3. Describe new "participants" or functionality expressed in the evaluation. This includes Command spawning new commands, generic factories, Singleton—as—Single—Constant idiom, guarded types, etc.
  4. Using different language catalysts for evaluation. It could be truly interesting to apply the evaluation approach using a prototype—based language and corresponding OO taxonomy. This is no small task as the concepts and themes described by Gamma et al. are clearly targeted at class—based languages.
  5. Apply the evaluation approach using different design pattern systems, for example the "POSA" patterns. This will require adaptation to the pattern format used, but is certainly manageable. A bigger task is perhaps to ensure a consistent understanding of the OO concepts and themes. It could be interesting to see if the features and techniques applied in this evaluation are applicable elsewhere.
  6. One of the reasons for choosing Java 6 over Java 5 was the support for annotation processing via Sun's Annotation Processing Tool (APT). The original idea was to prime APT with a handler that would traverse the source code and gather information about patterns and participants, thereby generating a summary of pattern usage. Perhaps even compiling code that could be utilised at runtime to enhance pattern support akin to Meta Data expressed with classes. This could also aid the documentation. As explained, this could be a very interesting tool to implement, with many exiting possibilities.
  7. Target the implementations for reusable components. The evaluation shows that Creational and especially Behavioural patterns are good candidates for componentization.
  8. For completeness, implement Mediator and evaluate the secondary objective of this thesis, to establish if this thesis could be helpful to others pondering with the "Gang of Four" patterns and language issues. This could be a practical survey among co—workers, discussion group, or lectures on the findings, etc.

10.4.  Final Remarks
Our initial goals have been reached, though we did not accomplish all we set out to do, in part because we changed focus half way through corresponding to the work description available as [Rode07a]. We believe others may benefit from the experiences and results presented in this thesis, perhaps using it actively and practically. It has been educational to write, and we hope it will be educational to read, thus causing developers and others to think more actively about design patterns.