Knowledge (XXG)

Coding conventions

Source 📝

25: 750:
detection activity. By definition, only the original author of a piece of code has read the source file before the code is submitted for review. Code that is written using consistent guidelines is easier for other reviewers to understand and assimilate, improving the efficacy of the defect detection
779:
The management of complexity includes the following basic principle: minimize the amount of code written during the project development. This prevents unnecessary work which prevents unnecessary cost, both upfront and downstream. This is simply because if there is less code, it is less work not only
908:
A convention in one language may be a requirement in another. Language conventions also affect individual source files. Each compiler (or interpreter) used to process source code is unique. The rules a compiler applies to the source creates implicit standards. For example, Python code is much more
783:
Complexity is managed both at the design stage (how the project is architectured) and at the development stage (by having simpler code). If the coding is kept basic and simple then the complexity will be minimised. Very often this is keeping the coding as 'physical' as possible - coding in a manner
802:
is modified to improve readability or improve its structure. Software is often refactored to bring it into conformance with a team's stated coding standards after its initial release. Any change that does not alter the behavior of the software can be considered refactoring. Common refactoring
754:
Even for the original author, consistently coded software eases maintainability. There is no guarantee that an individual will remember the precise rationale for why a particular piece of code was written in a certain way long after the code was originally written. Coding conventions can help.
767:
Where coding conventions have been specifically designed to produce high-quality code, and have then been formally adopted, they then become coding standards. Specific styles, irrespective of whether they are commonly adopted, do not automatically produce good quality code.
905:), it became the practice to write the code for a single (public) class in a single file (the 'one class per file' convention). Java has gone one step further - the Java compiler returns an error if it finds more than one public class per file. 880:
All software practitioners must grapple with the problem of organizing and managing a large number of sometimes complex instructions. For all but the smallest software projects, source code (instructions) are partitioned into separate
909:
consistently indented than, say Perl, because whitespace (indentation) is actually significant to the interpreter. Python does not use the brace syntax Perl uses to delimit functions. Changes in indentation serve as the delimiters.
699:
of a software project. Conventions may be formalized in a documented set of rules that an entire team or company follows, or may be as informal as the habitual coding practices of an individual. Coding conventions are not enforced by
829:
Coding conventions allow programmers to have simple scripts or programs whose job is to process source code for some purpose other than compiling it into an executable. It is common practice to count the software size
864:
has grown consistently since the 1950s. Some of the growth of this class of development tools stems from increased maturity and sophistication of the practitioners themselves (and the modern focus on
716:
is the most often cited reason for following coding conventions. In the introductory section on code conventions for the Java programming language, Sun Microsystems offers the following reasoning:
964:
The reason is that in Tcl, curly braces are not used only to delimit functions as in C or Java. More generally, curly braces are used to group words together into a single argument. In Tcl, the
889:. It was natural for programmers to collect closely related functions (behaviors) in the same file and to collect related files into directories. As software development shifted from purely 784:
that is very direct and not highly abstract. This produces optimal code that is easy to read and follow. Complexity can also be avoided simply by not using complicated tools for simple jobs.
1112: 615: 569: 1092: 1067: 536: 913:, which uses a brace syntax similar to Perl or C/C++ to delimit functions, does not allow the following, which seems fairly reasonable to a C programmer: 787:
The more complex the code is the more likely it is to be buggy, the more difficult the bugs are to find and the more likely there are to be hidden bugs.
608: 1087: 378: 1231: 1082: 526: 601: 501: 242: 521: 46: 672: 559: 835: 468: 232: 335: 68: 1186: 639:, practices, and methods for each aspect of a program written in that language. These conventions usually cover file organization, 733:
If you ship your source code as a product, you need to make sure it is as well packaged and clean as any other product you create.
458: 453: 209: 730:
Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.
1034: 1023: 668: 587: 1005: 648: 644: 478: 191: 171: 997: 756: 656: 388: 277: 267: 217: 818: 660: 564: 292: 257: 108: 1172: 898: 383: 355: 39: 33: 814: 506: 350: 237: 227: 166: 869: 272: 252: 50: 1132:"EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs" 413: 282: 262: 652: 541: 423: 302: 176: 857:. The tools specify the use of a set of tags, but their use within a project is determined by convention. 1047: 890: 808: 676: 483: 393: 345: 287: 1029: 664: 340: 307: 123: 113: 1235: 1055: 1306: 861: 831: 743: 713: 692: 632: 403: 247: 181: 148: 128: 89: 860:
Coding conventions simplify writing new software whose job is to process existing software. Use of
1017: 846: 398: 317: 143: 1205: 1072: 516: 1001:
for numerous examples and discussion. Common coding conventions may cover the following areas:
1097: 1039: 803:
activities are changing variable names, renaming methods, moving methods or whole classes and
636: 1218: 1107: 1102: 473: 436: 418: 408: 133: 1149: 865: 841:
Consistent coding standards can, in turn, make the measurements more consistent. Special
360: 312: 196: 118: 817:
plan for regular (or even continuous) refactoring making it an integral part of the team
1190: 886: 842: 804: 1300: 1150:"Code Conventions for the Java Programming Language : Why Have Code Conventions" 882: 103: 1162:
Robert L. Glass: Facts and Fallacies of Software Engineering; Addison Wesley, 2003.
1077: 1011: 987:(because the Tcl also uses the newline character to delimit the end of a command). 747: 640: 186: 746:
frequently involves reading source code. This type of peer review is primarily a
799: 795: 696: 688: 684: 759:
improves readability and reduces the time it takes to understand the software.
1272: 680: 727:
Hardly any software is maintained for its whole life by the original author.
695:
easier. Coding conventions are only applicable to the human maintainers and
138: 1257: 701: 511: 463: 448: 443: 724:
40%–80% of the lifetime cost of a piece of software goes to maintenance.
1051: 894: 854: 850: 834:) to track current project progress or establish a baseline for future 720:
Code conventions are important to programmers for a number of reasons:
683:
are highly recommended to follow these guidelines to help improve the
222: 902: 849:
are often used to process documentation, two notable examples are
297: 531: 910: 675:, architectural best practices, etc. These are guidelines for 18: 1131: 1287: 1230:
van Rossum, Guido (2006-09-19). Fred L. Drake, Jr (ed.).
872:), but also from the nature of the languages themselves. 1232:"Python Tutorial : First Steps Towards Programming" 1187:"What is Extreme Programming? : Design Improvement" 1288:"Why can I not start a new line before a brace group" 995:
There are a large number of coding conventions; see
780:
to create the application, but also to maintain it.
798:refers to a software maintenance activity where 1206:"C++ Coding Standard : Naming Class Files" 776:Complexity is a factor going against security. 609: 8: 1234:. Python Software Foundation. Archived from 1068:Comparison of programming languages (syntax) 616: 602: 80: 1088:List of software development philosophies 69:Learn how and when to remove this message 16:Standards and guidelines for writing code 815:Agile software development methodologies 32:This article includes a list of general 1123: 631:are a set of guidelines for a specific 88: 1083:List of tools for static code analysis 570:Electrical and electronics engineering 1173:"Complexity is the enemy of security" 7: 1286:Staplin, George Peter (2006-07-16). 1152:. Sun Microsystems, Inc. 1999-04-20. 983:is missing its second argument, its 38:it lacks sufficient corresponding 14: 496:Standards and bodies of knowledge 1273:"Summary of Tcl language syntax" 23: 588:Outline of software development 1: 1189:. XP Magazine. Archived from 1046:Coding standards include the 901:constructs (such as found in 1256:Raymond, Eric (2000-05-01). 1185:Jeffries, Ron (2001-11-08). 819:software development process 677:software structural quality 1323: 952:"$ i squared = " 885:and frequently among many 673:programming rules of thumb 351:Software quality assurance 1204:Hoff, Todd (2007-01-09). 979:. In the example above, 915: 336:Configuration management 1271:Tcl Developer Xchange. 971:takes two arguments, a 772:Reduction of complexity 560:Artificial intelligence 53:more precise citations. 1048:CERT C Coding Standard 1035:Programming principles 891:procedural programming 805:breaking large methods 736: 669:programming principles 484:Infrastructure as code 330:Supporting disciplines 1290:. 'the Tcler's Wiki'. 1219:FIFE coding standards 1113:The Power of 10 Rules 1030:Programming practices 811:) into smaller ones. 718: 712:Reducing the cost of 665:programming practices 341:Deployment management 862:static code analysis 847:source code comments 832:Source lines of code 744:Software peer review 714:software maintenance 708:Software maintenance 693:software maintenance 681:Software programmers 633:programming language 161:Paradigms and models 90:Software development 84:Part of a series on 1073:Hungarian Notation 1056:High Integrity C++ 991:Common conventions 893:(such as found in 755:Consistent use of 661:naming conventions 629:Coding conventions 479:Release automation 356:Project management 1098:Programming style 1040:Programming style 836:project estimates 637:programming style 626: 625: 517:ISO/IEC standards 79: 78: 71: 1314: 1292: 1291: 1283: 1277: 1276: 1268: 1262: 1261: 1260:. Linux Journal. 1253: 1247: 1246: 1244: 1243: 1227: 1221: 1216: 1210: 1209: 1201: 1195: 1194: 1182: 1176: 1169: 1163: 1160: 1154: 1153: 1146: 1140: 1139: 1128: 1108:Software quality 1103:Software metrics 960: 956: 953: 950: 947: 944: 941: 938: 935: 932: 929: 926: 923: 919: 876:Language factors 763:Coding standards 618: 611: 604: 565:Computer science 474:Build automation 81: 74: 67: 63: 60: 54: 49:this article by 40:inline citations 27: 26: 19: 1322: 1321: 1317: 1316: 1315: 1313: 1312: 1311: 1297: 1296: 1295: 1285: 1284: 1280: 1270: 1269: 1265: 1255: 1254: 1250: 1241: 1239: 1229: 1228: 1224: 1217: 1213: 1203: 1202: 1198: 1184: 1183: 1179: 1170: 1166: 1161: 1157: 1148: 1147: 1143: 1130: 1129: 1125: 1121: 1064: 993: 962: 961: 958: 954: 951: 948: 945: 942: 939: 936: 933: 930: 927: 924: 921: 917: 899:object-oriented 897:) towards more 878: 827: 825:Task automation 793: 774: 765: 741: 710: 635:that recommend 622: 593: 592: 583: 575: 574: 555: 547: 546: 497: 489: 488: 439: 429: 428: 374: 366: 365: 361:User experience 331: 323: 322: 213: 202: 201: 162: 154: 153: 99: 98:Core activities 75: 64: 58: 55: 45:Please help to 44: 28: 24: 17: 12: 11: 5: 1320: 1318: 1310: 1309: 1299: 1298: 1294: 1293: 1278: 1275:. ActiveState. 1263: 1248: 1222: 1211: 1196: 1193:on 2006-12-15. 1177: 1164: 1155: 1141: 1122: 1120: 1117: 1116: 1115: 1110: 1105: 1100: 1095: 1090: 1085: 1080: 1075: 1070: 1063: 1060: 1044: 1043: 1037: 1032: 1027: 1021: 1015: 1009: 992: 989: 916: 877: 874: 826: 823: 792: 789: 773: 770: 764: 761: 740: 737: 735: 734: 731: 728: 725: 709: 706: 697:peer reviewers 624: 623: 621: 620: 613: 606: 598: 595: 594: 591: 590: 584: 581: 580: 577: 576: 573: 572: 567: 562: 556: 553: 552: 549: 548: 545: 544: 539: 534: 529: 524: 519: 514: 509: 507:IEEE standards 504: 498: 495: 494: 491: 490: 487: 486: 481: 476: 471: 466: 461: 456: 451: 446: 440: 435: 434: 431: 430: 427: 426: 421: 416: 411: 406: 401: 396: 391: 386: 381: 375: 372: 371: 368: 367: 364: 363: 358: 353: 348: 343: 338: 332: 329: 328: 325: 324: 321: 320: 315: 310: 305: 300: 295: 290: 285: 280: 275: 270: 265: 260: 255: 250: 245: 240: 235: 230: 225: 220: 214: 212:and frameworks 208: 207: 204: 203: 200: 199: 194: 189: 184: 179: 174: 169: 163: 160: 159: 156: 155: 152: 151: 146: 141: 136: 131: 126: 121: 116: 111: 106: 100: 97: 96: 93: 92: 86: 85: 77: 76: 31: 29: 22: 15: 13: 10: 9: 6: 4: 3: 2: 1319: 1308: 1305: 1304: 1302: 1289: 1282: 1279: 1274: 1267: 1264: 1259: 1258:"Why Python?" 1252: 1249: 1238:on 2008-09-28 1237: 1233: 1226: 1223: 1220: 1215: 1212: 1207: 1200: 1197: 1192: 1188: 1181: 1178: 1174: 1168: 1165: 1159: 1156: 1151: 1145: 1142: 1137: 1133: 1127: 1124: 1118: 1114: 1111: 1109: 1106: 1104: 1101: 1099: 1096: 1094: 1091: 1089: 1086: 1084: 1081: 1079: 1076: 1074: 1071: 1069: 1066: 1065: 1061: 1059: 1057: 1053: 1049: 1041: 1038: 1036: 1033: 1031: 1028: 1025: 1022: 1019: 1016: 1013: 1010: 1007: 1004: 1003: 1002: 1000: 999: 990: 988: 986: 982: 978: 974: 970: 967: 914: 912: 906: 904: 900: 896: 892: 888: 884: 875: 873: 871: 867: 863: 858: 856: 852: 848: 844: 839: 837: 833: 824: 822: 820: 816: 812: 810: 806: 801: 797: 790: 788: 785: 781: 777: 771: 769: 762: 760: 758: 752: 749: 745: 738: 732: 729: 726: 723: 722: 721: 717: 715: 707: 705: 703: 698: 694: 690: 686: 682: 678: 674: 670: 666: 662: 658: 654: 650: 646: 642: 638: 634: 630: 619: 614: 612: 607: 605: 600: 599: 597: 596: 589: 586: 585: 579: 578: 571: 568: 566: 563: 561: 558: 557: 551: 550: 543: 540: 538: 535: 533: 530: 528: 525: 523: 520: 518: 515: 513: 510: 508: 505: 503: 500: 499: 493: 492: 485: 482: 480: 477: 475: 472: 470: 467: 465: 462: 460: 457: 455: 452: 450: 447: 445: 442: 441: 438: 433: 432: 425: 422: 420: 417: 415: 412: 410: 407: 405: 402: 400: 397: 395: 392: 390: 387: 385: 382: 380: 377: 376: 370: 369: 362: 359: 357: 354: 352: 349: 347: 346:Documentation 344: 342: 339: 337: 334: 333: 327: 326: 319: 316: 314: 311: 309: 306: 304: 301: 299: 296: 294: 291: 289: 286: 284: 281: 279: 276: 274: 271: 269: 266: 264: 261: 259: 256: 254: 251: 249: 246: 244: 241: 239: 236: 234: 231: 229: 226: 224: 221: 219: 216: 215: 211: 210:Methodologies 206: 205: 198: 195: 193: 190: 188: 185: 183: 180: 178: 175: 173: 170: 168: 165: 164: 158: 157: 150: 147: 145: 142: 140: 137: 135: 132: 130: 127: 125: 122: 120: 117: 115: 112: 110: 107: 105: 104:Data modeling 102: 101: 95: 94: 91: 87: 83: 82: 73: 70: 62: 52: 48: 42: 41: 35: 30: 21: 20: 1281: 1266: 1251: 1240:. Retrieved 1236:the original 1225: 1214: 1199: 1191:the original 1180: 1171:Tom Gillis. 1167: 1158: 1144: 1136:EditorConfig 1135: 1126: 1078:Indent style 1045: 1012:Indent style 998:Coding Style 996: 994: 984: 980: 976: 972: 968: 965: 963: 907: 879: 859: 840: 828: 813: 794: 786: 782: 778: 775: 766: 753: 742: 719: 711: 649:declarations 628: 627: 464:UML Modeling 459:GUI designer 124:Construction 114:Requirements 65: 56: 37: 1307:Source code 1042:conventions 1026:conventions 1020:conventions 1018:Line length 1014:conventions 1008:conventions 887:directories 800:source code 796:Refactoring 791:Refactoring 689:source code 685:readability 657:white space 641:indentation 182:Prototyping 177:Incremental 149:Maintenance 129:Engineering 51:introducing 1242:2014-08-17 1119:References 757:whitespace 653:statements 554:Glossaries 144:Deployment 59:April 2021 34:references 973:condition 809:functions 751:process. 702:compilers 691:and make 687:of their 373:Practices 197:Waterfall 172:Cleanroom 139:Debugging 109:Processes 1301:Category 1062:See also 870:security 645:comments 582:Outlines 512:ISO 9001 454:Profiler 449:Debugger 444:Compiler 419:Stand-up 1052:MISRA C 1006:Comment 975:and an 895:FORTRAN 855:doxygen 851:javadoc 845:within 739:Quality 253:Lean SD 192:V model 134:Testing 47:improve 1024:Naming 985:action 977:action 866:safety 748:defect 527:SWEBOK 248:Kanban 223:DevOps 187:Spiral 119:Design 36:, but 1093:MISRA 981:while 969:while 928:while 883:files 522:PMBOK 437:Tools 298:SEMAT 293:Scrum 167:Agile 966:word 955:incr 949:puts 937:< 868:and 853:and 843:tags 807:(or 537:IREB 532:ITIL 502:CMMI 379:ATDD 288:SAFe 258:LeSS 233:DSDM 934:$ i 918:set 911:Tcl 903:C++ 542:OMG 469:IDE 424:TDD 414:SBE 404:DDD 389:CCO 384:BDD 308:TSP 303:TDD 283:RUP 278:RAD 273:PSP 268:MSF 263:MDD 243:IID 238:FDD 228:DAD 218:ASD 1303:: 1134:. 1058:. 1054:, 1050:, 957:i 940:10 838:. 821:. 704:. 679:. 671:, 667:, 663:, 659:, 655:, 651:, 647:, 643:, 409:PP 399:CD 394:CI 318:XP 313:UP 1245:. 1208:. 1175:. 1138:. 959:} 946:{ 943:} 931:{ 925:0 922:= 920:i 830:( 617:e 610:t 603:v 72:) 66:( 61:) 57:( 43:.

Index

references
inline citations
improve
introducing
Learn how and when to remove this message
Software development
Data modeling
Processes
Requirements
Design
Construction
Engineering
Testing
Debugging
Deployment
Maintenance
Agile
Cleanroom
Incremental
Prototyping
Spiral
V model
Waterfall
Methodologies
ASD
DevOps
DAD
DSDM
FDD
IID

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.