Created
June 27, 2015 01:18
-
-
Save wagamama/879f0ef78372f1cd6559 to your computer and use it in GitHub Desktop.
Clean Code - Ch. 6 The Law of Demeter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class C: | |
def __init__(self): | |
self.foo = Foo() | |
def f(self, arg_foo): | |
# call method of C | |
self.other_f() | |
# call method of an object created by f | |
local_foo = Foo() | |
local_foo.bar() | |
# call method of an object passed as an argument to f | |
arg_foo.bar() | |
# call method of an object held in an instance vairable of C | |
self.foo.bar() | |
def other_f(self): | |
pass | |
class Foo: | |
def bar(self): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment