From: mortee Date: 2007-10-13T19:35:55+09:00 Subject: Re: I don't like my code -- what can I do? Daniel Waite wrote: > But this makes my controller code ugly (I think) because of the way the > interface is setup. The fact that it's heavily biased towards parts and > not vendors leaves me wanting to write things like > part.request_bid_from_vendor and part.set_default_prices_for_vendor but > then Part knows too much about BidRequest. > > If it were biased towards vendors I imagine I'd write the inverse of > what I just showed you. But is there a way to be biased towards neither? > Take a cue from REST and treat BidRequest like a resource? Hi, just to drop in my $.02 naively. I guess that some part of your code would have to know about BidRequest statuses anyway. It's either the Parts which can collect corresponding requests belonging to a specific vendor, and selecting which applies. Or the Vendor can, given a Part, select the corresponding requests and select the appropriate one. If you want neither to know about the ins and outs of this selection algorithm, you'll need a BidRequest broker, which, given a Part and a Vendor (and possibly a Client, too), yields you with whatever bid applies out of all the available ones - taking into consideration whether whether these are valid completed ones, and in case there's no such bid, then look for a default one. You could then use this broker to specify those default bids, too. The logic has to be specified at one place or another, it's just a question of whether you really want to decouple it from everything, or not. mortee