Does This Belong In a Dictionary?
Jere Kahanpaa
kahanpaa at gstar.astro.helsinki.fi
Mon Dec 9 08:29:34 EST 2002
More information about the Python-list mailing list
Mon Dec 9 08:29:34 EST 2002
- Previous message (by thread): Does This Belong In a Dictionary?
- Next message (by thread): Does This Belong In a Dictionary?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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) Jere Kahanpää -- It's hard to think outside the box when you ARE the box. - unknown, alt.religion.kibology
- Previous message (by thread): Does This Belong In a Dictionary?
- Next message (by thread): Does This Belong In a Dictionary?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list