Skip to content

Update coding standard for examples #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BillWagner opened this issue Jul 31, 2021 · 4 comments
Closed

Update coding standard for examples #358

BillWagner opened this issue Jul 31, 2021 · 4 comments
Assignees
Labels
type: clarity While not technically incorrect, the Standard is potentially confusing

Comments

@BillWagner
Copy link
Member

See #9 (comment)

Our coding style was optimized for the printed page. We've agreed to update the examples to follow a more consistent C# coding standard that uses whitespace to improve readability.

Much of the code is fine, but we will adopt the following updates:

  • Add a blank line between peer declarations. There is one exception to this rule: If a group of peer declarations all have empty bodies (e.g. class C {} or public void M() {}, then no blank line is added between them.
  • Different types of elements can be grouped without blank lines. When that's done, there should be a blank line between elements of different types. (e.g. all private fields can be declared without a blank line, but there should be a blank line between the group of private fields and method declarations).

We have discussed replacing the K&R style braces on methods with Allman style braces. We haven't made an affirmative decision on that.

@jskeet jskeet added meeting: discuss This issue should be discussed at the next TC49-TG2 meeting type: clarity While not technically incorrect, the Standard is potentially confusing labels Sep 22, 2021
@jskeet
Copy link
Contributor

jskeet commented Nov 17, 2021

I suggest we defer discussing this one until a meeting where Mads is present.

@jskeet
Copy link
Contributor

jskeet commented Feb 23, 2022

Next actions:

  • Jon to amend the Word converter to spit out a histogram of line lengths
  • Jointly decide between 2 or 4 space indents
  • Bill and Jon to go through all examples to use consistent format

@jskeet jskeet removed the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Feb 23, 2022
@jskeet
Copy link
Contributor

jskeet commented Feb 24, 2022

Histogram of line lengths (length:count) for C# code:

  0: 188
  1: 1148
  2: 14
  3: 33
  4: 126
  5: 508
  6: 26
  7: 133
  8: 20
  9: 128
  10: 200
  11: 63
  12: 116
  13: 198
  14: 130
  15: 86
  16: 123
  17: 124
  18: 146
  19: 108
  20: 94
  21: 91
  22: 104
  23: 106
  24: 154
  25: 115
  26: 110
  27: 106
  28: 107
  29: 118
  30: 87
  31: 79
  32: 96
  33: 85
  34: 76
  35: 77
  36: 74
  37: 63
  38: 76
  39: 53
  40: 49
  41: 64
  42: 34
  43: 41
  44: 47
  45: 39
  46: 41
  47: 54
  48: 48
  49: 36
  50: 31
  51: 34
  52: 42
  53: 28
  54: 24
  55: 29
  56: 41
  57: 31
  58: 31
  59: 28
  60: 32
  61: 22
  62: 27
  63: 12
  64: 27
  65: 22
  66: 22
  67: 22
  68: 24
  69: 14
  70: 23
  71: 10
  72: 13
  73: 14
  74: 14
  75: 16
  76: 12
  77: 9
  78: 4
  79: 12
  80: 4
  81: 4
  82: 3
  83: 2
  84: 3
  86: 1
  88: 2
  89: 3
  90: 2
  92: 1
  101: 2
  102: 1
  104: 1
  118: 1

Having printed out all the lines with over 70 characters, almost all of them include comments that could be moved quite easily.

Looking at the converted Word document, I think we're actually safe to about 95 characters, which gives us quite a lot of wiggle room.

I propose we use a 4-space indent.

@jskeet
Copy link
Contributor

jskeet commented Apr 13, 2022

Done.

@jskeet jskeet closed this as completed Apr 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: clarity While not technically incorrect, the Standard is potentially confusing
Projects
None yet
Development

No branches or pull requests

2 participants