A design problem I met again and again.

andrew cooke andrew at acooke.org
Wed Apr 1 06:40:02 EDT 2009


Ò»Ê×Ê« wrote:
> 3. completely move codes in service to business classes.  Initialize
> these classes and pass them to protocol classes.
> These protocol classes calls these instances of business classes
> instead of call service.  These means whenever I add a new business
> class.  I have to add a parameter to __init__ methods of every
> protocol class.  Not very clear either.

i don't fully understand your problem, but i would guess (3) is the
correct solution.  you can probably avoid adding a new parameter by
writing code in a generic way (using lists of arguments, perhaps using
introspection to find method names, etc)

andrew





More information about the Python-list mailing list