Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #20829

Re: Redundant return()

From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c
Subject Re: Redundant return()
Date 2012-05-16 09:56 +1200
Message-ID <a1g1o0Fd96U5@mid.individual.net> (permalink)
References (5 earlier) <jote6e$5e0$1@dont-email.me> <a1fqsoFd96U1@mid.individual.net> <20120515125648.406@kylheku.com> <a1fs0vFd96U3@mid.individual.net> <4fb2c107$0$21939$426a74cc@news.free.fr>

Show all headers | View raw


On 05/16/12 08:48 AM, Lanarcam wrote:
> Le 15/05/2012 22:18, Ian Collins a écrit :
>> On 05/16/12 08:08 AM, Kaz Kylheku wrote:
>>> On 2012-05-15, Ian Collins<ian-news@hotmail.com>  wrote:
>>>> On 05/15/12 11:20 PM, BartC wrote:
>>>>> "Stefan Ram"<ram@zedat.fu-berlin.de>  wrote:
>>>>>
>>>>>> If it is complex, we put it into a function »f«, so:
>>>>>
>>>>> But the body of f() will still be complex (as you've only eliminated a
>>>>> couple of lines; it that now makes it simple, then it was *not*
>>>>> complex!);
>>>>> then what? Suppose there were several such returns in a function?
>>>>> You would
>>>>> end up *increasing* complexity (by extra functions, extra names, extra
>>>>> interfaces) for no discernible benefit. Actually it would be
>>>>> probably be
>>>>> slower, less readable, and more buggy.
>>>>
>>>> Testing. A large, complex, function is hard to test. More less complex
>>>> functions are easier to test. That's why code written test first won't
>>>> contain large, complex, functions.
>>>
>>> Sure it will. Start with a small well-tested function, and grow it,
>>> carefully
>>> testing every increment. You end up with a big function that is supported
>>> by a large number of tests.
>>
>> That only happens if you don't refactor as you go. Even if it is well
>> tested, a big function is still a fragile thing.
>>
> IMO, a function, for reasons of maintenance, must be short,
> two pages max, and easily understandable. Large chunks of code
> should be replaced with calls to functions with meaningful names
> and few parameters. It should be easy to understand it at the
> first reading without being lost in obscure details and forgetting
> the logic of the whole.

Two *pages*? blimey.

-- 
Ian Collins

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-12 21:41 +0000
  Re: Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-12 21:56 +0000
    Re: Redundant return() Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2012-05-12 17:07 -0600
  Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-12 18:46 -0400
    Re: Redundant return() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-12 20:10 -0400
      Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-12 21:29 -0400
  Re: Redundant return() Barry Schwarz <schwarzb@dqel.com> - 2012-05-12 15:49 -0700
    Re: Redundant return() pembed2012 <once@was.enough.invalid> - 2012-05-14 16:40 +0000
      Re: Redundant return() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-05-14 17:57 +0100
      Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 00:33 -0700
        Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 03:03 -0700
          Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-15 03:26 -0700
          Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 08:51 -0400
        Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 12:20 +0100
          Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 07:59 +1200
            Re: Redundant return() Kaz Kylheku <kaz@kylheku.com> - 2012-05-15 20:08 +0000
              Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 08:18 +1200
                Re: Redundant return() Lanarcam <lanarcam1@yahoo.fr> - 2012-05-15 22:48 +0200
                Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 09:56 +1200
            Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 22:59 +0100
              Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 10:16 +1200
                Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-16 09:29 +0100
        Re: Redundant return() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-15 07:51 -0400
        Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 08:47 -0400
          Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 08:01 +1200
          Re: Redundant return() "BartC" <bc@freeuk.com> - 2012-05-15 22:58 +0100
            Re: Redundant return() Ian Collins <ian-news@hotmail.com> - 2012-05-16 10:24 +1200
              Re: Redundant return() James Kuyper <jameskuyper@verizon.net> - 2012-05-15 18:39 -0400
              Re: Redundant return() nick_keighley_nospam@hotmail.com - 2012-05-16 02:45 -0700
  Re: Redundant return() Noob <root@127.0.0.1> - 2012-05-16 13:34 +0200

csiph-web