Re: Mixing OO and DB

From: Robert Martin <unclebob_at_objectmentor.com>
Date: Sun, 2 Mar 2008 13:40:51 -0600
Message-ID: <200803021340518930-unclebob_at_objectmentorcom>


On 2008-02-29 00:42:04 -0600, Marshall <marshall.spight_at_gmail.com> said:

>> 
>> 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);
> }

"At last, one of them understands!"

  • Lord Raiden.
-- 
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 - 20:40:51 CET

Original text of this message