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

Michael Langford mlangford.cs03 at gtalumni.org
Wed Sep 19 09:28:16 CEST 2007


(*)BTW Its also possible to do OOP without classes! This is not
often seen nowadays but there were several OOP languages in
the 70's and 80's that explored that route. Scheme is probably
the best known. Its a very different kind of OOP of course but the
basic concepts are all there.

OOP without classes is quite common still. This is how a good portion of the
Linux kernel is written (I do kernel modules/porting at my day job).

As far as classes go, they're largely a syntactic method for implicitly
passing a data member to the correct functions that should operate on it.
You can do that in pure procedural languages like C. (Its actually a very
very maintainable way to write C, some studies show that it is more
maintainable than equivalent projects in C++, but that has little to do with
C++'s OO features and lots  to do with C++ containing not just the kitchen
sink but the bathroom sink and a bidet too).

         --Michael


-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.TierOneDesign.com/
Entertaining: http://www.ThisIsYourCruiseDirectorSpeaking.com

On 9/19/07, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> "Ricardo Aráoz" <ricaraoz at gmail.com> wrote>
>
> > Encapsulation comes with OO - you get it for free.
> >
> > Encapsulation does not come with OO. It is something you must code
> > in
> > your classes.
>
> This depends on your definition of encapsulation.
> Many modern texts use a definition of encapsulation that relates
> to data hiding. Thus, making attributes private/protected etc is
> called
> encapsulation. This definition didn't start to appear till the very
> late
> 80's with the rise of C++. In the early days of OOP encapsulation
> was the act of binding data and functions together in a single code
> entity - a class(*).
>
> The early definition was a radical new idea in the 70's and 80's but
> with the advent of OOP languages liker C++/Java it becomes a
> fundamental concept so its easy to forget how important and
> fundamental encapsulation of data and function into a class is.
> It is literally the foundation of all Object Oriented and Object
> Based programming. And without an OOP that kind of
> encapsulation is very tricky to get right. Data hiding is a nice
> to have. Python OOP provides the original concept of encapsulation
> but doesn't really support the later meaning.
>
> (*)BTW Its also possible to do OOP without classes! This is not
> often seen nowadays but there were several OOP languages in
> the 70's and 80's that explored that route. Scheme is probably
> the best known. Its a very different kind of OOP of course but the
> basic concepts are all there.
>
> Regards,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070919/4f9e0535/attachment.htm 


More information about the Tutor mailing list