User Functions

Older Stories

Welcome to Saturday, 16 December 2017, 19:34 @ CET

Attribute, Property, Variable and Value

Anti Patterns
  • Monday, 09 September 2013, 11:14 @ CEST
  • Contributed by:
  • Views:
Cobol works with Files, Records, Fields (or Items) and values can be attached to named conditions, initial states of variables. But modern languages know of (additional) Attributes and Properties.

Mixing the usage of these concepts is a pain. Not only in these modern languages.
The crux is the difference between a Variable and a Value.
So, a Property is meant to be used as a Value, while the Attribute is meant to be used as a Variable. For both rules that they can be changed: the value of a property can be changed and the contents of a attribute can be changed.

However, if one changes the value of properties at runtime, the user or reader of the code or text will be confused. And maybe that is what you're after?

Let us look at a select list. The attribute (read: variable) of this list can contain a value, selectable from multiple properties (read: values). Sometimes one says that the Attribute is enumerated or has a enumerated property.
At startup time these properties get their value by a one-time assignment or are read from a database. The attribute gets its value at run-time.

Let us look at a country list in an international application. That list could contain the countries of the world, or, being smart, the (selectable) countries of Europe or the Americas. Depending on the geo location this application shows Europe, the Americas or the complete World list.
Being smart, a property of a productive programmer, one could change the properties that will be attached to the attribute of the select list.
Being robust, a property of a Cobol programmer btw, you will use three different select lists.

So, don't change a value that is defined as a property and expect attributes (variables) to contain unknown contents.

The following comments are owned by whomever posted them. This site is not responsible for what they say.