.

Web.com Web Hosting
Sign up for PayPal and start accepting credit card payments instantly.

.

Hello If you are new here, so you might want to subscribe for my feed so Subscribe in a reader. Or bring updates In Your Email

Tuesday, July 6, 2010

Introduction to Objects in C# Tutorial

 An object is a combination of messages and data. Objects can receive and send messages and use messages to interact with each other. The messages contain information that is to be passed to the recipient object.

An object literally means a 'material thing' that's is capable of being presented to the senses. For our purpose, an object is tangible entity that may exhibit some well-defined behavior. For example, let us consider a  Football :

  • A football is a tangible entity, with a visible boundary.
  • A football has a specific defined purpose (such as bouncing).
  • You can direct a specific action towards a football by kicking it or tossing it.


But the definition of an object is not limited to merely something that can be seen, held, and touched, such as a tennis ball or a car. For the purpose of software development, the definition of an object needs refinement. For example, consider the Acme Nut and Bolt Company. An organization does not  have a visible boundary, unlike a tennis ball. While it does not posses a physical boundary, it does not have a conceptual boundary. Like all organizations. it has a specific defined purpose, and one can direct a specific action towards it. Thus, the Acme Nut and Bolt Company is an object.

State, Behavior, and Identity of an object

According to Grady Booch, a renowned software architect, an object has the following characteristics :

  • It has a state.
  • It may display behavior.
  • It has a unique identity.

The state of an object is indicated by a set of attributes and their values. For example, a chemical can be characterized by its temprature, color and density. The behavior of a chemical refers to the change of its attributes over a period of time. A chemical also has state, such as solid, liquid or gas.

The preceding paragraph explains the first two points of the definition of an object by Grady Booch "An object has state, exhibits some well-defined behavior...". Now, you will examine the next part of the definition - "...and has a unique identity."

Each object has a unique identity, and the identity of an object distinguishes the object from all other objects.

For example, you can take a car as an object. It can have states such as moving and stationary. It can accelerate, decelerate, turn right, or turn left, which is its behavior. The car also has an identity, such as a unique registration number.

Two objects may have the same behavior and state, but they will never have the same identity. The identity of an object does not change in his lifetime. For example, two tennis balls may have the same color, be made of the same material, have the same weight and the same circumference, and display the same behavior. However, they will have distinct identities (for example, one ball will have the factory seal number 'A189735' and the other "S660794').

No comments:

Post a Comment

Related Posts with Thumbnails