[Tutor] Usefulness of classes and necessity of inheriting classes

Alan Gauld alan.gauld at btinternet.com
Mon Nov 25 15:30:45 CET 2013


On 25/11/13 13:29, Albert-Jan Roskam wrote:
> <snip until MIB ;-)>

 > ===> interesting. Is this (a) the same as or (b)
 > similar to Abstract Base Classes (ABC) in Python?


>   MIB...is usually defined in terms of Managed Objects(MO). There is
>   a standard protocol (a set of methods or API) that all MOs
>   must adhere to.

A MO is an abstract base class. I don't know what/how
Python supports for ABC but the concept of abstract base classes
is at the root of almost all OO designs. In fact OO design
is largely about extracting out the common elements from
a group of classes and creating an abstract superclass (or
set of them) from that. The main framework of the application
is then created around manipulating the abstract classes.
The amount of bespoke, class specific code is thus minimized.
The bespoke elements are hidden inside the class implementations
of the abstract behaviour. In an ideal solution this allows you
to add new classes to the system without making any changes
to the application itself. It is rarely that simple in practice!

>   switches, printers etc) all have their own specialist
>   methods/features on top of the standard MO protocol.

These are non-abstract base classes. That is to say it's perfectly 
possible, and quite common, to actually create instances of a generic 
printer or switch (possibly because a class doesn't exist yet for
that make/model or because it has no unique features).


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list