"Ricardo Aráoz" <[EMAIL PROTECTED]> 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@python.org http://mail.python.org/mailman/listinfo/tutor