CSC/ECE 517 Fall 2009/wiki2 12 PatternClassification: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
(56 intermediate revisions by the same user not shown)
Line 1: Line 1:
Originality, Clarity, Coverage, Definitions, Examples, Links, Organization.
= Introduction =
Patterns are often classified into creational, structural, and behavioral categories. However, this leaves a large number of patterns in each group, with no easy way of remembering all of them. What classifications and strategies have been developed to help programmers remember patterns, so that they can apply them at opportune moments?
 
This article is intended for experienced programmers who are well in versatile patterns. It is not intended to familiarize the reader with the concept of a design pattern. If interested in learning what design patterns are please refer to [http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29 Design Pattern]. The intent of the article is not to describe existing patterns and their usage but rather introduce a other ways of categorizing and cataloging of patterns.
 
This article relies heavily on the [http://www.cs.tut.fi/~kk/webstuff/PatternClassificationKalvot.pdf presentation by Imed Hammouda and Jakub Rudzki]. We would like to thank them for their contribution to the field of design patterns and helping us to better understand pattern classification.


= Definition =
= Definition =


A pattern is a solution to a problem in its context.  A context is specific to the domain in which the problem is being solved.  For example, in computer science software engineers often are surrounded by problems in similar contexts such as web and database infrastructure.  Within these contexts there are repeatable solutions.  Those solutions when described abstractly are are what we call patterns.   
A pattern is a solution to a problem in its context.  A context is specific to the domain in which the problem is being solved.  For example, in computer science software engineers often are surrounded by problems in similar contexts such as web and database infrastructure.  Within these contexts there are repeatable solutions.  Those solutions when described abstractly are are what we call patterns.  A pattern in itself is not a finished solution to a problem but rather a template on how to solve a given problem which can arise in a variety of different situations (contexts)[1]


A more abstract concept than a pattern is a schema.  A schema does not necessarily have any context but it does have structure and attributesMany times schemas and patterns are mistakenly interchangedThe key to pattern recognition is that its context be described so that others can identify its usages.
The goal of patterns is to recognize and make use of a library of knowledge that can be used to solve problemsOften times, the same problems are 're-solved' without learning from the past experiencesAs long as we have similar contexts we will have patterns or knowledge that develop from those solved problems.  


The goal of patterns is to recognize and make use of a library of knowledge that can be used to solve problems.  Often times, the same problems are 're-solved' without learning from the past experiences. As long as we similar contexts we will have patterns or knowledge that develop from those solved problems.  
== Example ==
The company you work for decides to switch a different database vendor which in turn requires you to change the interface for a set of objects in the software you designed.
It turns out that the change of interface is a common problem not just for the databases but in general in software development. In this case you would use a Adapter pattern in the context of database development.


= Problem =  
= Problem =  


The problem with patterns is classification and recognition or usage.  For example, a pattern that is not classified correctly will not be remembered and used.  Several attempts to classify patterns has been made.  The existing software classification of patterns uses the categories of:
The problem with patterns is classification and recognition or usage, i.e. what type of patterns to use for each given case.  For example, a pattern that is not classified correctly will not be remembered and used.  Several attempts to classify patterns has been made.  The existing software classification of patterns uses the categories of:
 
* Structural
* Behavioral
* Creational
 
While these are good starting points for patterns, it is very hard to make use of this information in different contexts.
 
= Existing Work =
 
[http://c2.com/cgi/wiki?GangOfFour The Gang of Four] patterns are the most famous.  They are classified according to creational, structural and behavioral groups.  There is also a J2EE catalog of patterns by SUN.  These are all classified as J2EE patterns but they can be split into presentation, business, and integration tier patterns.
 
There is a good [http://www.cs.tut.fi/~kk/webstuff/PatternClassificationKalvot.pdf presentation] regarding pattern classification by Imed Hammouda and Jakub Rudzki.  In the presentation they suggest that patterns can be classifed by:
 
* Domain
* Paradigm
* Granularity
* Purpose
* Scope
* Discipline
 
== Domain ==
 
Domain specific classification may help make patterns more useful in various contexts.  This is because the solution to the problem will be more specific to the context.  Below are some examples of domain specific classification.
 
'''[http://en.wikipedia.org/wiki/Factory_method_pattern Factory method]''' - Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.[1]
'''[http://en.wikipedia.org/wiki/Object_pool Object pool]''' - Avoid expensive acquisition and release of resources by recycling objects that are no longer in use.[1]
 
'''[http://en.wikipedia.org/wiki/Adapter_pattern Adapter or Wrapper]''' - Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.[1]
 
'''[http://en.wikipedia.org/wiki/Interpreter_pattern Interpreter]''' - Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.[1]
 
== Paradigm ==
Paradigm classification is a categorization of a pattern according a programming paradigm. In [http://en.wikipedia.org/wiki/Object-oriented_programming OOP] patterns take forms of classes, objects and inheritance while in [http://en.wikipedia.org/wiki/Imperative_programming imperative programming] patterns take form of procedures and functions.
 
Below are examples of patterns for functional logic languages taken from [2] and [3]
 
'''Opaque Type''' - Ensure that values of a datatype are hidden.
 
'''Locally Defined Global Identifier''' - Ensure that a local name is globally unique.
 
'''Incremental Solution''' - Compute solutions in an incremental manner.
 
'''Concurrent Distinct Choices''' - Ensure that a mapping from indexes to values is injective.
 
'''Constrained Constructor''' - Prevent invoking a constructor that might create invalid data.
 
== Granularity ==
This kind of categorization refers to the system level where the patterns are used at. For this category it is sometimes hard to draw a border between levels and the pattern might be used at different granularity categories. Below are the examples of pattern classification based on granularity classification. These examples were taken from [2] and [4]
 
'''Architectural patterns''' - refer to a software system at high level. Examples of these patterns would be [http://en.wikipedia.org/wiki/Layer_%28object-oriented_design%29 Layer], [http://en.wikipedia.org/wiki/Model-View-Controller Model-View-Controller] and [http://en.wikipedia.org/wiki/Multitier_architecture Multitier architecture]
 
'''Design patterns''' - focus on subsystems and components. Examples of these patters would be [http://en.wikipedia.org/wiki/Factory_method_pattern Factory method], [http://en.wikipedia.org/wiki/Object_pool Object pool] and [http://en.wikipedia.org/wiki/Adapter_pattern Adapter or Wrapper]
 
'''Idioms''' - address the lowest level of a software system. A good example of these would be [http://c2.com/cgi/wiki?JavaIdioms Java Idioms]
 
== Purpose ==
Purpose represents a specific type of a problem a pattern is trying to solve. It is the most useful criterion since it describes the exact situation where the pattern is used.
 
Below are examples which were taken from [2] and [5]
 
'''Architectural support patterns''' - represent the strategic decisions for the organization of real-time applications.
 
'''Collaboration and distribution''' - patterns provide solutions to common application domain problems in real-time systems.
 
'''Safety and reliability patterns''' - deal with common problems of safety and reliability.
 
'''Behavioral patterns''' - provide different implementation solutions involving multiple objects.


# Structural
== Scope ==
# Behavioral
Scope classification is categorization of patterns according to features implemented in a given pattern. As an example in [http://en.wikipedia.org/wiki/Object-oriented_programming object-oriented design] patterns can be classified using either class inheritance or object composition
# Creational


While these are good starting points for patterns, it is very hard to make use of this information in different contexts.
== Discipline ==
It is perhaps the easiest and most natural way to classify patterns, i.e. categorize them according to a field or discipline where they are used, i.e. music, engineering, or economy. It is unlikely (but not impossible) that a pattern used in one discipline becomes relevant to another.


== Domain Specific Classification ==
= Article Definitions =
'''Gang of Four''' - also known as GoF. The authors of the Design Patterns book.


Domain specific classification may help make patterns more useful in various contexts. This is because they solution to the problem will be more specific to the context.  Here are some examples of where domain specific classification was used:
'''''M''odel-''V''iew-''C''ontroller''' - MVC for short, Architectural design pattern.


# [http://www.cs.helsinki.fi/u/salaakso/patterns/index.html User Interface]
# [http://vis.berkeley.edu/papers/infovis_design_patterns/ Information Visualization]
# [http://simson.net/thesis/ Computer Security]
# [http://developer.yahoo.com/ypatterns/ Web Applications]


For example, when building a webapp it is useful to use the Model-View-Controller pattern to organize access and control to and from the domain data.  This pattern is structural.  However, if a novice developer was to start building a webapp from scratch, would they turn to the literature on MVC to start their webapp architecture?
= Related Links =


I propose that a novice would not because it would be too difficult to understand 'how' MVC applies to their context, webapps. This is a failure of patterns and the existing pattern classification scheme. We propose that for software patterns to be more recognizeable and useful for the average developer, the specific context should be explicitly described. For example, the context of webapps, MVC solution is very different than the context in GUI applications. Although the same pattern can be used in both, the problems are solved differently. Thus we actually say MVC is a schema and not a pattern. This may be controversial so we shall provide evidence for why view is worthy of acceptance.
* [http://www.cs.helsinki.fi/u/salaakso/patterns/index.html User Interface]
* [http://vis.berkeley.edu/papers/infovis_design_patterns/ Information Visualization]
* [http://simson.net/thesis/ Computer Security]
* [http://developer.yahoo.com/ypatterns/ Web Applications]
* [http://www.cs.tut.fi/~kk/webstuff/PatternClassificationKalvot.pdf Pattern Classification]
* [http://pattron.net/default.aspx A pattern catalog]
* [http://www.cs.umu.se/~jubo/ExJobbs/MK/patterns.htm Classification of Object Oriented Design Patterns]
* [http://www.patternforge.net/wiki/images/0/0c/Kudelka.pdf New Pattern Classification Approach]
* [http://java.sun.com/blueprints/patterns/catalog.html J2EE Patterns]


Although patterns always existed, they were first described in a book by Christopher Alexander called [http://en.wikipedia.org/wiki/A_Pattern_Language "A Pattern Language - Towns, Buildings, Construction"].  Looking at patterns from the perspective of architecture, we see that the context is very important.  For example, repeatable solutions for construction of buildings exist only for very specific contexts.   
= References =
[1] [http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29 Design Pattern]


= Existing Work =
[2] [http://www.cs.tut.fi/~kk/webstuff/PatternClassificationKalvot.pdf Pattern Classification] by Imed Hammouda & Jakub Rudzki


= Sources Other Engineering Disciplines =
[3] S. Antoy and M. Hanus. “Functional Logic Design Patterns”. In Proc. Of the 6thInternational Symposium on Functional and Logic Programming (FLOPS 2002), Aizu (Japan), Springer LNCS 2441, pp. 67-87, 2002.


= Examples =
[4] F. Buschmann, R. Meunier, H. Rohnert, P. Sommerland and M. Stal. ”Pattern-Oriented Software Architecture: A System of Patterns”. Wiley , (1996).


= Links =
[5] B. P. Douglass. “Doing Hard Time: Developing Real-Time Systems with UML, Objects, Frameworks, and Patterns”, Addison-Wesley, 19.

Latest revision as of 01:56, 15 October 2009

Introduction

Patterns are often classified into creational, structural, and behavioral categories. However, this leaves a large number of patterns in each group, with no easy way of remembering all of them. What classifications and strategies have been developed to help programmers remember patterns, so that they can apply them at opportune moments?

This article is intended for experienced programmers who are well in versatile patterns. It is not intended to familiarize the reader with the concept of a design pattern. If interested in learning what design patterns are please refer to Design Pattern. The intent of the article is not to describe existing patterns and their usage but rather introduce a other ways of categorizing and cataloging of patterns.

This article relies heavily on the presentation by Imed Hammouda and Jakub Rudzki. We would like to thank them for their contribution to the field of design patterns and helping us to better understand pattern classification.

Definition

A pattern is a solution to a problem in its context. A context is specific to the domain in which the problem is being solved. For example, in computer science software engineers often are surrounded by problems in similar contexts such as web and database infrastructure. Within these contexts there are repeatable solutions. Those solutions when described abstractly are are what we call patterns. A pattern in itself is not a finished solution to a problem but rather a template on how to solve a given problem which can arise in a variety of different situations (contexts)[1]

The goal of patterns is to recognize and make use of a library of knowledge that can be used to solve problems. Often times, the same problems are 're-solved' without learning from the past experiences. As long as we have similar contexts we will have patterns or knowledge that develop from those solved problems.

Example

The company you work for decides to switch a different database vendor which in turn requires you to change the interface for a set of objects in the software you designed. It turns out that the change of interface is a common problem not just for the databases but in general in software development. In this case you would use a Adapter pattern in the context of database development.

Problem

The problem with patterns is classification and recognition or usage, i.e. what type of patterns to use for each given case. For example, a pattern that is not classified correctly will not be remembered and used. Several attempts to classify patterns has been made. The existing software classification of patterns uses the categories of:

  • Structural
  • Behavioral
  • Creational

While these are good starting points for patterns, it is very hard to make use of this information in different contexts.

Existing Work

The Gang of Four patterns are the most famous. They are classified according to creational, structural and behavioral groups. There is also a J2EE catalog of patterns by SUN. These are all classified as J2EE patterns but they can be split into presentation, business, and integration tier patterns.

There is a good presentation regarding pattern classification by Imed Hammouda and Jakub Rudzki. In the presentation they suggest that patterns can be classifed by:

  • Domain
  • Paradigm
  • Granularity
  • Purpose
  • Scope
  • Discipline

Domain

Domain specific classification may help make patterns more useful in various contexts. This is because the solution to the problem will be more specific to the context. Below are some examples of domain specific classification.

Factory method - Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.[1] Object pool - Avoid expensive acquisition and release of resources by recycling objects that are no longer in use.[1]

Adapter or Wrapper - Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces.[1]

Interpreter - Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language.[1]

Paradigm

Paradigm classification is a categorization of a pattern according a programming paradigm. In OOP patterns take forms of classes, objects and inheritance while in imperative programming patterns take form of procedures and functions.

Below are examples of patterns for functional logic languages taken from [2] and [3]

Opaque Type - Ensure that values of a datatype are hidden.

Locally Defined Global Identifier - Ensure that a local name is globally unique.

Incremental Solution - Compute solutions in an incremental manner.

Concurrent Distinct Choices - Ensure that a mapping from indexes to values is injective.

Constrained Constructor - Prevent invoking a constructor that might create invalid data.

Granularity

This kind of categorization refers to the system level where the patterns are used at. For this category it is sometimes hard to draw a border between levels and the pattern might be used at different granularity categories. Below are the examples of pattern classification based on granularity classification. These examples were taken from [2] and [4]

Architectural patterns - refer to a software system at high level. Examples of these patterns would be Layer, Model-View-Controller and Multitier architecture

Design patterns - focus on subsystems and components. Examples of these patters would be Factory method, Object pool and Adapter or Wrapper

Idioms - address the lowest level of a software system. A good example of these would be Java Idioms

Purpose

Purpose represents a specific type of a problem a pattern is trying to solve. It is the most useful criterion since it describes the exact situation where the pattern is used.

Below are examples which were taken from [2] and [5]

Architectural support patterns - represent the strategic decisions for the organization of real-time applications.

Collaboration and distribution - patterns provide solutions to common application domain problems in real-time systems.

Safety and reliability patterns - deal with common problems of safety and reliability.

Behavioral patterns - provide different implementation solutions involving multiple objects.

Scope

Scope classification is categorization of patterns according to features implemented in a given pattern. As an example in object-oriented design patterns can be classified using either class inheritance or object composition

Discipline

It is perhaps the easiest and most natural way to classify patterns, i.e. categorize them according to a field or discipline where they are used, i.e. music, engineering, or economy. It is unlikely (but not impossible) that a pattern used in one discipline becomes relevant to another.

Article Definitions

Gang of Four - also known as GoF. The authors of the Design Patterns book.

Model-View-Controller - MVC for short, Architectural design pattern.


Related Links

References

[1] Design Pattern

[2] Pattern Classification by Imed Hammouda & Jakub Rudzki

[3] S. Antoy and M. Hanus. “Functional Logic Design Patterns”. In Proc. Of the 6thInternational Symposium on Functional and Logic Programming (FLOPS 2002), Aizu (Japan), Springer LNCS 2441, pp. 67-87, 2002.

[4] F. Buschmann, R. Meunier, H. Rohnert, P. Sommerland and M. Stal. ”Pattern-Oriented Software Architecture: A System of Patterns”. Wiley , (1996).

[5] B. P. Douglass. “Doing Hard Time: Developing Real-Time Systems with UML, Objects, Frameworks, and Patterns”, Addison-Wesley, 19.