Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Better practices for code formatting

    So what kind of advice do we have for code formatting? There's an FAQ entry on BB code snippets that suggests using [ code ] to format things out. Example:

    Code:
    sysuse auto, clear
    regress mpg foreign
    test foreign == 0
    However, it insists on breaking the line and putting (a totally unnecessary) "Code:" introduction on top, which is silly: everybody sees this is code. And if I need to do five snippets throughout my post, it gets annoying.

    I see that some people started using typeface. To me, bold means I really want to stress something important in my post, and I thought that was the common part of the netiquette. Code formatting has to be done differently, and I think proportional font works better: regress does look more like something I would type in the command line, and I would really love to see an option to change the background color to grey to highlight it even more... and it would definitely help to have a button to do this for (i) inline, and (ii) paragraph (which is the [#] button does now).

    Do we want to develop a common community strategy for this? NJC's main FAQ does not seem to be mentioning formatting at this stage; may be it should, now that we have moved to a somewhat richer environment.

    Thanks, Stas
    Last edited by skolenik; 10 Apr 2014, 14:25.
    -- Stas Kolenikov || http://stas.kolenikov.name
    -- Principal Survey Scientist, Abt SRBI
    -- Opinions stated in this post are mine only


  • #2
    Originally posted by skolenik View Post
    However, it insists on breaking the line and putting (a totally unnecessary) "Code:" introduction on top, which is silly: everybody sees this is code. And if I need to do five snippets throughout my post, it gets annoying.

    I see that some people started using typeface. To me, bold means I really want to stress something important in my post, and I thought that was the common part of the netiquette. Code formatting has to be done differently, and I think proportional font works better: regress does look more like something I would type in the command line
    I started a topic related to this issue here, but it seems like it needs a big push. Maybe we could do a poll.
    Last edited by Roberto Ferrer; 11 Apr 2014, 10:54.
    You should:

    1. Read the FAQ carefully.

    2. "Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly!"

    3. Describe your dataset. Use list to list data when you are doing so. Use input to type in your own dataset fragment that others can experiment with.

    4. Use the advanced editing options to appropriately format quotes, data, code and Stata output. The advanced options can be toggled on/off using the A button in the top right corner of the text editor.

    Comment


    • #3
      The convention regress rather than regress came out of pre-launch discussions. No names, no pack-drill. It's not in the FAQ because no-one thought it was obviously the one and only possible right thing.

      My personal take is to support discussion of this on the forum and let a consensus emerge. Note that absolutely no one is prohibited from anything different.

      I've not seen dissent from the view that using code boxes is absurd style for single names, so that uses such as

      Code:
      regress
      are not banned, but just not encouraged at all. Contrary to what I might appear to imply elsewhere, we want as few rules as possible here, although we might strongly about those few rules.

      A good style will be one that others will consciously and easily want to copy without being argued or persuaded into it.

      Comment


      • #4
        What is the rationale for the "Code:" header and the extra blank line in code boxes? Both seem unnecessary and have no obvious benefit for users of the forum.

        Comment

        Working...
        X