Re: Mixing OO and DB

From: Robert Martin <>
Date: Sat, 8 Mar 2008 16:32:43 -0600
Message-ID: <2008030816324343658-unclebob_at_objectmentorcom>

On 2008-03-06 16:05:47 -0600, Gene Wirchenko <> said:

> Robert Martin <> wrote:
> [snip]

>> A function should be no longer than five or ten lines of code.  This is
>> about as obvious and self-evident as it can be.  Are you really going
>> to argue that functions should be longer?

> Hmm. It used to be a page. Attention spans are getting shorter?
It used to be: "No longer than a screenful". Average size would be
considerably less. That rule was invented when a "screenful" was the number of lines on a VT100 -- 24. And four of them were used by the editor for administrative purposes. So, 20 lines as a maximum.
> Of course I am going to argue against such ridiculously low
> limits. Some functions are longer. Splitting them up into small
> pieces can make them much harder to follow.

It can also make them much easier to follow if you do a good job.

> I have had cases of snippets, that if I were to convert them to
> functions, what with all of the context that I would have to pass and
> handle, that the calling sequence (setup, call, wrapup) could be
> longer than the snippet. That way lies madness.

Holding contexts like that is what objects are for. If you have lots of local variables in a function that make it hard to split the function up, it means you need a new class.

Robert C. Martin (Uncle Bob)  | email:
Object Mentor Inc.            | blog:
The Agile Transition Experts  | web:
800-338-6716                  |
Received on Sat Mar 08 2008 - 23:32:43 CET

Original text of this message