|
Re: How C++ programmers think
|
Posted: Dec 31, 2005 9:37 AM
|
|
> [Terje] could you explain what you mean by this > implementation method being used to "fake classes"? In > this case, how do you define "real" classes, and can you > provide any "authority" as to what should be the proper > definition of "class"? > > Many beginning programmers believe the methods are > actually laid out in memory right next to the data of an > object. That could be done, but since the various methods > are going to be identical functions, it's much more common > to lay out any necessary vtables and the data in the > object itself, and make the methods functions that can be > found when needed. > > That's what I mean by "fake classes." In truth, that's > not a Computer Science term. It's just something that > comes as a bit of a surprise to beginning programmers.
Yeah, but implementing something more efficient than a "naïve" solution doesn't make it fake... As has been pointed out in the discussion, this is more or less how _all_ the languages implement OO (at least the statically typed ones).
> I'm not aware of any authority for the terms. OTOH, show > Java programmers object oriented C code (such as the Linux > kernel), they'll almost all say "Oh, I get it -- they're > faking OOP!"
Now you may be getting at something. :) Indeed, it's possible to write OO code even in assembly, it's just not very easy, as there's no support for OO in that language. The usual terminology in this matter is, in my experience, what I said here, namely that OO is a design methodology or paradigm - a way of structuring the code, etc., and whether or not a language has _support_ for OO, determines how easy it is to write OO-programs in the language. There's no "faking" involved - only whether or not the language has support for it, or if you have to do it all, "manually".
|
|