[placement][ptg] code refactoring constraints and goals

Ed Leafe ed at leafe.com
Thu Apr 11 18:02:12 UTC 2019


On Apr 11, 2019, at 12:07 PM, Eric Fried <openstack at fried.cc> wrote:
> 
> (1) Pass `self` to the db method. This grates on me pretty bad. It
> screams that the thing should be an instance method.

That is actually a pretty old design pattern: passing a data object, rather than a slew of parameters. Of course, it would be cleaner to keep them as instance methods, and that would be my preference. I know that you have expressed an interest in reducing the overall size of the individual modules, so this option is only valid if smaller modules is decided on as a Good Thing™, 

> (2) Pass in the attributes that are needed by the method, and return the
> ones that the caller needs to use to update itself. This may make for
> some ugly call/return signatures.

I can’t think of a more brittle approach. 

-- Ed Leafe








More information about the openstack-discuss mailing list