开发者

Recommended nomenclature: a better term than "parent"?

I am writing a connection-state keeping program based loosely on the "State" example here.

In the example, the class Radio passes a pointer (better term?) to AmState when instancing AmState:

class AmState(State):
    def __init__(self, radio):
    self.radio = radio

...
class Radio(object):
    def __init__(self):
        ...
        self.amstate = AmState(self)

The example stores this pointer (?) in the name 'radio', but what would be the correct Python/开发者_C百科OO term for this value? I keep wanting to say "parent", but 'AmState's parent is 'State', not 'radio'.

What is the terminology I should be using here to minimize confusion when documenting my code?

Thanks


The usual term for this sort of composition is "owner". And the "better term" you're looking for is "reference".


I suppose GOF Design Patterns is the nearest thing to canon, and it uses 'context'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