fosclipse-core
Hex Artifact Content
Not logged in

Artifact 059df37955dbfdfa1a059b65d7703ae1ec5626e3:

Wiki page [Coding Style] by jan.nijtmans 2012-07-23 06:34:47.
0000: 44 20 32 30 31 32 2d 30 37 2d 32 33 54 30 36 3a  D 2012-07-23T06:
0010: 33 34 3a 34 37 2e 31 30 39 0a 4c 20 43 6f 64 69  34:47.109.L Codi
0020: 6e 67 5c 73 53 74 79 6c 65 0a 50 20 33 32 64 63  ng\sStyle.P 32dc
0030: 34 66 34 63 35 30 66 64 33 32 66 38 36 38 65 30  4f4c50fd32f868e0
0040: 64 37 61 35 37 32 31 33 64 37 34 31 63 63 65 30  d7a57213d741cce0
0050: 36 32 35 31 0a 55 20 6a 61 6e 2e 6e 69 6a 74 6d  6251.U jan.nijtm
0060: 61 6e 73 0a 57 20 31 34 31 34 0a 3c 68 32 3e 43  ans.W 1414.<h2>C
0070: 6f 64 69 6e 67 20 53 74 79 6c 65 3c 2f 68 32 3e  oding Style</h2>
0080: 0d 0a 0d 0a 3c 70 3e 42 79 20 64 65 66 61 75 6c  ....<p>By defaul
0090: 74 2c 20 74 68 65 20 64 65 66 61 75 6c 74 20 3c  t, the default <
00a0: 62 3e 45 63 6c 69 70 73 65 3c 2f 62 3e 20 63 6f  b>Eclipse</b> co
00b0: 64 69 6e 67 20 73 74 79 6c 65 20 69 73 20 61 73  ding style is as
00c0: 73 75 6d 65 64 2c 20 62 75 74 20 61 20 66 65 77  sumed, but a few
00d0: 20 73 6d 61 6c 6c 20 6d 6f 64 69 66 69 63 61 74   small modificat
00e0: 69 6f 6e 73 20 61 72 65 20 6d 61 64 65 2e 20 3c  ions are made. <
00f0: 2f 70 3e 0d 0a 0d 0a 3c 68 33 3e 45 6e 66 6f 72  /p>....<h3>Enfor
0100: 63 69 6e 67 3c 2f 68 33 3e 0d 0a 3c 70 3e 48 6f  cing</h3>..<p>Ho
0110: 77 20 63 61 6e 20 77 65 20 65 6e 66 6f 72 63 65  w can we enforce
0120: 20 74 68 65 20 73 79 73 74 65 6d 20 28 6e 6f 74   the system (not
0130: 20 74 68 65 20 70 65 6f 70 6c 65 21 29 20 6b 65   the people!) ke
0140: 65 70 69 6e 67 20 74 68 65 20 61 67 72 65 65 64  eping the agreed
0150: 2d 75 70 6f 6e 0d 0a 63 6f 64 69 6e 67 20 73 74  -upon..coding st
0160: 79 6c 65 20 69 6e 20 61 6c 6c 20 73 6f 75 72 63  yle in all sourc
0170: 65 20 66 69 6c 65 73 3f 20 53 69 6d 70 6c 79 20  e files? Simply 
0180: 62 79 20 75 73 69 6e 67 20 74 68 65 20 45 63 6c  by using the Ecl
0190: 69 70 73 65 20 66 65 61 74 75 72 65 20 74 68 61  ipse feature tha
01a0: 74 0d 0a 65 76 65 72 79 20 22 73 61 76 65 22 20  t..every "save" 
01b0: 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 64 6f  automatically do
01c0: 65 73 20 74 68 65 20 6e 65 63 65 73 73 61 72 79  es the necessary
01d0: 20 66 69 78 65 73 2e 20 54 68 69 73 20 6f 6e 6c   fixes. This onl
01e0: 79 20 77 6f 72 6b 73 20 69 66 20 74 68 65 0d 0a  y works if the..
01f0: 45 63 6c 69 70 73 65 20 66 6f 72 6d 61 74 74 65  Eclipse formatte
0200: 72 20 64 6f 65 73 20 65 78 61 63 74 6c 79 20 77  r does exactly w
0210: 68 61 74 20 69 73 20 69 6e 74 65 6e 64 65 64 2e  hat is intended.
0220: 20 53 6f 2c 20 69 66 20 79 6f 75 20 74 68 69 6e   So, if you thin
0230: 6b 20 74 68 61 74 0d 0a 6f 6e 65 20 6f 66 20 74  k that..one of t
0240: 68 65 20 72 75 6c 65 73 20 62 65 6c 6f 77 20 6d  he rules below m
0250: 61 6b 65 20 79 6f 75 72 20 6c 69 66 65 20 75 6e  ake your life un
0260: 6e 65 63 65 73 73 61 72 79 20 64 69 66 66 69 63  necessary diffic
0270: 75 6c 74 2c 20 70 6c 65 61 73 65 20 73 75 62 6d  ult, please subm
0280: 69 74 0d 0a 61 20 74 69 63 6b 65 74 20 6f 6e 20  it..a ticket on 
0290: 69 74 2e 3c 2f 70 3e 0d 0a 0d 0a 3c 68 33 3e 53  it.</p>....<h3>S
02a0: 63 72 65 65 6e 20 77 69 64 74 68 20 31 33 32 3c  creen width 132<
02b0: 2f 68 33 3e 0d 0a 3c 70 3e 41 20 6c 69 6e 65 20  /h3>..<p>A line 
02c0: 77 69 74 68 20 6f 66 20 38 30 20 63 68 61 72 61  with of 80 chara
02d0: 63 74 65 72 73 20 69 73 20 62 65 69 6e 67 20 63  cters is being c
02e0: 6f 6e 73 69 64 65 72 65 64 20 74 6f 6f 20 72 65  onsidered too re
02f0: 73 74 72 69 63 74 69 76 65 2c 20 73 6f 20 61 20  strictive, so a 
0300: 6c 69 6e 65 20 77 69 64 74 68 20 6f 66 20 31 33  line width of 13
0310: 32 20 63 68 61 72 61 63 74 65 72 73 20 69 73 20  2 characters is 
0320: 63 68 6f 73 65 6e 2e 20 57 68 79 20 31 33 32 3f  chosen. Why 132?
0330: 20 53 69 6d 70 6c 79 20 62 65 63 61 75 73 65 20   Simply because 
0340: 69 74 20 77 61 73 20 74 68 65 20 6e 65 78 74 20  it was the next 
0350: 61 76 61 69 6c 61 62 6c 65 20 6c 69 6e 65 20 77  available line w
0360: 69 64 74 68 20 61 76 61 69 6c 61 62 6c 65 20 69  idth available i
0370: 6e 20 6f 6c 64 20 49 42 4d 20 33 32 37 30 2d 63  n old IBM 3270-c
0380: 6f 6d 70 61 74 69 62 6c 65 20 6d 6f 6e 69 74 6f  ompatible monito
0390: 72 73 20 61 6e 64 20 70 72 69 6e 74 65 72 73 3c  rs and printers<
03a0: 2f 70 3e 0d 0a 3c 70 3e 54 68 69 73 20 63 68 61  /p>..<p>This cha
03b0: 6e 67 65 20 6d 61 6b 65 20 69 74 20 70 6f 73 73  nge make it poss
03c0: 69 62 6c 65 20 74 6f 20 70 6c 61 63 65 20 70 61  ible to place pa
03d0: 72 61 6d 65 74 65 72 73 20 76 61 6c 75 65 73 20  rameters values 
03e0: 77 69 74 68 20 63 6f 6d 6d 65 6e 74 73 0d 0a 69  with comments..i
03f0: 6e 20 6a 61 76 61 64 6f 63 20 66 75 6e 63 74 69  n javadoc functi
0400: 6f 6e 20 63 6f 6d 6d 65 6e 74 20 62 6c 6f 63 6b  on comment block
0410: 73 20 6f 6e 20 61 20 73 69 6e 67 6c 65 20 6c 69  s on a single li
0420: 6e 65 2e 20 57 69 74 68 20 38 30 20 63 68 61 72  ne. With 80 char
0430: 61 63 74 65 72 73 20 6f 6e 20 61 20 6c 69 6e 65  acters on a line
0440: 2c 20 74 68 65 72 65 20 6f 66 74 65 6e 20 69 73  , there often is
0450: 20 6e 6f 74 20 65 6e 6f 75 67 68 20 73 70 61 63   not enough spac
0460: 65 20 74 6f 20 64 6f 20 74 68 61 74 2e 3c 2f 70  e to do that.</p
0470: 3e 0d 0a 0d 0a 3c 68 33 3e 44 6f 6e 27 74 20 66  >....<h3>Don't f
0480: 6f 72 63 65 20 6c 69 6e 65 20 6a 6f 69 6e 3c 2f  orce line join</
0490: 68 33 3e 0d 0a 3c 70 3e 49 66 20 61 20 64 65 76  h3>..<p>If a dev
04a0: 65 6c 6f 70 65 72 20 73 70 6c 69 74 73 20 61 20  eloper splits a 
04b0: 6c 69 6e 65 20 66 6f 72 20 72 65 61 64 61 62 69  line for readabi
04c0: 6c 69 74 79 2c 20 45 63 6c 69 70 73 65 20 73 68  lity, Eclipse sh
04d0: 6f 75 6c 64 20 72 65 73 70 65 63 74 20 74 68 61  ould respect tha
04e0: 74 2e 20 45 63 6c 69 70 73 65 27 73 20 64 65 66  t. Eclipse's def
04f0: 61 75 6c 74 20 66 6f 72 20 74 68 69 73 20 6f 70  ault for this op
0500: 74 69 6f 6e 20 69 73 20 22 6f 66 66 22 20 66 6f  tion is "off" fo
0510: 72 20 62 61 63 6b 77 61 72 64 73 20 63 6f 6d 70  r backwards comp
0520: 61 74 69 62 69 6c 69 74 79 20 77 69 74 68 20 6f  atibility with o
0530: 6c 64 65 72 20 45 63 6c 69 70 73 65 20 76 65 72  lder Eclipse ver
0540: 73 69 6f 6e 73 20 77 68 69 63 68 20 64 69 64 6e  sions which didn
0550: 27 74 20 68 61 76 65 20 74 68 69 73 20 6f 70 74  't have this opt
0560: 69 6f 6e 2e 20 42 75 74 20 77 69 74 68 6f 75 74  ion. But without
0570: 20 74 68 69 73 2c 20 74 68 65 72 65 20 61 72 65   this, there are
0580: 20 74 6f 6f 20 6d 61 6e 79 20 65 78 61 6d 70 6c   too many exampl
0590: 65 73 20 74 68 61 74 20 45 63 6c 69 70 73 65 20  es that Eclipse 
05a0: 77 6f 75 6c 64 20 63 72 65 61 74 65 20 75 6e 6e  would create unn
05b0: 65 63 65 73 73 61 72 79 20 6c 6f 6e 67 20 6c 69  ecessary long li
05c0: 6e 65 73 2c 20 65 78 70 65 63 69 61 6c 6c 79 20  nes, expecially 
05d0: 77 69 74 68 20 61 20 73 63 72 65 65 6e 20 77 69  with a screen wi
05e0: 64 74 68 20 6f 66 20 31 33 32 2e 3c 2f 70 3e 0d  dth of 132.</p>.
05f0: 0a 0a 5a 20 31 63 38 37 38 33 62 62 32 63 66 32  ..Z 1c8783bb2cf2
0600: 64 64 63 66 65 36 66 63 65 33 63 39 34 64 37 62  ddcfe6fce3c94d7b
0610: 37 37 65 37 0a                                   77e7.