1709.易读代码的艺术(影印版).pdf
文本预览下载声明
易读代码的艺术(影印版)
猛点这里下载全部内容
目录:
PREFACE
PREFACE
CODESHOULDBEEASYTOUNDERSTAND
WhatMakesCodeBetter?
TheFundamentalTheoremofReadability
IsSmallerAlwaysBetter?
DoesTime-TilI-UnderstandinRConflictwithOtherGoals?
TheHardPart
PartOneSURFACE-LEVELIMPROVEMENTS
PACKINGINFORMATIONINTONAMES
ChooseSpecificWords
AuoidGenericNamesLikeImpandretual
PreferConcreteNamesouerAbstractNames
Attachin9ExtraInformationtoaName
HowLon.gShouldaNameBe?
UseNameFormattingtoConueyMeaning
Summary
NAMESTHATCANTBEMISCONSTRUED
Example:FilterO
Example:Clip(text,length)
Preferrainandmaxfor(Inclusiue)Limits
PreferfirstandlastforInelusiueRanRes
Preferherinandendfor.lnclusiue/ExclusiueRanRes
NaminRBooleans
MatchinRExpectationsofUsers
Example:EualuatinRMultipleNameCandidates
Summary
ESTHETICS
WhyDoAestheticsMatter?
BearranReLineBreakstoBeConsistentandCompact
UseMethodstoCleanUpIrreRularity
UseColumnAliRnmentWhenHelpful
PickaMeaninRfulOrder,andUseItConsistently
OrRanizeDeclarationsintoBlocks
BreakCodeintoParafgraphs
PersonalStyleuersusConsistency
Summary
KNOWINGWHATTOCOMMENT
WhatNOTtoComment
Becordin9YourThouyhts
PutYourselfintheReadersShoes
FinalThoughts--GettingOverWritersBlock
Summary
6MAKINGCOMMENTSPRECISEANDCOMPACT
KeepCommentsCompact
AvoidAmbiguousPronouns
PolishSloppySentences
DescribeFunctionBehaviorPrecisely
UseInput/OutputExamplesThatIllustrateCornerCases
StatetheIntentofYourCode
NamedFunctionParameterComments
UseInformation-DenseWords
Summary
PartTwoSIMPLIFYINGLOOPSANDLOGIC
MAKINGCONTROLFLOWEASYTOREAD
TheOrderofArgumentsinConditionals
TheOrderofif/elseBlocks
The?:ConditionalExpression(a.k.a.TernaryOperator)
AvoiddogwhileLoops
ReturningEarlyfromaFunction
TheInfamousgoto
MinimizeNesting
CanYouFollowtheFlowofExecution?
Summary
BREAKINGDOWNGIANTEXPRESSIONS
Explainin9Variables
SummaryVariables
UsingDeMorgansLaws
AbusingShort-CircuitLogic
Example:WrestlingwithComplicatedLogic
BreakingDownGiantStatements
AnotherCreativeWaytoSimplifyExpressions
Summary
VARIABLESANDREADABILITY
EliminatinfgVariables
ShrinktheS
显示全部