[gameprogrammer] Re: C vs. C++

Chris Nystrom wrote:

I understrand that objects are instances of classes.

So, what is the class, and what are the objects, in your code?

"According to the object-oriented principles, the verb is attached to
the object and logic associated to the requirement is handled in the
object."


I am a little fuzzy about what this is saying. It seems to be a little
abstract. I am not sure what "the verb" is in programming.

To paraphrase unhelpfully, "the action." Typically, the function calls. Unlike imperative programming where there is an implied actor for everything, in OOP the objects are the actors and the functions are their verbs. This may be a matter of the jargon and thought pattern requiring that you already "drank the Kool-Aid," so to speak.


I do understand that the "logic associated to the requirement is
handled in the object". That is why I said that the methods were an
interface to the data.

What is the object, in this case, though? Objects are concrete things; classes their definitions.


I do not do anything with inheritance, so it seems my programming
style would more presicely be called "object-based programming".

Yes, if that.

On
the other hand there does not seem to be a wikipedia page for "object
based programming", so OOP _also_ appears to be a more generic term
for any sort of programming with objects (OBP is discussed in this
entry on OOP, instead of having its own entry, for example).

Because people don't like to call their own code OBP... OOP has better marketing magic associated with it.


So perhaps it is not unusual that we have different ideas about it.

Among people who regularly work with OOPLs, like Java, Objective-C, C++, and so on - rather than languages like Visual Basic, C, PHP, or Perl where objects are essentially tacked on (if available in the syntax at all) - there is not so much debate.


In my experience, most of the debate centers on people claiming they are doing object-oriented programming outside a language that supports it natively. To my knowledge, GTK+ has the best claim to this.

Writing in C, without a lot of overhead and effort, isn't going to be OOP.

In strict terms (with inheritance), I agree. However I was claiming OOP in general terms as I quoted before:

"OOP is the practice of writing program text decomposed in modules
that encapsulate the representation of one data type per module"

I'm not going to argue a single sentence definition, any more than I'm going to discuss a single-sentence definition of "hacker" or even "programming."


and I believe my audio_lib code is object based in the above sense. It
is basically a library of 3 modules each with a single data type:

Long before C programmers heard of OOP, they were doing that. Data encapsulation is good practice, and it's perfectly sensical outside the context of OOP.


can copy the example, but there are no reusable modules here. My code
is modularized (Note: I am not saying it is better, I am just saying
it is modularized).

Well, it seem to me that "modular" is a fine description of what you're doing. You can probably make an argument, any time you want, that you're doing OOP... but why bother? IMO, it confuses the issue because you're not dealing with the issues most people think of when they think of OOP, you're not providing an interface that most people who do OOP will recognize, but you *are* engaging in good practices.
--
Matthew Weigel




---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: