Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Code Newbie > Submit Tutorials > C++

Reply
 
LinkBack Thread Tools Display Modes
Old 03-11-2003, 11:11 AM   #1 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Post Abstract: What are objects?

What are objects?

Preface
This short tutorial covers the abstract definition of an object, as we know it in C++.
Before I give the final definition of an object, I'll cover aspects that play a role in the process of defining an object. Besides that, I'll present examples from the "real" world and translate them into knowledge related to the C++ programmer.

(Part 1 of 2) So what are objects: informal description
Entity. A word that can relate to a ghost, a car, a human being, a chair, a mortgage, a feeling, love. It is hard to think of a more abstract word than the word "entitiy". It can be absolutely everything.
But a programmer needs more than such a word. He or she needs something that is "tangible", something that is clearly defined and put in its place. The memory of a computer that is. Programmers call these things: objects. Objects are "real". They have a quantity,a clear shape, a behaviour and they are in a certain state. Just like humans. There is a quantity of humans, they have a distinctive shape, they have a certain behaviour, and are in a certain state (sleep, angry, happy, awake).
While the definition of an entity may depend upon the perception of a human being, an object is clearly shaped.
Objects are in a certain state.
Defining objects is the same thing as "looking for things". Usually a programmer does this by thinking and writing specifications (code) in a class.

Humans have a behaviour. A human can give you a cup of tea, or help you do the dishes. Humans can offer services. So can objects.
Objects can offer services.

Well, objects are unique, no two objects are the same. Take for instance twins. They might look the same in all aspects, but since they have their own personality, identity, they are by no means the same. Both of them are unique.This goes for objects too.
Objects are unique and have their own shape.

Lets wrap this informal part up. In general, one can say about objects:
1) Objects are clearly defined.
2) No two objects are the same.
3) Objects can offer services.
4) Objects are in a certain state.


(Part 2 of 2) So what are objects: its definition

An object is an instance of a class with the following essential properties:
1) Each object has its own identity.
2) Each object can have a behaviour.
3) Each object is in a state.

These essential properties are proposed by G. Booch (1991).

Lets elaborate these three essentials.
1) Identity
So how can you Identify objects? How do they have their own identity?
Each object persists in its own memory adress.
So we managed to define the word identity, implying at the same time their uniquenes.
2) Behaviour.
The behaviour of an object is the same thing as the kind of services an object delivers. A point-object can offer services to make a line. And a line-object can offer services to a CAD/CAM application. A server-object can offer services to a client-object. And (by our definition) a client-object can offer services to other objects. It all depends upon the context in wich the object is created.
3) State.
The state of an object is information about the object itself. For example, a point-object might actually hold a value, like (1,2). This is the state the point object is in right now.

Comment 1:
While I defined the uniqueness of an object by its adress in memory, one could easely connect the uniqueness of an object with its name. I've seen books and universities introduce this definition. For the sake of completeness I've added this comment.

Comment 2:
A class is NOT an object. A class is a definition. It is not "real". An object is. Though this might cause some problems. What about meta-classes? These are classes about classes. But this goes beyond the scope of this tutorial.


So there we have it. An abstract view on objects. I hope the student has now a firmer grip on thinking in terms of Object Oriented Programming


See you guyz next time,
Val
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting objects arrays by object properties sde Java 28 08-05-2004 05:51 AM


All times are GMT -8. The time now is 06:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting