您好,欢迎访问三七文档
DREWTECHNOLOGIES,INC.Page1of30October22,1999ProjectNotebookStorageLocation:DrewTechnologiesCorporateLibraryACodingStandardfortheCProgrammingLanguageDrewTechnologiesInc.Copyright©1996,1999Contact:DrewTechnologies,Inc.41EnterpriseDriveAnnArbor,MI48103(734)623-8080support@drewtech.comDREWTECHNOLOGIES,INC.October22,1999DrewTechnologies,Inc.ProprietaryPage2of30RevisionHistoryDATECOMMENTS04-Sep-96FinalDraft22-Oct-99Englishcorrections,addressupdateDREWTECHNOLOGIES,INC.October22,1999DrewTechnologies,Inc.ProprietaryPage3of30TABLEOFCONTENTS1.Introduction___________________________________________________________51.1Scope_______________________________________________________________51.2References__________________________________________________________52.ProcessProblem________________________________________________________53.RootCausesandEffects_________________________________________________63.1PoorMaintainability___________________________________________________63.2PoorPortability/Reusability____________________________________________73.3ArgumentsforEfficiency_______________________________________________74.Recommendations______________________________________________________84.1GeneralNamingConventions___________________________________________84.1.1NamingVariables___________________________________________________________84.1.2NamingFunctions_________________________________________________________104.1.3NamingStructures&StructureMembers________________________________________104.1.4NamingConstantsMacros&Typedefs_________________________________________104.2Indentation_________________________________________________________114.2.1IndentationofBasicFlowControlStatements____________________________________114.2.1.1SimpleIfStatement_______________________________________________________114.2.1.2CompoundIfStatement___________________________________________________124.2.1.3ForStatement___________________________________________________________134.2.1.4WhileStatement_________________________________________________________134.2.2IndentationofSwitchStatements______________________________________________144.2.3IndentationofStructuresandUnions___________________________________________164.3Parenthesis_________________________________________________________174.4Comments__________________________________________________________184.5PreprocessorDirectives_______________________________________________184.6ProgramStructure___________________________________________________184.6.1ModuleLayout____________________________________________________________194.7DeadCode_________________________________________________________204.8IncludeFiles________________________________________________________214.9ModuleHeader______________________________________________________234.10FunctionHeader___________________________________________________244.11WhiteSpace______________________________________________________244.12LowLevelDataAbstraction__________________________________________244.13CompilerandProcessorDependence__________________________________254.14HardwarePlatformDependence______________________________________25DREWTECHNOLOGIES,INC.October22,1999DrewTechnologies,Inc.ProprietaryPage4of304.15UnitTestCode____________________________________________________274.16Efficiency_________________________________________________________285.Conclusions__________________________________________________________286.AppendixA___________________________________________________________297.AppendixB___________________________________________________________30DREWTECHNOLOGIES,INC.October22,1999DrewTechnologies,Inc.ProprietaryPage5of301.IntroductionThisdocumentisproposedasthecodingstandardforallCprogramswrittenbyDrewTechnologiesthatarenotrequiredtofollowanexternalcodingstandardspecifiedbythecustomer.1.1ScopeThisdocumentisacollectionofrulesandguidelinesthatincludeissuesrelatednotonlytotheClanguage,butalsosoftwareengineeringandprogramportabilityingeneral.Thescopeofthisdocumentissuchthatitismosteffectivewhenappliedattheearlieststagesofcoding.Mostifnotalloftheconceptsandpracticesproposedinthisdocumentcanbeappliedtothemaintenanceofcodethatdoesnotconformtothisstandard.1.2ReferencesHarbison,S.P.,1991,CAReferenceManual,PrenticeHallInc.ANSI,1989,AmericanNationalStandardX3.159-1989Oualline,S.,1992,CElementsofStyle,M&TBooksInc.Libes,D.1993,ObfuscatedCandOtherMysteries,JohnWiley&SonsInc.2.ProcessProblemWithoutacodingstandardinplace,thereisnoframeworkthroughwhichwecan:•Enforcegoodstructuredprogrammingpractices•Provideareferenceforcodewalkthroughsandinspections•MakecodeeasiertounderstandandmaintainDREWTECHNOLOGIES,INC.October22,1999DrewTechnologies,Inc.ProprietaryPage6of303.RootCausesandEffectsItispossibletowritehopelesslyobscurecodeinanylanguage.TheCprogramminglanguagehassomeverypowerfulfeatures,whichcanbemisusedtomakeprogramshardtounderstand,anddothingsthatarewidelyrecognizedasbadsoftwareengineering.Anyprocessputintoplacemustminimizethelikelihoodthatthis
本文标题:A Coding Standard for the C Programming Language
链接地址:https://www.777doc.com/doc-6229716 .html