Re: Mixing OO and DB

From: Marshall <>
Date: Thu, 28 Feb 2008 22:42:04 -0800 (PST)
Message-ID: <>

On Feb 28, 5:05 pm, topmind <> wrote:
> But it is not "upping" the abstraction enough to justify all the
> method proliferation. It's almost like:
> function addTwoNumbers(a, b) {
> return (a + b);
> }

I don't think that's a good analogy. It's too high level compared to Mr. Martin's proposal. A better analogy:

function addOne(a) {
  return a+1;

Then later if you also discover a different sum is needed, you can extend the model thusly:

function addTwo(a) {
  return a+2;

Later, if you discover you just *have* to be able to add two arbitrary numbers, (sigh) you can do something like this:

function addArbitraryValue(a, b) {
  switch (b)
  case 1:
    return addOne(a);
  case 2:
    return addTwo(a);

> It's nonsensical busy work for one-off usages. Maybe OOP is a jobs
> creation program?
> By the way, I forgot to mention a compromise:
> function getEmployees(criteria) {
> return query(std, "select * from empl where " . criteria);
> }
> This way you don't have to create a method for every different
> predicate one can dream up.

That's not bad. For full generality, though, you need to migrate the select clause and from clause in as well. If you can precompute the necessary string, you can reduce it to:

function get(query) {
  return odbcExec(handle, query);

Marshall Received on Fri Feb 29 2008 - 07:42:04 CET

Original text of this message