AG VLSI Design and Architecture

SFB 501 - Project D1: Application System "Buildings"

PSiGene

Pattern Catalog

[PSiGene]

3.2 Pattern VariableValue

Intent

The VariableValue pattern defines a new instance variable (i.e., an attribute) and its access methods for an object.

Also Known As

Attribute

Motivation

An object should have direct access to its local data. Other objects may access via access-methods only. This serves two aims: namely, encapsulation and safety.

Data will be encapsulated because only the Object itself knows how an item is implemented, external objects only see external representations.

Safety is necessary to keep control on accessing, i.e., range checks or multiple write protections can be implemented.

Applicability

Usually, this pattern will be used implicit by other patterns defining participants which are attributes.

Structure

The target object will contain a new attribute and methods to access it. In Smalltalk, a variable named v it would result in methods v (get) and v: (set).

Participants

Objects:
Attributes:

Consequences

Access to instance variables must only be available by corresponding methods.

It seems suggestive to build subpattern for Protected Variables using semaphores or monitor-concepts to save the variables on multiple access. (ProtectedVariableValue )

Implementation

{variable}
    "Return attributes value."
    ^{variable}
{variable}: value
    "Set attributes value."
    ^{variable} := value

Related Patterns

ConstantValue

PEdit description

Pattern VariableValue Category basic
    Description VariableValue.html

    ObjectType use target
    Attribute implement variable
End

previous page next page up   Table of Contents PSiGene