Jump to content

Binding properties pattern

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Shevonsilva (talk | contribs) at 04:45, 5 February 2016. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Binding properties pattern is combining multiple observers to force properties in different objects to be synchronized or coordinated in some way.[1] This pattern comes under concurrency patterns.

Comparision with aspect-oriented implementation

As an alternative to the aspect-oriented implementation of mutual properties, property binding can be proposed. In LibPropC++ C++ library it is implemented too.[2]

Some weakness in the LibPropC++ (with property binding:

  1. Its use is not transparent as it requires to be declared neccessory object attributes as properties and appropriate accessor methods must be provided
  2. Binding of attributes in LibPropC++ is not designed to replace method calls
  3. The library does not maintain an interaction history.[2]

Implementation

There are two types of binding. One-way binding should be applied when one of the properties is read-only. In other cases, two-way binding must be applied.[2]

Infinite loops can be elimated by blocking the signal, or comparing the assigned value with the property value before assignment, or eliminating unnecessary assignments.[2]

Binding properties of different types can be achieved through Type Conversions.[2]

Binding properties with transformations can be achieved thorugh reducing the transformation function to the problem of binding properties, and the function can be imaginary consider as Type Conversions.

Resulting Cotext

Properties are being kept sychronized automatically. Between library calls they always have the values expressed by the EqualityConstraints.[2]

Deficieancies

Property changes watching machanism aquires some resources.[2]

Sample Code

Two-way binding can be expressed as follows:

// In this pseudo-code are not taken into the account initial values assignments
bind_two_way(prop1, prop2)
{
  bind(prop1, prop2);
  bind(prop2, prop1);
}

[2]

Accomplishing the binding (i.e. connecting the property change notification in a event handler) may be like as follows:

on_property_change(src_prop, dst_prop)
{
  block_signal(src_obj, on_property_change);
  dst_prop := src_prop;
  unblock_signal(src_obj, on_property_change);
}

[2]

See also

References

  1. ^ "Binding Properties". Cunningham & Cunningham. Cunningham & Cunningham. Retrieved 4 February 2015.
  2. ^ a b c d e f g h i Evermann, J., The Association Construct in Conceptual Modelling - An Analysis Using the Bunge Ontological Model, Wellington, New Zealand: School of Information Management, Victoria University