Re: Mixing OO and DB
Date: Sun, 09 Mar 2008 19:10:57 -0700
Message-ID: <vp59t31qeeov7jv821m6cqurg5i6b1fqg0@4ax.com>
Robert Martin <unclebob_at_objectmentor.com> wrote:
>On 2008-03-06 16:05:47 -0600, Gene Wirchenko <genew_at_ocis.net> said:
>
>> Robert Martin <unclebob_at_objectmentor.com> 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
I remember when paper listings were the usual way to deal with the program.
[snip]
>>
>> 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.
It depends on what is being coded. It might go either way. At some point, the code has to do something.
>> 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.
Suppose I have a form to validate, and I need to validate the input values. There may be dependencies between some of the controls' values. I usually find it way easier to validate in one method since the validations are somewhat short and ad hoc (from the point-of-view of the program).
Each of the validations including the error handling is usually less than ten lines long. I have the validations limited to one method. It usually is not worth the time to break it up any further. Sometimes, it is for some of the validations. Then, I will break them out. Usually, it is not.
YMMV. Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.
Received on Sun Mar 09 2008 - 21:10:57 CDT
