What style to choose?

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

    What style to choose?

    What style do you prefer? Where to place brackets? How to name
    variables, functions, constants, etc. How do you format your source
    code? Do you write comments?
  • Mike Wahler

    #2
    Re: What style to choose?

    "maths_fan" <maths_fan@mail .ru> wrote in message
    news:c13b5d9.03 10190543.326b00 a0@posting.goog le.com...[color=blue]
    > What style do you prefer?[/color]

    Clear and readable.
    [color=blue]
    > Where to place brackets?[/color]

    Such that they contribute to the above.
    [color=blue]
    >How to name
    > variables, functions, constants, etc.[/color]

    Such that they express their purpose.
    [color=blue]
    > How do you format your source
    > code?[/color]

    Such that it's clear and readable.
    [color=blue]
    > Do you write comments?[/color]

    Yes, when they aid readability, otherwise not.

    -Mike


    Comment

    • Irrwahn Grausewitz

      #3
      Re: What style to choose?

      maths_fan@mail. ru (maths_fan) wrote:
      [color=blue]
      >What style do you prefer?[/color]
      Baroque.
      [color=blue]
      >Where to place brackets?[/color]
      On the wall.
      [color=blue]
      >How to name
      >variables, functions, constants, etc.[/color]
      Pick random scrabble pieces out of a bag.
      [color=blue]
      >How do you format your source
      >code?[/color]
      With an editor.
      [color=blue]
      >Do you write comments?[/color]
      No. The purpose of writing comments is to confuse the reader.
      They're only useful in military strength code.

      --
      Irrwahn
      (irrwahn33@free net.de)

      Comment

      • Malcolm

        #4
        Re: What style to choose?


        "maths_fan" <maths_fan@mail .ru> wrote in message[color=blue]
        > What style do you prefer?
        > Where to place brackets?[/color]
        I always place brackets one above the other, and always have a bracket as
        the only entry on its line.[color=blue]
        > How to name variables, functions, constants, etc.[/color]
        Generally I think one should use mathematical conventions - eg i for a loop
        counter, x for a general real and y for a dependent one, N for a count etc.
        An angle would be theta.
        You do have problems with namespace collisions in C.[color=blue]
        > How do you format your source code?[/color]
        Without tabs, 2 spaces of indents.[color=blue]
        >Do you write comments?[/color]
        A function needs a comment to expalin what it does, what parameters it
        takes, and what it returns. Usually heavy commenting of the function body
        should be unnecessary because the function should be simple enough for
        another programmer to see what is going on.


        Comment

        • Richard Heathfield

          #5
          Re: What style to choose?

          Irrwahn Grausewitz wrote:
          [color=blue]
          > maths_fan@mail. ru (maths_fan) wrote:
          >[color=green]
          >>Do you write comments?[/color]
          > No. The purpose of writing comments is to confuse the reader.[/color]

          That is merely an unfortunate side-effect of badly-written or
          poorly-maintained comments.
          [color=blue]
          > They're only useful in military strength code.[/color]

          All code should be "military" strength.

          I know you're just winding the guy up, but it's fairly obvious that /he/
          doesn't know that - hence this clarification.

          --
          Richard Heathfield : binary@eton.pow ernet.co.uk
          "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
          C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
          K&R answers, C books, etc: http://users.powernet.co.uk/eton

          Comment

          • Mathew Hendry

            #6
            Re: What style to choose?

            On 19 Oct 2003 06:43:51 -0700, maths_fan@mail. ru (maths_fan) wrote:
            [color=blue]
            >What style do you prefer?[/color]

            The one true style, obviously. :)
            [color=blue]
            >Where to place brackets?[/color]

            Cuddled except for function definitions, where they go one line under.
            [color=blue]
            >How to name variables[/color]

            By function.
            [color=blue]
            >functions[/color]

            By variable.
            [color=blue]
            >constants[/color]

            Constantly.
            [color=blue]
            >How do you format your source code?[/color]

            As I go... (seriously: adjusting formatting after the fact tends to confuse
            version control systems).
            [color=blue]
            >Do you write comments?[/color]

            /* FIXME: broken */

            (Yes, direct quote I'm afraid :)

            Serious answer: simple, undertandable, consistent.

            -- Mat.

            Comment

            Working...