Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Definition of OOP

This topic is 6571 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

It''s all heresay

To me OOP is anything in which you create your variables and use them. So anything that isn''t OOP would be more of a scripting language in which you might use pre-determined variables or none at all.

Share this post

Link to post
Share on other sites
Since, as you say there are a lot of articles that disagree, you could come to the conclusion that either

a) No-one actually knows.


b) It''s a subjective definition.

Myself, well I define it as using logical objects to define a heirarchy and structure in a program, using encapsulation to provide safe and consistent access to members and ensuring that it is easily expandable.

But that''s probably crap, so let''s just say no-one knows


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
OOP is where you use objects such as classes and structs to group and structure your data logically.

The alternative to this is procedural programming. The old BASIC is this as anyone who knows it knows what i mean, there''s no real structure, you take your program statement by statement.

Share this post

Link to post
Share on other sites
VB is not fully OOP, C++ neither
java is though...

but hey, I''d rather do RND or rand() than Math.random()

Share this post

Link to post
Share on other sites
To be considered Object Oriented I think a language has to cntain at least the following 3 features:

1. Encapsulation
2. Inheritane
3. Polymorphism

On top of ths there is some "extra" features and differences between the implementation of differend object oriented languages.

Some languages (Object Pascal and Java) lets all classes inherit at least from a default class (Pascal: TObject, Java: Object). Thus all objects ever created will always be a part of one large inheritance three. This might be considered a requirement too.

C++ has multiple inheritance, that is a class can inherit from two or more parent classes. Java does not. In Java you can only inherit from one class. This is not simply done out of technical concerns but because the Java designers thought that multiple inheritance was not a "good" or propper OOP.

In return Java have the concept of Interfaces (which can sometimes be used in place of multiple inheritance). Interfaces plays a rather big role in some object oriented methologies but is it a part of OOP? Well not the original definition I think but OOP is not a static definition but is still evolving.

PS: Marco Cantù has a papper on his web-site titled "Comparing OOP Languages: Java, C++, Object Pascal" which you might find interesting. I did.



Share this post

Link to post
Share on other sites

heh heh I like yours the best! (null likes C++)

I''m not dead-set against Java or anything, but it seems that there are two problems:

1) deriving all objects from a base object
2) multiple inheritance

#1 one hierarchy, aka CObject

This is usually used to address some perceived shortcoming in the C++ language, and is generally considered an obvious indicator of bad design (which in turn stems from lack of knowledge about the language or the problem domain, or both). There is never a good solution for _all_ classes, however. Not even with simple things like instance counting... Even the MFC programmers know that!

Besides, the name doesn''t even make sense. When you define a class, you define a class. When you define an object, you define an object.

// declare an instance of a class
// (this is also called defining an object!)
CClass MyObject;

class CObject {}; // wrong! this is _not_ defining an object!

class = type
object = instance

#2 multiple inheritance

I don''t think multiple inheritance is bad. The way many people use it is bad, though. However, when used properly, it is a real timesaver and definitely a good programming tool.


class input_stream
virtual void read(void* data, int size) = 0;

class output_stream
virtual void write(void* data, int size) = 0;

// now what do we do when we want both?

class file
: public input_stream, output_stream
virtual void read(void* data, int size) { /* implement this */ }
virtual void write(void* data, int size) { /* implement this */ }

Some classes do not need to do both input and output and thus they are not derived from both input_stream and output_stream, but some classes do need to do both input and output are derived from both (like the file class).

This is important, because you may have an object that can do both input and output, but you have a stream class that can only do output (or input) but not both. You want only one syntax to be valid, so you let the compiler use the class hierarchy determine whether or not the stream supports the methods.

Without multiple inheritance, you would have to add in the read/write methods yourself. Also, that approach still prevents you from using the abstract classes, and it undermines the power of data streams, which is to be able to send the same data to different destinations in the same way. If you use an abstract class without multiple inheritance (which has both read and write) that would leave some methods unimplemented on some classes (which is a, how do you say it? "boner"?).

Ideal solution? Multiple inheritance.

However, I do not want this to turn into a language war - just a reasonable topic on programming methodologies.


How is C++ not an OOP language?


If OOP is subjective (which I doubt), then it is useless as a methodology.

- null_pointer
Sabre Multimedia

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!