LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-23-2004, 03:09 AM   #1
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Rep: Reputation: 30
Problem with "Object Oriented Concepts"


Suppose we have a world as a class, and some agents in the world. Agents are also objects. The problem with OO is that when we want to implement the world we also have to make an instance of the agent within the world class. It's obvious that the agent within the class should know almost everything about it's world (it has a lot of examples around us), but it do nothing unless we send him a reference/pointer of the world class.
Isn't it a problem with Object Oriented Concepts?
 
Old 03-23-2004, 03:13 PM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
Either make all the stuff in World that the agent needs to know about public, or if you feel it needs to be private you can use some language construct to give Agent access to it. In java you could make Agent an inner class (terminoligy?) of World, or in c++ you can use "friend". You can instantiate an Agent with a {pointer|reference} to an instance of World.
 
Old 03-23-2004, 10:24 PM   #3
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Original Poster
Rep: Reputation: 30
Quote:
In java you could make Agent an inner class
Thanks, I think this answers to part of my question. But human -as an agent in the world- can not be an inner class of the world, because it's an independent object, and should not place within the world class. What about this problem?
 
Old 03-23-2004, 11:06 PM   #4
shortfuse
Member
 
Registered: Feb 2004
Location: Texas
Distribution: Debian
Posts: 30

Rep: Reputation: 15
I think your talking about nested classes which I find interesting(learned something new), I found some information for you that basically says you can make the nested class friends with the outer class and have access to it's members.

Also if the nested class is declared in the public section it will be visible to other classes and as such you can create independent instances of those objects.

http://www.icce.rug.nl/documents/cpl...lusplus16.html
 
Old 03-23-2004, 11:17 PM   #5
Mohsen
Member
 
Registered: Feb 2003
Location: Iran
Distribution: Solaris 10
Posts: 201

Original Poster
Rep: Reputation: 30
Thanks

Last edited by Mohsen; 03-23-2004 at 11:20 PM.
 
Old 03-23-2004, 11:24 PM   #6
shortfuse
Member
 
Registered: Feb 2004
Location: Texas
Distribution: Debian
Posts: 30

Rep: Reputation: 15
After reading you original post again it sounds like maybe you just need the world class to be a friend of the agent class?

Last edited by shortfuse; 03-23-2004 at 11:29 PM.
 
Old 03-24-2004, 12:21 AM   #7
jsokko
Member
 
Registered: Mar 2004
Location: Phila, PA
Distribution: SuSE 9.0 / RH 9 / Slackware 9.1
Posts: 110

Rep: Reputation: 15
your question really asks about the rules of inheritance and abstract classes, and does not apply to real world examples. The world doesn't necessarily 'classify' easily; we cannot organize what 'the world' consists of in a finite way. so there IS no inheritance nor is there real classification except in the loosest sense of the word.

remember -- OO is based on classification, a way of organizing information for OUR understanding. We do not understand what 'the world' is in every definition (macrocostic to microcostic) so it makes for a bad example.

just because we are of the world, doesn't mean we are the world.

instead, the world is comprised of us. that's the real gotcha.




J

Last edited by jsokko; 03-24-2004 at 12:40 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript error "is null or not an object" apt Programming 2 03-28-2005 06:14 AM
LDAP object classes: cn=admin, why "simpleSecurityObject" and "organizationalRole&quo Hko Linux - Networking 0 08-06-2004 07:55 AM
Not loading gdm;"libX11.so.6 cannot open shared object" zlobby Linux - Newbie 6 03-03-2004 04:30 PM
/usr/libexec/ld-elf.so.1: Shared object "libgd.so.4" not found lxxy *BSD 1 12-04-2003 12:01 PM
Can't locate object method "splitpath" via package "File::Spec" RobJohnston Linux - General 2 06-28-2003 09:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration