Does This Belong In a Dictionary? REDUX

beno zope at thewebsons.com
Mon Dec 9 08:38:11 EST 2002


At 01:29 PM 12/9/2002 +0000, you wrote:
>beno <zope at thewebsons.com> wrote:
> > Hi;
> > I'm writing UML for a shopping cart. Some of the methods have huge amounts
> > of variables passed back and forth. For example, the following:
>
> >
>cueForShipment(customerID:int;basketID:int,firstName:string,middleInitial:string,lastName:string,address1:string,address2:string,city:string,state:string,zip:string,shipFirstName='':string,shipLastName='':string,shipaddress1='':string,shipAddress2='':stri
>ng,shipCity='':string,shipState='':string,shipZip='':string,country:string;shipCountry='':string,wrapGift:bool)
>
> > Should I simply pack everything but the IDs into a dictionary?
>
>A short answer: Yes, but even better solutions exist...
>
>A longer one: I'd use a simple class for this.
>
>class CustomerInfo:
>    def __init__(self): # Add arguments if preferred
>       self.firstName = None
>       self.shipState = ''
>       self.shipZip = ''  # etc.
>    # Maybe other methods, such as PrintShippingLabel ?
>
>customer = CustomerInfo()
>customer.firstName = 'Jere'  # ect.
>
>and use it as a parameter:
>
>cueForShipment(basketID,customer)

Spoke too fast. Yeah, I'm already doing that <;-) But since I'm separating 
the UI and the PD, I'm still calling it out of the PD to render in the UI, 
so I guess the dictionary is the way to go for the rendering, eh?
TIA,
beno






More information about the Python-list mailing list