Skip to content

Instantly share code, notes, and snippets.

@MarceloCajueiro
Created November 29, 2012 18:28
Show Gist options
  • Save MarceloCajueiro/4170956 to your computer and use it in GitHub Desktop.
Save MarceloCajueiro/4170956 to your computer and use it in GitHub Desktop.
Violação de Demeter
class A
def do_things(b)
b.c.do_things #violação de demeter
end
end
class B
attr_reader c
end
class C
def do_things
end
end
class A
def do_things(b, intermediario)
intermediario.do_things(b.c) #sem violação
end
end
class Intermediario
def do_things(c)
c.do_things
end
end
class B
attr_writer :c
end
class C
def do_things
end
end
class A
def do_things(b)
b.c_do_things #sem violação
end
end
class B
attr_writer :c
def c_do_things
c.do_things
end
end
class C
def do_things
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment