正文描述:《写好代码的10大秘诀》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、F•XCHANGF•XCHANGDEDEPPwwClicktobuyNOW!ClicktobuyNOW!wmwmwowo.d.c.d.cocu•trackocu•track10ThingsYouCanDoToWriteBetterCodeݭདҷⷕⱘकϾ⾬䆔ᵫ᭠DevelopmentManagerMicrosoftResearch,China1F•XCHANGF•XCHANGDEDEPPwwClicktobuyNOW!ClicktobuyNOW!wmwmwowo.d.c.d.cocu•trackoc
2、u•trackϔ⌕ҷⷕⱘ⡍ᗻ•剕Ầ•SolidandRobustCode•ㅔ⋕•MaintainableandSimpleCode•催ᬜ•FastCodeϔ⌕•ㅔⷁ•SmallCodeҷⷕ•݅ѿ•Re•usableCode•ৃ⌟䆩•TestableCode•ৃ⿏ỡ•PortableCode2F•XCHANGF•XCHANGDEDEPPwwClicktobuyNOW!ClicktobuyNOW!wmwmwowo.d.c.d.cocu•trackocu•trackWhyisthiscodebad?vo
3、idMyGirlFriendFunc(CORP_DATAInputRec,intCrntQtr,EMP_DATAEmpRec,floatEstimRevenue,floatYTDRevenue,intScreenX,intScreenY,COLOR_TYPEnewColor,COLOR_TYPEPrevColor,STATUS_TYPEstatus,intExpenseType){inti;for(i=1;i<100;i++)InputRec.revenue[i]=0;for(i=1;i<100;
4、i++)InputRec.expense[i]=CorpExpense[i];UpdateCorpDatabase(EmpRec);EstimRevenue=YTDRevenue*4.0/(float)CrntQtr;NewColor=PreColor;Status=Success;if(ExpenseType==1)for(i=1;i<12;i++)Profit[i]=Revenue[i]•Expense.Type1[i];elseif(ExpenseType==2)Profit[i]=Reve
5、nue[i]•Expense.Type2[i];elseif(ExpenseType==3){Profit[i]=Revenue[i]•Expense.Type3[i];3}F•XCHANGF•XCHANGDEDEPPwwClicktobuyNOW!ClicktobuyNOW!wmwmwowo.d.c.d.cocu•trackocu•trackWhyisthiscodebad?voidMyGirlFriendFunc(CORP_DATAInputRec,intCrntQtr,EMP_DATAEmp
6、Rec,floatEstimRevenue,floatYTDRevenue,intScreenX,intScreenY,COLOR_TYPEnewColor,COLOR_TYPEPrevColor,STATUS_TYPEstatus,intExpenseType){inti;for(i=1;i<100;i++)InputRec.revenue[i]=0;for(i=1;i<100;i++)InputRec.expense[i]=CorpExpense[i];UpdateCorpDatabase(E
7、mpRec);EstimRevenue=YTDRevenue*4.0/(float)CrntQtr;NewColor=PreColor;Status=Success;if(ExpenseType==1)for(i=1;i<12;i++)Profit[i]=Revenue[i]•Expense.Type1[i];elseif(ExpenseType==2)Profit[i]=Revenue[i]•Expense.Type2[i];elseif(ExpenseType==3){Profit[i]=Re
8、venue[i]•Expense.Type3[i];4}F•XCHANGF•XCHANGDEDEPPwwClicktobuyNOW!ClicktobuyNOW!wmwmwowo.d.c.d.cocu•trackocu•trackBecause…•Badfunctionname–Maintainability•CrashifCrntQtrequals0–Robustness•Nocomments–Maintainability•Unnecessaryforloop–Performan
显示全部收起