Role Class Model

Role Class Model

In computer science, the role class model is a role analysis patterncite web | last = Fowler | first = Martin | authorlink = Martin Fowler | title = Dealing with Roles | work = Analysis Pattern | date = 1997-07-20 | url = http://www.martinfowler.com/apsupp/roles.pdf | format = PDF | accessdate = 2007-01-16 ] described by Francis G. Mossé in his article on Modelling Rolescite web | author = Francis G. Mossé | title = Modeling Roles - A Practical Series of Analysis Patterns | publisher = Journal of Object Technology, vol. 1, no. 4 | pages = pp. 27-37 | year = 2002 | month = September | url = http://www.jot.fm/issues/issue_2002_09/column2 | accessdate = 2006-12-28 ] . The role class pattern provides the ability for a class to play multiple roles and to embed the role characteristic in a dedicated class.

In our society, as we built it, roles are everywhere. Anyone trying to work in a team to create something has a role. In cinematography, many different persons take part in the creation of a film: the film director, the producer, actors, play writer(s), etc.Even our State organisations are based on various roles. In a Republic, you have a President, Ministers, Deputies, etc.

Dealing with these situations is one of the problems encountered most during object-oriented analysis. Francis G. Mossé has identified 5 role analysis patterns that can be used to solve most role related problems: Role Inheritance, Association Roles, Role Classes, Generalised Role Classes and Association Class Roles. They all have various degrees of constraints, flexibility or power, which together offer a complete solution to most role-related problems.

This article describes the topic Role Classes.

Name

Role Class Model

Intent

A model that allows a class to play one or more role at the same time. A role - as defined by Francis Mossé in Modelling Roles - is a concept of a purpose that a class could have in a certain context.

Context

The following example is given:

Many persons work on a film, each of them with a different role. At the difference of other concepts, a person is not restricted to one role. One could be both the director and a character of a film. Modelling roles for such a concept would require that a class could play more than a single role.

A solution using inheritance to conceptualise a role - cf. the Inheritance Role Model - is not possible, as this would allow a person to play only a single role. As one can see in Figure 1 below, the inheritance role model says that a character, who is a person, is playing in a film. But there is no way to say that the person playing the character is also the director. Because, the inheritance makes it that a character is a person in general, not a particular person.

Problem

As explained in Context, using inheritance to play more than one role cannot be considered, because a class could not play two roles at the same time in such a context (cf. the Inheritance Role Model).

The expectation is to have a model where a class could be seen as more than one concept or role, and where attributes specific to one of those concepts can be specified.

olution

A solution to the previous problem could be to use the Association Role Model, which could create an association between a person and a film. However, specific information on each role could not be stored in such a case. The "role class model" provides the flexibility of the association with role-specific attributes and even class operations, if needed.

This meta model - in Figure 2 - shows the role class like an element linking the "Client" and the "BaseClass". For the "Client" interacting with the "Role" is like interacting with the "Base Class" itself, but from the perspective it is expecting. The advantage having the role as a class is that attributes can be bound to it.

Real world example

Cinema

A simple application of the role class model in a real example is in the 7th art (see Figure 3), the cinematography. This art involves a creation (the Film) and people to create it. Each person has a different role in the film, they could be actors and play characters, they could be director or scenarist, etc. A person is not limited to one role in a film, they can be both actors and directors and even more. For example, the film Scoop (2006) has been directed by Woody Allen, he is also the scenarist and he plays the role of Sid Waterman.

, one can see in more detail the role that each person can play in a film. From the film, it is possible to ask the list of crews and cast that help elaborated it. Each person has one or more roles (e.g. actor, director, producer, cameraman, etc.) in the film and can participate in more than one film. A person could even be an actor in a film and a producer in another. One advantage of using a role class in the case of the actor role is that the character qualities can be stored within the role. This is true for the actor role, this is also true for other roles, however maybe not all.

Only a few of the possible role have been modelled in Figure 4. One remark easily visible is that not all the role needs attributes and using the role class model for all of them is unnecessary (like for the "Director" role). In addition, there is a lot of redundancy between each role class. Redundancy in computer science means more work in maintenance, which is not wished.

