Syntactic pain.. :P

Donn Cave donn at u.washington.edu
Wed Sep 8 12:23:49 EDT 1999


Quoth Markus Stenberg <mstenber at cc.Helsinki.FI>:
...
| Yes, exactly; that's why I'm using Python for rapid prototyping and not
| say, Java or C++ (yeech). I was mainly looking for more elegant way to do
| it, but judging from the replies I got, there was just slight
| beautification available to my approach, and apply still stayed. Oh well. 

OK, if you want some discipline, take this!

It seems to me, the notion that gets us started down this twisted path
is that a subclass extends its base class' constructor.  Some of the
parameters in the constructor are inherited and should be passed to
the base class constructor, and others are introduced by the subclass.

I don't think that's the only way to go.  It has some a maintenance
issues, obviously, especially since it seems to be understood that
both base and derived constructors' parameter lists are subject to 
revision, making it especially hard to keep everything sorted out.

Instead, a base class should provide however many initialization
functions are necessary to deal with its own specific construction.
The goal is to get everything to execute in its natural place in the
class hierarchy, instead of looking up base class methods explicitly.

I think this is more or less the direction folks have been pointing,
but it looks like ``slight beautification'' because no one has attempted
to supply a meaningful example so the initialization functions are
reduced to generic things like "setup".  In a real example, there'd be
a handful of things  --  "setserviceconnection(host, port=20)", etc.
This abstraction of the initialization process can be as radical and
rigorous as you want it to be.

	Donn Cave, University Computing Services, University of Washington
	donn at u.washington.edu




More information about the Python-list mailing list