Re: Mixing OO and DB

From: Bob Badour <bbadour_at_pei.sympatico.ca>
Date: Mon, 10 Mar 2008 00:09:26 -0300
Message-ID: <47d4a668$0$4028$9a566e8b_at_news.aliant.net>


Gene Wirchenko wrote:

> 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.
I find centralizing them all also has the benefit that one can write them in the same order as they appear in the functional specification. It makes it very easy to audit the code against the specs. Received on Mon Mar 10 2008 - 04:09:26 CET

Original text of this message