C++ Guidelines

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jeffc

    #61
    Re: C++ Guidelines


    "Pete Vidler" <pvidler@mailbl ocks.com> wrote in message
    news:OVZdc.83$7 w.18@newsfe1-gui.server.ntli .net...[color=blue][color=green]
    > >
    > > A suggestion. Functions could easily be longer once you add blank lines[/color][/color]
    and[color=blue][color=green]
    > > comments. Functions that are pretty straightforward but long, say[/color][/color]
    because[color=blue][color=green]
    > > they have to read in a lot of input arguments, are fine, it seems to me.[/color][/color]
    As[color=blue][color=green]
    > > soon as you start to process input arguments and do stuff, that's when[/color][/color]
    the[color=blue][color=green]
    > > long function should raise a bell.
    > >
    > > A related concept is that functions should have few input arguments.[/color]
    >
    > I usually adhere to this one because I find that I make fewer mistakes
    > if the entire method is immediately available. I'm not sure how this
    > relates to the number of arguments, but I'll accept that as a suggestion.[/color]

    Worry about cohesion rather than number of lines. If you worry too much
    about number of lines, then you'll start breaking down every 2 lines into
    function, and that can make things *less* readable ultimately.


    Comment

    • Siemel Naran

      #62
      Re: C++ Guidelines

      "jeffc" <nobody@nowhere .com> wrote in message
      news:407ac299_1 @news1.prserv.n et...[color=blue]
      > "Siemel Naran" <SiemelNaran@RE MOVE.att.net> wrote in message[/color]
      [color=blue][color=green][color=darkred]
      > > > - Header files should be self contained, from various sources.[/color]
      > >
      > > What?[/color]
      >
      > Makes sense to me, and I wholeheartedly agree. Nothing worse than
      > unnecessary dependencies in header files.[/color]

      You mean like header A.h fails to include B.h though it depends on entities
      from B.h. Then the user who includes A.h has to include B.h first then A.h.
      Is this what you mean? If so, definitely this is a good rule.

      In fact, my cpp files always include the h file as the first non-comment
      line. But in windows they have this stdafx.h if you use pre-compiled
      headers, and so you shouldn't by accident include B.h in this file.


      Comment

      Working...