trengths and weaknesses

The employment of this model depends on the business process. The analysis pattern “Role Class Model” offers a possibility to employ a model with linking between a base class and the client. In addition inheritance is not a part of the solution because of the flexibility of zero or multiple roles (=> role-specific attributes and operations).Strength implies also its counter part's weakness. The problem of the role class model is the redundancy, for example the method "getName" is visible in all of the role classes described in Figure 4. If this is considered inconvenient, the role class generalisation model as defined in Modelling Roles is a possible way to go.

See also

Francis G. Mossé has described other solutions to the role problem.
* Role Inheritance
* Association Roles
* Generalised Role Classes
* Association Class Roles
* Association Class Roles with role type, which is a refinement of the previous.

References

Further reading

* cite book
last = Fowler
first = Martin
authorlink = Martin Fowler
title = Analysis Patterns: Reusable Object Models
publisher = Addison-Wesley
date = 1996-11-27
isbn = 0201895420
An introduction to object-oriented analysis with conceptual models
* cite paper
author = Raventós, Ruth and Cabot, Jordi
title = Conceptual Modelling Patterns for Roles
publisher = Journal on Data Semantics V
date = 2006
url = http://www.lsi.upc.edu/~jcabot/papers/JODS05.pdf
format = PDF
accessdate = 2007-01-16

* cite web
author = Department of Computer Science
title = Usage of Roles in Patterns
publisher = University of Illinois at Urbana-Champaign
work = Analysis Pattern
date = 2004
url = http://wiki.cs.uiuc.edu/AnalysisPatterns/Asita+%3A+Usage+of+Roles+in+Patterns
accessdate = 2007-01-16

* cite web
author = chromatic
title = Usage of Roles in Patterns
publisher = O'Reilly Media
work = [http://www.oreillynet.com/onlamp/blog/technical/ Technical]
date = 2006-08-31
url = http://www.oreillynet.com/onlamp/blog/2006/08/roles_composable_units_of_obje.html
accessdate = 2007-01-16

Related links

* Actor-Role Pattern, A JPA Implementation [http://www.ibstaff.net/fmartinez/?p=16 http://www.ibstaff.net/fmartinez/?p=16]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно решить контрольную?

Look at other dictionaries:

  • Model Colony — is one of the neighbourhoods of Malir Town in Karachi, Sindh, Pakistan.[1] There are several ethnic groups in Malir Town including Urdu speakers, Punjabis, Sindhis, Kashmiris, Seraikis, Pakhtuns, Balochs, Memons, Bohras, Ismailis. Over 98% of the …   Wikipedia

  • Model Rail — Editor Ben Jones Categories British Frequency Four weekly Circulation 28,337 (2009) First issue 1997 Company Bauer …   Wikipedia

  • Model United Nations — A Model United Nations Conference in Stuttgart, Germany in action. Model United Nations (also Model UN or MUN) is an academic simulation of the United Nations that aims to educate participants about current events, topics in international… …   Wikipedia

  • Class (computer programming) — In object oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable …   Wikipedia

  • Class diagram — UML diagrams Structural UML diagrams Class diagram Component diagram Composite structure diagram Deployment diagram Object diagram …   Wikipedia

  • Role-playing game — A role playing game (RPG; often roleplaying game) is a game in which the participants assume the roles of fictional characters.cite web url = http://www.darkshire.net/ jhkim/rpg/whatis/ title = What is a Role Playing Game? accessdate = 2008 09 09 …   Wikipedia

  • Class (computer science) — In object oriented programming, a class is a programming language construct that is used as a blueprint to create objects. This blueprint includes attributes and methods that the created objects all share.More technically, a class is a cohesive… …   Wikipedia

  • Role-playing video game — Part of a series on …   Wikipedia

  • Model theory — This article is about the mathematical discipline. For the informal notion in other parts of mathematics and science, see Mathematical model. In mathematics, model theory is the study of (classes of) mathematical structures (e.g. groups, fields,… …   Wikipedia

  • Model Crime Investigations — KMCI Seal representing KMCI Crimson red: Justice; White: Integrity …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”