dimanche 25 janvier 2015

What returns a DAO?

Lets suppose that I have two classes Foo and Bar with each respective DAO.


Lets say that a foo has many bars.


So the method that returns the bars of a foo where should it go?



class FooDAO
def bars_from_foo(foo)
# return the bars of that foo
end
end

class BarDAO
def bars_from_foo(foo)
# returns the bars of that foo
end
end


My doubt is, does FooDAO only return foo objects? Or does FooDAO only include the methods that a foo will need?


In my opinion, I choose the first one: FooDAO only returns foo objects. Because, the method could be used from another class, that has nothing in common with the other DAO. I can't think in an example right now.


I would like to read some opinions from experts.


Aucun commentaire:

Enregistrer un commentaire