Re: Mixing OO and DB
Date: Sun, 2 Mar 2008 12:47:41 -0600
On 2008-02-28 10:36:03 -0600, topmind <topmind_at_technologist.com> said:
>> Of course we can implement other kinds of 'find' methods.
>> find_by_date, find_by_salary, etc, etc. Every different query we use
>> on a regular basis, we can create a verb for in our DSL. That verb is
>> a function call of some kind.
> Such only makes sense if you do the same kind of query in *multiple*
> spots. One-usage wrappers are a waste of code in my opinion and just
> creates tedious red-tape accessor clutter.
Not if they are explanatory. Employee.find("Bob") is a lot easier to understand than Select * from Employee_Table where Name = 'Bob'; In any case, once you have the method, you can polymorphically replace it with test methods etc.
>> So we have not lost the power of the flexible query language. We still
>> have it, and we still use it. But we also hide it from the bulk of the
>> That allows us to create a polymorphic API below which we can swap out
>> different database implementations, or even stubs and dummies .
> No it wont.
Of course it does. If you have a suite of methods through which you make all your queries, you can polymorphically replace the implementations of those methods.
> OOP here is a solution looking for a problem.
Not at all. The problem is very simple. Run 10,000 business rule
tests through your application in under a minute. Doing this with the
datbase in place is a lot harder than polymorphically replacing the
Not at all. The problem is very simple. Run 10,000 business rule tests through your application in under a minute. Doing this with the datbase in place is a lot harder than polymorphically replacing thedatabase.
-- Robert C. Martin (Uncle Bob) | email: unclebob_at_objectmentor.com Object Mentor Inc. | blog: www.butunclebob.com The Agile Transition Experts | web: www.objectmentor.com 800-338-6716 |Received on Sun Mar 02 2008 - 19:47:41 CET