Skip to content

Instantly share code, notes, and snippets.

@wagamama
Created June 27, 2015 01:18
Show Gist options
  • Save wagamama/879f0ef78372f1cd6559 to your computer and use it in GitHub Desktop.
Save wagamama/879f0ef78372f1cd6559 to your computer and use it in GitHub Desktop.
Clean Code - Ch. 6 The Law of Demeter
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