[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: object-oriented C programming



Sam Couter wrote:
> 
> Jason Gunthorpe <jgg@debian.org> wrote:
> >
> > I will admit being rather alarmed that someone would pass this off as
> > better than C++, I'm not even confident OO is a proper term to describe
> > it..
> 
> OO design doesn't require an OO language. An OO language makes it easier,
> and can enforce OO to varying degrees, but the main ingredient is
> discipline.

  design does not require OO language but implementation pretty much
does... I've been doing OO analysis in most of my projects, sometime
even drawing UML but unless you have support of language it is somewhat
awkward. you either don't really do OO or you end up in situation
described below.

> Data encapsulation and providing methods to manipulate that data makes a
> design OO, even if it doesn't have inheritence (which you can fake in C
> with a "isa" member on your structs, but it's messy) or polymorphism.

  of course you can do that, the expressions to manipulate objects might
get a bit messy though. you might want to introduce special macros for
them, then you just need a preprocessor, let's call it cfront:-) and
you're on your way!

> And even though C++ provides language support for data encapsulation and
> hiding, inheritance and polymorphism, I wouldn't submit it as a good example
> of an OO language. It provides all the same shortcomings of C (it's just a
> superset of C to begin with, poor start), it makes private members
> well-known (and hence not-so-private), etc. I won't go any further, better
> people than I have already done so. ;)

  I'd say (or maybe Stroustrap said, I don't really remember) that C++
supports OO (quite well), but is not really OO language in the same way
e.g. smalltalk is.

	erik



Reply to: