A Semantic Representation for Domain-Specific Patterns Susana Montero, Paloma Díaz, and Ignacio Aedo Laboratorio DEI. Dpto. de Informática, Universidad Carlos III de Madrid, Avda. de la Universidad 30. 28911 Leganés, Spain {smontero, pdp}@inf.uc3m.es,
[email protected] http://www.dei.inf.uc3m.es
Abstract. Design patterns are a valuable mechanism to capture and disseminate best practice in software design. The oft-cited definition of an Alexandrian pattern, a solution to a problem in a context”, stimulates the definition of patterns from knowledge and expertise in any domain. Indeed, their application has spread from the object-oriented community, who first adopted them, through different software areas including human-computer interaction, virtual environments, ubiquitous computing, hypermedia and web engineering. This kind of patterns that describe successful solutions to recurring design problems in terms of a specific domain of application are known as domain-specific patterns. The increasing number of available design patterns is making difficult to find the most appropriate one given a specific problem since this task requires mastery on existing design patterns. Hence, there is a need to introduce a formalism to describe them accurately and to allow a rigorous reasoning process to assist users to retrieve those patterns that solve their problems. With this purpose, we propose a semantic representation for domain-specific patterns based on the domain knowledge for which they were written and for which an ontology-based approach is applied. This representation is used as an underlying armature for complementing the informal textual pattern description by means of semantic annotations. The combination of the literary pattern representation with its formal representation counterpart could assist an intelligent search engine that supports users not just for retrieval purposes but also for the discovery useful design solutions improving, therefore, their ability to develop quality software.
1
Introduction and Motivation
In 1977, the architect Christopher Alexander and his colleagues introduced the pattern metaphor as a mechanism to capture the essence of successful solutions to recurring design problems in urban architecture [2]. Patterns are generally intended for human/manual use as they are structured but informal documents made up of a series of fields, including the problem that the pattern addresses, the context in which it is used, and the suggested solution written in natural language. This idea of capturing knowledge into patterns was adopted by the object-oriented community as an effective mean for reusing best practice in software design [10]. Moreover, their continued usage U. Kock Wiil (Ed.): MIS 2004, LNCS 3511, pp. 129–140, 2004. c Springer-Verlag Berlin Heidelberg 2005
130
S. Montero , P. Díaz, and I. Aedo
among designers and developers has turn the names of patterns into a shared vocabulary for expressing and communicating knowledge. The oft-cited definition of an Alexandrian pattern, a solution to a problem in a context”, is so general that allows patterns to be formed from knowledge and expertise in any domain. This quality together with the aforementioned benefits have spread the adoption of patterns to other fields, whether or not software-related. Some of these fields related to the software area include human computer interaction [5], security [1] and hypermedia [18]. All these kinds of patterns are embraced in a broader term denominated DomainSpecific Pattern and it is this category that strongly motivates our work. In recent years, the number of domain-specific patterns has increased drastically. For this reason, repositories, tools and methods for searching and selecting a particular pattern in an intelligent way are required to improve the ability of developers to produce high quality software reusing good design solutions. Current approaches to represent patterns are document-based, at best supported with hypertext tools on the Web, meaning that effective use is difficult. For a designer or a domain expert, finding suitable patterns for a particular purpose is increasingly problematic. They need to be aware of existing patterns and to understand when they should be applied. In this paper, we propose a semantic representation for domain specific patterns based on the domain knowledge for which they were written. For that purpose, both the pattern format and the domain are reflected separately in a representational vocabulary using an ontology-based approach. Subsequently, this representation is used as an underlying armature for complementing the informal textual representation of patterns by means of semantic annotations. The combination of both makes patterns mutually understandable to stakeholders and machines. Finally, this general model is applicable to domain-specific patterns whether or not software-related, providing the semantic foundation on which to build standardised patterns collected in repositories and to develop tools for intelligent reasoning. This kind of efforts comprise what Engelbart identified as B-level activities [8], that are those oriented towards reducing the product-cycle time, that is, towards improving the ability to perform our core activity. The approach presented here is intended to facilitate software reuse and, thus, to improve our ability to develop quality software by reusing tested knowledge and expertise. As the specific domain area used to illustrate this approach is the hypermedia arena, this work is expected to constitute one contribution to the B’s David L. Hicks was looking for in [15]. This paper is structureed as follows: Section 2 briefly introduces the concept of Domain Specific Pattern and provides some examples of these patterns. Section 3 presents related work on the formal specification of patterns. Section 4 describes our model for the representation of domain-specific patterns from their semantics, its underlying rationale as well as their formal components. Section 5 subsequently illustrates our approach with a case study and section 6 finally presents some conclusions and the future directions of our research shall take.
2
Domain-Specific Patterns
Design patterns have proven that they are a natural way for the formulation of accumulated expertise. It all began in the field of building architecture. The software engineering
A Semantic Representation for Domain-Specific Patterns
131
community enthusiastically embraced the patterns concept and their field of application has been extremely broadened. We can find patterns in other software areas such as hypermedia, security, user interfaces, real-time systems or even in knowledge areas such as communication, economy or education. As a consequence, large knowledge repositories of domain-specific patterns are being created. To illustrate this situation, we present some software domains that have an important literature together with an example of pattern. – Human-computer interaction. These patterns are focused on solutions to problems that end-users have when they interact with systems, being the usability the essential design quality. Interaction design patterns collections are publicly available in books [5] or online [21] with a total count of more than 250 published patterns. For example, the Progress pattern should be used when the user wants to know whether or not the operation is still being performed as well as how much longer the user will need to wait. This pattern proposes that the application provides a valid indication of progress while it is still working [21]. – Security. A security pattern is a well-understood solution to a recurring information security problem the aim of which is to allow developers to make informed trade-off decisions between security and other goals. These patterns include different aspects of security such as security models, application security or cryptography [1]. Moreover, the pattern template [10] has been altered to convey more security-relevant information [16]. An example of security pattern is the Check Point pattern which proposes a structure that checks incoming requests, and in case of violations, the Check Point is responsible for taking appropriate countermeasures [16]. – Hypermedia. Hypermedia patterns are commonly used in any type of hypermedia design, including web applications, to deal with the different aspects of conceptual design (interface, content structure, navigation, dynamics, interaction). The first hypermedia patterns were presented by Rossi [18], and many more have since been published [12]. As example of hypermedia pattern, the Index Navigation pattern provides fast access to a group of nodes, adding a node which contains an entry point for each node of the group and vice versa [11]. Next section discusses existing representations of patterns and their suitability for capturing the knowledge domain of these patterns and the automatic support for organisation, retrieval and provision of explanations.
3
Related Work
Design patterns usually are expressed in natural language, through a specific structure. Although, there are different formats [17], they usually contain certain essential elements that describe the context in which the problem occurs, the intent and statement of the problem, a description of the relevant forces that justify why the pattern and implementations should be used and how to generate the solution. Although this representation is the most suitable to understand the rationale behind a pattern, there is a limitation to precision due to the use of natural language and the semantic ambiguity. This feature does not allow any level of automation to resolve problems widely recognised such as finding and selecting the appropriate patterns or applying them.
132
S. Montero , P. Díaz, and I. Aedo
In order to resolve these problems there have been several attempts to provide design patterns with certain formalism in the object oriented community, but not in other domains. For example, the Cornils and Hedin [6] model design patterns using reference attributed grammars with syntactic and context-sensitive rules. Eden et al. [7] define LePlus (LanguagE for Patterns Uniform Specification) from Higher-Order logic to represent design patterns as logic formulas which consist of participants (i.e. classes, functions or hierarchies) and relations imposed amongst them. Smith and Stotts [19] use an extension of sigma calculus which defines relationships between the elements of object oriented language to express design patterns. Finally, Taibi and Ling Ngo [20] are concerned with specifying both the structural and behavioural aspect of design patterns using first order logic for the former and temporal logic for the later. This approach describes patterns in terms of entities (classes, attributes, methods, objects and untyped values) and relations that express the way entities collaborate. The main advantage of these approaches is their rigourous reasoning since they are based on formal specification languages. However, this advantage can turn into a strong disadvantage if the user cannot easily understand how patterns have been specified or how to specify new patterns. Most of the reported approaches adopt a well-defined mathematical semantics to describe the object-oriented domain that it is not readable by people from outside the software engineering profession and lacking mathematical skills. In the case of domain specific patterns, they are used by both domain experts and novices whose knowledge is focused solely on the application domain. Moreover, most of domain-specific patterns not described in terms of classes, objects, etc., but in terms of components of the application domain, so the aforementioned approaches can not be applied directly. Finally, they reflect only the pattern solution, but a pattern is much more than this. Besides teaching the rationale behind the solution and its trade-offs [3], a pattern captures how and when to apply the solution. All of these elements are needed for the development of support tools for organisation, retrieval and provision of explanations. For example, including the intent section of a pattern description in the formalisation would allow for indexing of patterns according to the problem that resolve, helping users find the correct pattern for a design problem. A formalisation of a pattern description cannot replace the understandability of the natural language description but can be thought of as a complement.
4
An Ontology-Based Approach
As aforementioned, the objective of our approach is to provide an underlying formalism that complements the textual description of the domain specific patterns based on the same terms experts use to describe their domain knowledge. To achieve this aim, our approach is based on the use of ontologies. Ontologies have as main motivation help programs and humans share and reuse knowledge bodies [14] providing the following benefits to our solution: – Well-defined semantics. Patterns are described in textual form which can be ambiguous and sometime misleading in their understanding and application. This
A Semantic Representation for Domain-Specific Patterns
133
approach provides a formalism that allow us to know precisely what we mean when we use domain-specific terms and concepts. – Rigourous reasoning. Patterns to be understood by machines need a formalism that supports reasoning. Ontologies can provide reasoning service over information expressed since ontology specification languages are usually based on a particular kind of formal logic [13]. – Browsing/Searching. Due to the large amount of patterns there is a need for tools to make patterns accessible in more than one way. Our approach can assist an intelligent search engine that supports users not just for retrieval but for discovery. These tools can generate different views or offer dedicated search functionality to select appropriate patterns. – Interoperability. Different repositories that hold patterns formalised with different ontologies should coexist. Ontologies enable the integration of information from diverse resources, allowing different ontologies to model the same concepts of the application domain in different ways. 4.1
A Representation Framework
Our approach is based on three types of ontologies that supply the basic structure or armature around which domain-specific patterns can be built, as shown in Figure 1.
Fig. 1. Import relations between the ontologies for domain specific patterns using the UML package notation
– The pattern components. This ontology gathers the elements that are part of the pattern template, but independent of any particular domain. Patterns, in general, follow a format to describe a proven solution to a recurring design problem [2]. Depending on the level of detail of each domain more specific components to describe its patterns including diagrams, examples of use or pointers to related patterns can be added here [17]. – The domain knowledge. This domain ontology describes the vocabulary and background knowledge of the domain of application. Examples of this ontology can be the core knowledge needed to describe human computer interaction, security or hypermedia patterns.
134
S. Montero , P. Díaz, and I. Aedo
– The domain specific pattern. This ontology imports the above ontologies to define an explicit mapping between them. This allows us to keep the pattern template and the domain specific knowledge separate since each domain depending on its needs uses more or less fields to describe its patterns and the later ontology changes according to the domain knowledge that the pattern captures. Each of these ontologies specifies the representational vocabulary in the corresponding domain, with agreed-on definitions of the terms in declarative form. Definitions may include axioms, constraints, relationships among concepts, and hierarchies of the problem domain. Once the domain specific pattern ontology is specified, it acts as a semantic backbone for making semantic annotations to the textual pattern description. This framework can be instantiated in different domains for modelling their domain-specific patterns. 4.2
AnnotPat: An Ontology-Based Pattern Annotation Tool
Semantic annotation deals with assigning links to the semantic description of raw data in order to produce data that are machine-processable. Semantic annotation is applicable to any sort of text, audio, video, and currently to web pages in order to build the semantic web [4]. In this context, semantic annotation is formalised from two sets of objects, documents and formal representations and two functions can be created: a function from document to formal representations, called annotation and a function from formal representations to documents called index [9]. The work presented here is related to the first function. As mentioned previously, we aim to enrich the textual pattern description to enable the development of tools for the automatic organisation, retrieval and explanation of domainspecific pattern collections. The overall approach is depicted in Figure 2. Domain-specific patterns are annotated by domain experts or novices using an annotation tool called AnnotPat. AnnotPat provides the facility to annotate a textual pattern description with its appropriate semantic terms. Thus, a formalised pattern can be extracted and stored together with its textual representation, suitable for further processing. From the knowledge base and a inference engine different tools can be developed, such as a query tool to search and retrieve suitable patterns in terms of the ontology, a web community portal through which pattern knowledge can be gathered, stored, secured and accessed by members, or support tools that interact with other systems, to help users select and apply patterns according to the application context. With regard to the AnnotPat tool, it reads an OWL file containing a domain-specific pattern ontology specification. OWL 1 is the W3C recommended language to describe ontologies. From this specification, the tool generates a user interface for patterns annotation. Figure 3 shows a snapshot of the annotation interface which is divided into two sides. The left side shows the status of annotations made by the user as a domain-specific pattern ontology instance. The right side shows the template pattern where the textual descriptions are typed and annotations are made. After typing the pattern, the user can make 1
http://www.w3.org/2004/OWL/
A Semantic Representation for Domain-Specific Patterns
135
Fig. 2. The approach overview
Fig. 3. Snapshot of the annotation interface. The user has highlighted a piece of text to make an annotation
136
S. Montero , P. Díaz, and I. Aedo
annotations in order to link words with terms. For that, she first needs to highlight a relevant piece of text and does click with the right mouse button. A pop-up menu is displayed with the possible terms according to the pattern element selected, for easier use. In the next section, we put the high-level rationale outlined above into a concrete perspective, hypermedia design patterns.
5
A Study Case: Hypermedia Patterns
Before making any annotation on hypermedia patterns, we need to define the domain ontology from which these patterns capture the domain solutions. Hypermedia patterns are described by a number of terms and concepts that describe the general features of hypermedia applications. Taking into account only the elements related to their structure, all hypermedia applications can be described in a simple way from the following terms:
Fig. 4. Snapshot of the Protégé ontology editor v. 2.1.2 showing part of the domain-specific pattern ontology
– Node is an information holder able to contain a number of contents. Examples of nodes are a web page, a frame or a pop-up window. – Content is a piece of information of any type like text, audio, graphics, animations or programs. – Link is a connection among two or more nodes or contents. A link is defined between two set of anchors.
A Semantic Representation for Domain-Specific Patterns
137
Fig. 5. The Index Navigation pattern in RDF format
– Anchor is the source or target of a link, and determines a reference locus into a node and/or content. Secondly, the template of the domain specific pattern is defined by means of the mapping between the hypermedia domain ontology and the fields needed to describe the domain specific patterns giving the Hypermedia Design Pattern ontology as a result. We specified all ontologies in OWL using the Protégé 2 ontology editor and its OWL plugin. This editor allows users to build ontologies in a frame-like way by means of classes, properties and axioms. Finally, we can use the AnnotPat tool in order to annotate a pattern with the final domain specific pattern ontology. To demonstrate this process, we used the Index Navigation pattern explained in the section 2. From the typed text of this pattern, the following annotations are made. The name is IndexNavigation and the pattern is related to another pattern called Hybrid Collection [11]. The element Category describes the level of abstraction and design aspect which suggest when a pattern could be used. For this example, the pattern is considered 2
http://protege.stanford.edu/
138
S. Montero , P. Díaz, and I. Aedo
conceptual since no detail about the solution implementation is provided and it belongs to the navigational category since its aim is to organise the navigation through the hypermedia application. The element Problem describes the scenario in which the pattern is applied by means of aim, which uses keywords to identify the reason why the pattern should be used, and state, which defines what hypermedia elements participate in the problem scenario. In the case of this pattern, its aim is to provide fast access to nodes. Finally, the element Solution describes how to obtain the desired outcome by means of state which defines what hypermedia elements participate in the solution scenario. As the solution of this pattern is to add a new node that contains entry points for each node, the actors that participate in the solution state are: the nodes of the problem state, the new node that represents an index, and the links between the two types of nodes. The result of the annotation process is showed in Figure 3 where the highlighted text means the annotated words. Figure 5 shows the Index Navigation pattern formalised as an instance of the domain specific pattern ontology in RDF 3 format ready to be shared by repositories and processed by reasoning tools.
6
Conclusions and Future Work
In this paper, we presented an ontology-based approach that allows designers and domain experts to enrich their domain-specific patterns with semantic annotations using their domain concepts and terms. The representation framework keeps the pattern template and the domain specific knowledge separate since each domain depending on its needs uses more or less fields to describe its patterns and the later ontology changes according to the domain knowledge that the pattern captures. This feature allow the framework to be applicable to any domain providing the formal foundation to build standardised patterns collected in repositories and intelligent tools for their automatic organisation, retrieval and discovery. The most valuable contribution of this approach is to be both human and machine readable, since the text pattern description is linked to its formal representation, protecting the essence of design patterns: express and communicate successful solutions to common problems between practitioners. In this way, patterns become more easy to reuse and, therefore, the developer’s ability to produce quality software can be improved. In a general sense, this work address a B-level activity within the Engelbart’s ABC of improvement infrastructure [8] that is aimed at helping software developers to enhance their core activity. Finally, we are working on enhancing the AnnotPat tool and provide personal and shared spaces such as web repositories or communities.
Acknowledgements Thanks to Damaris Fuentes, who implemented the AnnotPat tool prototype. The authors also wish to acknowledge the constructive suggestions provided by the reviewers and 3
The W3C recommendation for representing metadata, http://www.w3.org/RDF/
A Semantic Representation for Domain-Specific Patterns
139
the research assistants. Finally, this work is supported by Dirección General de Investigación de la Comunidad Autónoma de Madrid and Fondo Social Europeo (CAM and FSE) (07T/0024/2003 1).
References 1. Security Engineering With Patterns: Origins, Theoretical Models, and New Applications. Springer-Verlag, 2003. 2. C. Alexander, S. Ishikawa, M. Silverstein, M. Jacobson, I. Fiksdahl-King, and S. Angel. A Pattern Language: Towns, Buildings, Construction. Oxford University Press, New York, 1977. 3. B. Appleton. Patterns and software: Essential concepts and terminology, 2003. 4. T. Berners-Lee. Semantic web road map. w3c design issues. 5. J. O. Borchers. A Pattern Approach to Interaction Design. John Wiley & Sons, 2001. 6. A. Cornils and G. Hedin. Tool support for design patterns based on reference attribute grammars. In Proc. of WAGA’00, Ponte de Lima, Portugal, 2000. 7. A. H. Eden, A. Yehudai, and J. Gil. Precise specification and automatic application of design patterns. In Proc. of International Conference on Automated Software Engineering (ASE ’97), pages 143–152, Lake Tahoe, CA, USA, 1997. 8. Douglas C. Engelbart. Augmenting Human Intellect: A Conceptual Framework. Technical report, Air Force Office of Scientific Research, 1962. 9. J. Euzenat. Eight questions about semantic web annotations. IEEE INTELLIGENT SYSTEMS, 17(2):55–62, 2002. 10. E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns, Elements of Reusable Object-Oriented Software. Addison-Wesley, 1994. 11. F. Garzotto, P. Paolini, D. Bolchini, and S. Valenti. Modeling-by-Patterns of web applications. In Advances in Conceptual Modeling: ER ’99 Workshops on Evolution and Change in Data Management, Reverse Engineering in Information Systems, and the World Wide Web and Conceptual Modeling, pages 293–306, 1999. 12. D. German and D. Cowan. Towards a unified catalog of hypermedia design patterns. In Proceedings of 33rd Hawaii International Conference on System Sciences, Maui, Hawaii, 2000. 13. A. Gómez-Pérez and O. Corcho. Ontology specification languages for the semantic web. IEEE Intelligent Systems, 17(1):54–60, 2002. 14. T. R. Gruber. A translation approach to portable ontologies. Knowledge Acquisition, 5(2):199–220, 1993. 15. D.L. Hicks. In search of a user base: where are the b’s. In Metainformatics 2002, volume 2461 of LNCS, pages 112–117, 2003. 16. S. Konrad, B. H. C. Cheng, L. A. Campbell, and R. Wassermann. Using security patterns to model and analyze security requirements. In Proc. of the Requirements for High Assurance Systems Workshop (RHAS03) as part of the IEEE Joint International Conference on Requirements Engineering (RE03), Monterey Bay, CA, USA, September 2003. 17. L. Rising. Pattern forms. In Proceedings of Viking PLOP 2003, 2003. 18. G. Rossi, A. Garrido, and S. Carvalho. Design Patterns for Object-Oriented Hypermedia Applications. Pattern Languages of Programs II. Addison-Wesley, 1996.
140
S. Montero , P. Díaz, and I. Aedo
19. J. Smith and D. Stotts. Elemental design patterns: A link between architecture and object semantics. Technical Report Technical Report TR02-011, Univ. of North Carolina at Chapel Hill, March 2002. 20. T. Taibi and D. C. Ling Ngo. Formal specification of design patterns - a balanced approach. Journal of Object Technology, 2003. 21. M. Van Welie. Amsterdan collection of patterns. URL: http://www.welie.com. Visited January 2004.