[gameprogrammer] Re: C vs. C++

On Tue, 2005-12-27 at 01:39 -0600, Matthew Weigel wrote:
> 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.

Sorry, but I've lived through these debates too many times. OOP has only
a weak coupling to OOPLs. While OOPLs have a strong coupling to OOP.
That is to say, you do not need to use an OOPL to do OOP, but using an
OOPL tends to force you to use classes so you at least look like you are
doing OOP :-). (Old saying, you can write FORTRAN in any language.)

Object oriented programming is a concept that seems to have grown
originally out of two different areas, discrete event simulation and
abstract data types. (Look them up.) Object oriented programming
languages were originally developed for discrete event simulation. (look
up Simula.) While abstract data types were all the rage in the AI/LISP
area for many years. 

The advent of large scale GUI programming lead to the use of OOP/ADT by
large numbers of programmers and the spread of OOPLs to ordinary
programmers. OOPLs are, of course, designed to make OOP easier to do.
But, I can assure you that full scale object oriented development was
being done in languages such as assembly language, C, Pascal, and even
COBOL, long before OOPLs were widely available.

BTW, you can do inheritance in C. You can do it in any language with
structures. Remember that the original C++ compiler emitted C.

                Bob Pendleton

> 
> > 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.
-- 
+--------------------------------------+
+ Bob Pendleton: writer and programmer +
+ email: Bob@xxxxxxxxxxxxx             +
+ web: www.GameProgrammer.com          +
+ www.Wise2Food.com                    +
+ nutrient info on 7,000+ common foods +
+--------------------------------------+



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


Other related posts: