[gameprogrammer] Re: C vs. C++
- From: Chris Nystrom <cnystrom@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Mon, 26 Dec 2005 20:21:14 -0600
NOTE: This discussion about OOP programming with plain C was started
as an offtopic discussion on the SDL list and moved to this
gameprogrammer list. I invited the use of my audio_lib code found on
the Gameprogrammer wiki here
(http://gameprogrammer.com/gpwiki/Audio_lib) as an example for
discussion.
On 12/26/05, Matthew Weigel <unique@xxxxxxxxxxx> wrote:
>
> No, actually, data is inherent to *objects*, not classes, except
> metadata about objects of the class. Objects are fairly concrete
> things, you can point to them or reference them or assign them, and they
> have a type (which is the class).
I understrand that objects are instances of classes.
> I'd recommend reading that article more closely...
>
> "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.
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.
> "Widely-used terminology distinguishes object-oriented programming from
> object-based. The former is held to include inheritance (described
> below), while the latter does not."
I do not do anything with inheritance, so it seems my programming
style would more presicely be called "object-based programming". 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).
I do note this quote:
"OOP is subject to much contention as to its precise definition or its
principal ideas."
So perhaps it is not unusual that we have different ideas about it.
> That doesn't really say anything about the quality of your software,
> just how you wrote it.
I understand.
> 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"
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:
1. audio module that basically encapsulates a boolean value of whether
the audio port is open, or not.
2. music module that encapsulates a single music item
3. sound module that encapsulates an array for up to 25 sound effects.
As an anti example, look at this SDL_Mixer code:
http://www.kekkai.org/roger/sdl/mixer/
This code is fine, but it is not object based. The data is global, and
you can not take out a module and use it in some other project. You
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).
Chris
--
E-Mail: Chris Nystrom <cnystrom@xxxxxxxxx>
Business: http://www.shaklee.net/austin
Blog: http://conversazione.blogspot.com/
AIM: nystromchris
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: C vs. C++
- From: Matthew Weigel
- [gameprogrammer] Re: C vs. C++
- From: Tom Wilson
Other related posts:
- » [gameprogrammer] Re: C vs. C++
- » [gameprogrammer] Re: C vs. C++
- » [gameprogrammer] Re: C vs. C++
- » [gameprogrammer] Re: C vs. C++
- » [gameprogrammer] Re: C vs. C++
- » [gameprogrammer] C# vs C++ - Edilson Vasconcelos de Melo Junior
- » [gameprogrammer] Re: C# vs C++ - Alan Wolfe
- » [gameprogrammer] Re: C# vs C++ - Alan Wolfe
- » [gameprogrammer] Re: C# vs C++ - Matthew Weigel
- » [gameprogrammer] Re: C# vs C++ - Alan Wolfe
- » [gameprogrammer] Re: C# vs C++ - Paulo Pinto
- » [gameprogrammer] Re: C# vs C++ - Alan Wolfe
- » [gameprogrammer] Re: C# vs C++ - Matthew Weigel
- » [gameprogrammer] Re: C# vs C++ - Paulo Pinto
- » [gameprogrammer] Re: C# vs C++ - Alan Wolfe
- » [gameprogrammer] Re: C# vs C++ - Chris Nystrom
- » [gameprogrammer] Re: C# vs C++ - Yasser Gonzalez Soto
- » [gameprogrammer] Re: C# vs C++ - Vince
- » [gameprogrammer] Re: C# vs C++ - Paulo Pinto
- » [gameprogrammer] Re: C# vs C++ - tommy crayon
- [gameprogrammer] Re: C vs. C++
- From: Matthew Weigel
- [gameprogrammer] Re: C vs. C++
- From: Tom Wilson