Team LiB
Previous Section Next Section


If we wish to record information about a student, what data might we require? Some examples might be

and so on. Now, how about for an academic course? Perhaps we'd wish to record

and so on. In object nomenclature, the data elements used to describe an object are referred to as the object's attributes.


Use of the term "attribute" in this fashion is a language-neutral object modeling and programming convention. But, all .NET languages (including C#) have a specific programming construct called an attribute, which has a more complex purpose than simply referring to a data element of an object. It's important not to confuse the two uses of the term "attribute" when talking specifically about one of the .NET languages. (.NET languages instead prefer to use the term "field" to refer to an object's data elements/attributes in the generic sense of the word.)

We'll explain what an attribute in the C# (.NET) specific sense is all about in Chapter 13. For the time being, however (i.e., throughout the remainder of Parts One and Two of the book), whenever we use the term "attribute," we're using it in the generic OO sense.

An object's attribute values, when taken collectively, are said to define the state, or condition, of the object. For example, if we wanted to determine whether or not a student is "eligible to graduate" (a state), we might look at a combination of

to see if the student is indeed expected to have satisfied the course requirements for their chosen major field of study (a third attribute) by the end of the current academic year.

A given attribute may be simple—for example, "GPA", which can be represented as a simple floating point number—or complex—for example, "transcript", which represents a rather extensive collection of information with no simple representation (at least as far as C# simple types are concerned).

Team LiB
Previous Section Next Section