Wiki Home

Vmpia Velcro

Namespace: VFP
From the VMP 4.0 manual:

Visual Max Frame Professional classes have a custom iaVelcro array property.
iaVelcro is intended to provide a standard place to "attach" instances of custom classes that extend the functionality of the owning object. The attachment is done by storing an object reference to the custom-behavior-extender object in an element of the owning object's iaVelcro array property.

The main benefit of attaching the behavior-extender object is that the extra desired behaviors can be added to any other object, at runtime, without subclassing, which results in sophisticated features with a relatively flat class hierarchy. Also, the added behavior can be accessed by any number of objects of different VFP base classes without repeating the code in each class hierarchy.
It effectively incorporates the Bridge design pattern into the framework.

Say you have a form to enter selection criteria for customers. You have a textbox for customer name. Add an instance of a container inheriting from "ctrSelCriteria" and a custom object "this.cusSCCustomerName" based on "cusSelCriteria"

Initially, the textbox and the selection criteria object have nothing in common except for the fact that they are members of the same container. Code added to the "AttachVelcro()" method of the selection criteria container stores an object reference to the selection criteria object into the iaVelcro property of the textbox like this:
this.txtCustomerName.iaVelcro[1] = this.cusSCCustomerName

From then on, it is as if cusSelCriteria is an extension of the textbox, as if they are a single entity, because all of cusSelCriteria's PEMs are available to the txtTextBox via calls to this.iaVelcro[1].SomeMethod().
Contributors: Alex Feldstein
Category Visual Max Frame Professional
( Topic last updated: 1999.09.05 09:00:43 AM )