| Home | Previous Lesson: What Are Objects? Next Lesson: Class |
Every object has a state and behavior. For an object, attribute defines the state and service describes the behavior.
The attributes of an object are the characteristics (that represent the properties) that give it a distinct identity. They may be called attributes, properties, or fields, but, they always represent the same thing. Attributes represent the set of properties to which values can be assigned in order to describe the object, and thus establish its identity. In practical terms, attributes are the data elements that can be accessed in an object. In programming implementation of an object, attributes are defined by its instance variables. Instance variables are private to the object. Unless explicitly made public or made available to other "friendly" classes, an object's instance variables are inaccessible from outside the object.
An object's behavior is defined by its services. Many different terms are used to refer to the services of objects. They can be called functions, services, responsibilities, methods or operations. They all represent something, which responds either directly or indirectly to the actions, directed at one object by other objects. In practical terms, services are the processes that can be triggered in an object. Services manipulate the instance variables to create new state; can also create new objects.
The small picture above is a commonly used graphical representation of an object. The diagram illustrates the conceptual structure of a software object - it's like a cell, with an outer membrane, its interface to the world, and an inner nucleus protected by the outer membrane.
| Home | Previous Lesson: What Are Objects? Next Lesson: Class |