[Tutor] Python scripts: to use class or not — what is the best practice?

Alan Gauld alan.gauld at yahoo.co.uk
Mon Mar 16 20:44:11 EDT 2020


On 16/03/2020 22:41, DL Neil via Tutor wrote:

> More recently Grady Booch's view of Object-Oriented Programming (OOP) 
> talked of "encapsulation" - I'm a little wary of quoting his ideas 
> (which are nevertheless valid) because their implementation is an 
> anathema to Python and the pythonic way of thinking, 

I'm not sure I'd agree with that. Grady's ideas were expressed in
his OOD book from 1991 - 29 years ago - and were in line with
common thinking about OOP at the time.

Grady was (and is) a big fan of information hiding (which is
separate to, but often confused with, ecapsulation), an
important feature of creating robust systems. But he is not a
big fan of getters/setters.  Rather he follows the idioms of
the languages he uses. So, in his second edition he primarily
used Java and so included getters/setters but in both his 1st
and 3rd editions (both multi-lingual) he uses the conventions
of the language, often without getter/setter methods.

But that nit-pick aside, I agree with what you wrote... :-)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list