[Tutor] [Slightly OT] Inheritance, Polymorphism and Encapsulation

Alan Gauld alan.gauld at btinternet.com
Wed Sep 19 09:52:27 CEST 2007


"Michael Langford" <mlangford.cs03 at gtalumni.org> wrote 

> OOP without classes is quite common still. This is how a 
> good portion of the Linux kernel is written 

True, but as I understand it the Linux approach is to use C 
structs to mimic some class type behaviour. Essentially 
binding data and functions inside a struct. Is that not the case?

What I was referring to was the lack of any kind of class 
structure at all, a purely prototype driven OOP style. 
(Somewhat like JavaScript OOP except that it's very easy 
to fake classes in JavaScript)

My first OOP project was in pure C and used a combination 
of structs and a function protocol to identify objects, it was 
mostly modelled on ADA and had no inheritance mechanism.
The concept got refined into an intenal OOP dialect of C 
called Cellular C (if I recall correctly) which did have a class 
type concept (the cell, of course!) before we eventually 
adopted C++.

> very maintainable way to write C, some studies show 
> that it is more maintainable than equivalent projects 
> in C++, 

I agree, C++ - especially in its post v2.0 forms - has 
become a minefield of temporary objects and unexpected 
constructor calls.

> lots  to do with C++ containing not just the kitchen
> sink but the bathroom sink and a bidet too).

:-)

All true and the reason I've mostly given up 
programming in C++! Indeed one of my biggest fears 
for Python is that I see worrying signs that people are 
trying to cram in every programming fad going and there 
is a danger that it too acquires the kind of baggage 
that C++ has gathered over the years.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list