From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,92c39a3be0a7f17d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-11 10:43:48 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcline@optelnow.net (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: Future with Ada Date: 11 Mar 2002 10:43:47 -0800 Organization: http://groups.google.com/ Message-ID: References: <3C7E7CAD.7070504@mail.com> <3C7FB9D2.D9C6E055@boeing.com> <3C81DF1F.9000503@mail.com> <3C83A112.6080302@mail.com> <3C84223C.A356F466@adaworks.com> <3C853A04.34826F39@despammed.com> NNTP-Posting-Host: 198.23.5.11 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1015872228 29996 127.0.0.1 (11 Mar 2002 18:43:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 11 Mar 2002 18:43:48 GMT Xref: archiver1.google.com comp.lang.ada:21071 Date: 2002-03-11T18:43:48+00:00 List-Id: "Chad R. Meiners" wrote in message news:... > "Kevin Cline" wrote in message > news:dcfe911f.0203071252.582e0401@posting.google.com... > > > I used to happily program this way until I realized people > > (including me, after a few weeks) > > trying to read my code were drowning in details. Now I limit > > myself to one level of nesting per function, unless some > > performance analysis proves the function call overhead is too great. > > > > It's true that the complexity has to be somewhere, but it's not necessary > > nor desirable that it all be in one place. > > > I find it much easier to understand five ten-line functions > > than to understand one fifty-line function. > > If you had read the post you are replying to carefully, you would have > realized that the Marin is not advocating a practice that requires you to > always favor using deeply nested if statements. He is stating that there > are cases in which using nested if statements is the most appropriate > solution. > > You seem to be stating that there is never a case is which nested ifs are > appropriate (barring speed constraints). I find this claim very difficult > to believe. Is this the claim you really want to be making? That's pretty much it. Functions with nested ifs are hard to code correctly, and hard to understand. Worst, they're hard to test competely. A single function is the smallest unit that can be tested. Separating the top-level branches into separate functions allows each branch to be tested separately. Some people may enjoy painstakingly creating and verifying a complex function. I find that my accuracy improves if I write several small functions that can be easily read and tested. Additionally, I find that it's very often the case that a set of nested ifs would be better expressed in another way -- perhaps via data and a simple lookup function, or as a set of subclasses. I find that breaking up the function makes the overall structure more apparent.