Re: Mixing OO and DB

From: Robert Martin <unclebob_at_objectmentor.com>
Date: Mon, 3 Mar 2008 19:39:53 -0600
Message-ID: <2008030319395395335-unclebob_at_objectmentorcom>


On 2008-03-03 10:38:36 -0600, topmind <topmind_at_technologist.com> said:

>
>
> Robert Martin wrote:
>> On 2008-02-28 10:36:03 -0600, topmind <topmind_at_technologist.com> said:

>>> One-usage wrappers are a waste of code in my opinion and just
>>> creates tedious red-tape accessor clutter.
>> 
>> Not if they are explanatory.

>
> Like I suggested elsewhere, use *comments*.

No, please don't. If you have something to say, try to say it in your programming language. Only use a comment when you cannot find a way to simply express yourself in your programming language.

> Using methods/functions in
> place of comments is not economic,

It's much easier on the eye, and much easier on the brain of the person reading the code. Since code is read much more than it is written, this makes it very economical.

> and makes the code unnecessarily
> cluttered with micro-methods, making it harder to find the "meat"
> methods.

We don't want meat methods. You want many small methods that build upon each other and tell a story.

We divide english into smallish paragraphs in order to separate individual concepts. A thousand line paragraph is an abomination and indicates a lack of discipline and skill on the part of the author.

We separate programs into methods for the same reason. We want each method to be trivial to understand. We want it's name to describe it's function. We want to read the program from the top to the bottom like a newspaper article. It should start with the big concepts, and get more and more detailed as your read down through the little functions. Like a newspaper article, you should be able to stop reading when you have gotten to the desired level of detail.

A function should be no longer than five or ten lines of code. A function should have no more than one indent level. The body of each if statement should call one function. The body of each loop statement should call one function.

> I cannot vouch for every eyeball out there, but it slows down
> my reading to have all that extra junk in there.

I'd bet you it doesn't.

-- 
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 Tue Mar 04 2008 - 02:39:53 CET

Original text of this message