Object Oriented (OO) Example
State/Attributes/Data
Creating an object to describe (or model) a student, we might require the following data items:
- student name
- student ID number
- student address
- student designated major (if any)
- student GPA
- courses the student is currently enrolled in
In object terminology, the pieces (or items or elements) of data which describe an object are referred
to as the objects attributes. When an objects attributes are considered collectively during a
single time period (that is a "snap-shot" of the attributes), this defines an object's state. For
example, if we wish to determine if a student "is eligible for an academic scholarship in their major"
(a singular state), we would likely consider the attributes:
- student designated major
- student GPA
Behavior/Operations/Methods
Using the object described above (a student), consider some of the potential behaviors, such as:
- adding a course
- dropping a course
- choosing (or changing) a major field of study
- selecting a faculty advisor
- reporting their GPA
When discussing software objects, we define an objects behaviors (also called its operations) as
- the things the object does to access its attributes (data)
- the things the object does to modify/maintain its attribute (data) values
For example,
- reporting their GPA involves accessing the value of the students "GPA" attribute
- choosing a major field of study involves modifying the value of the student's "major" attribute