Está en la página 1de 23

The Definitive Guide To

tm tm

Building Code Quality


Don Jones

Introduction

IntroductiontoRealtimePublishers
by Don Jones, Series Editor

Forseveralyearsnow,Realtimehasproduceddozensanddozensofhighqualitybooks thatjusthappentobedeliveredinelectronicformatatnocosttoyou,thereader.Weve madethisuniquepublishingmodelworkthroughthegeneroussupportandcooperationof oursponsors,whoagreetobeareachbooksproductionexpensesforthebenefitofour readers. Althoughwevealwaysofferedourpublicationstoyouforfree,dontthinkforamoment thatqualityisanythinglessthanourtoppriority.Myjobistomakesurethatourbooksare asgoodasandinmostcasesbetterthananyprintedbookthatwouldcostyou$40or more.Ourelectronicpublishingmodeloffersseveraladvantagesoverprintedbooks:You receivechaptersliterallyasfastasourauthorsproducethem(hencetherealtimeaspect ofourmodel),andwecanupdatechapterstoreflectthelatestchangesintechnology. Iwanttopointoutthatourbooksarebynomeanspaidadvertisementsorwhitepapers. Wereanindependentpublishingcompany,andanimportantaspectofmyjobistomake surethatourauthorsarefreetovoicetheirexpertiseandopinionswithoutreservationor restriction.Wemaintaincompleteeditorialcontrolofourpublications,andImproudthat weveproducedsomanyqualitybooksoverthepastyears. Iwanttoextendaninvitationtovisitusathttp://nexus.realtimepublishers.com,especially ifyouvereceivedthispublicationfromafriendorcolleague.Wehaveawidevarietyof additionalbooksonarangeoftopics,andyouresuretofindsomethingthatsofinterestto youanditwontcostyouathing.WehopeyoullcontinuetocometoRealtimeforyour educationalneedsfarintothefuture. Untilthen,enjoy. DonJones

Table of Contents IntroductiontoRealtimePublishers.................................................................................................................i Chapter1:QualityCodingforVisualStudioandthe.NETFramework............................................1 .NETFrameworkandVisualStudioOverview.......................................................................................1 . TheCLRandRelatedLanguages..............................................................................................................2 The.NETFrameworkClassLibrary........................................................................................................4 VisualStudio.....................................................................................................................................................5 Issueswith.NETDevelopment.................................................................................................................6 TheMicrosoftVisualStudioEnvironment................................................................................................7 ABriefHistoryofVisualStudio................................................................................................................8 VisualStudioDevelopmentMethodsandTechniques...................................................................9 VisualStudioSolutions,ProjectsandProcedures.........................................................................10 IssueswithVisualStudioDevelopmentandNativeToolsets...................................................10 UnderstandingandAssessingCodeQuality.........................................................................................11 Yardsticks:Errors,Completeness,Security,andPerformance...............................................11 CommonlyUsedCodeMetrics...............................................................................................................12 AutomatingCodeQualityAssessmentandUsingCodeQualityAssessmentstoDrive Development.................................................................................................................................................15 . UltimateQuality:DoesItMeettheRequirements?.......................................................................15 TopCodeQualitySnafus................................................................................................................................16 WhattoExpectinthisDefinitiveGuide..................................................................................................18

ii

Copyright Statement

Copyright Statement
2009 Realtime Publishers, Inc. All rights reserved. This site contains materials that have been created, developed, or commissioned by, and published with the permission of, Realtime Publishers, Inc. (the Materials) and this site and any such Materials are protected by international copyright and trademark laws. THE MATERIALS ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. The Materials are subject to change without notice and do not represent a commitment on the part of Realtime Publishers, Inc or its web site sponsors. In no event shall Realtime Publishers, Inc. or its web site sponsors be held liable for technical or editorial errors or omissions contained in the Materials, including without limitation, for any direct, indirect, incidental, special, exemplary or consequential damages whatsoever resulting from the use of any information contained in the Materials. The Materials (including but not limited to the text, images, audio, and/or video) may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way, in whole or in part, except that one copy may be downloaded for your personal, noncommercial use on a single computer. In connection with such use, you may not modify or obscure any copyright or other proprietary notice. The Materials may contain trademarks, services marks and logos that are the property of third parties. You are not permitted to use these trademarks, services marks or logos without prior written consent of such third parties. Realtime Publishers and the Realtime Publishers logo are registered in the US Patent & Trademark Office. All other product or service names are the property of their respective owners. If you have any questions about these terms, or if you would like information about licensing materials from Realtime Publishers, please contact us via e-mail at info@realtimepublishers.com.

iii

Chapter 1 [Editor'sNote:ThiseBookwasdownloadedfromRealtimeNexusTheDigitalLibraryfor ITProfessionals.AllleadingtechnologyeBooksandguidesfromRealtimePublisherscanbe foundathttp://nexus.realtimepublishers.com.]

Chapter1:QualityCodingforVisualStudio andthe.NETFramework
Therearemanythingsthatcontributetothequalityofanapplication.Fromtheinitial requirementsthroughthefunctionalspecifications,datamodeling,securityconsiderations, andchoiceofinterfacesandsupportservicesallcontributetohowwelltheapplication performs,howeasyitistomaintain,andhowwellpeoplewilladoptit.Butforallthese factors,nothingisasdirectlytellingasthequalityofthecodeitself.Asetofcrystalclear requirements,abrilliantarchitecture,themostfriendlyofuserinterfaces(UIs)sisnothing ifthecodedoesnotperformreliably,errorsarenotwellhandled,andthecodedoesnot performtheexpectedtasksquickly. Inthisguide,Iintendtowalkyouthroughtheprocessofbuildingaqualitycodingpractice. Imassumingthatyoureeitheraprofessionaldeveloperyourself,orthatyoumanage developersasamajorpartofyourjob.Imassumingthatyouveworkedwithrecent versionsofVisualStudioquiteabit,too.Fromgettingthemostfromthedevelopment environmenttowritingclearandefficientcodetoanalyzingandeliminatingerrorsbefore theybecomeissuestomakingtheapplicationsrunatpeakefficiency,thisguidewillhelp yourefineyourcodepracticeandchurnoutbettercodefaster. Thisguideisntjustaboutindentingyourcodeandhowtocapitalizevariablenames;well alsotacklemorecomplicatedtopicssuchastherightwaytoconductapeercodereview, howtoaddresssecurityandperformanceproblems,andmoreeverythingthat contributestoqualitycode.Wellbeginbymakingsurewereonthesamepagewithtoolset andtechnologies.

.NETFrameworkandVisualStudioOverview
Microsoftintroducedthe.NETFrameworkinearly2002.Itrepresentedasignificant changeinMicrosoftssoftwaredevelopmentstrategy,movingawayfromnativecodethat wascompiledforaspecifichardwareandoperatingsystem(OS)towardamoreJavalike modelthatofferedthepossibilityforbroaderplatformsupport. Note Nativecodeisabinarythatisloadeddirectlyintothememoryofthe processorandexecuted.MicrosoftWin32,COM,andDCOMapplicationsare compiledinthismanner.NativecodeisstillusedfortheOSanddevice drivers.Itcanrunfastbutisdifficulttowriteefficientlyandwithouterrors.

Chapter 1 Tosimplifyandsecuretheprocessofwritingcode,.NETusesatypeofvirtualmachine, calledtheCommonLanguageRuntime(CLR),asabufferbetweentheprocessorandthe application.Thislayercanmakethingsrunmoresecurely.Someofthecodingproblems thatwouldcauseacomputertocrasharemitigatedbythisapproach. .NETispurelyobjectoriented,supportingfullencapsulation,inheritance,and polymorphism.Itforcesthedeclarationofvariablesandastrictobjectlifecycle(aproblem thatfrequentlyplaguedCOMandcreatedmemoryleaks).NoneoftheMicrosoftlanguages priortothis,withtheexceptionofJ#,waspurelyobjectoriented.Objectoriented languagesarenotinherentlyofhigherqualitybuttheyoffermanyfeaturesandforcea certainprogrammingstylethatmakeiteasiertowritehighqualitycode. .NETintroducedstructurederrorhandlingforalllanguagesnotjustaboltonasitwasin earlierlanguagessuchasC++.Structurederrorhandlingisakeycapabilityforwriting higherqualitycode;withoutit,yourcodecannotrespondasconsistentlytoerror conditions. InadditiontotheFrameworkitself,Microsoftcreatednewversionsofitssoftware developmenttools,includingVisualStudiointegrateddevelopmentenvironment(IDE). TheFrameworkandFrameworkbaseddevelopmentarententirelywithoutitscritics,and MicrosoftitselfhasrunintosignificanthurdlesinusingtheFrameworktocreateOS components. OneproblemwiththeFrameworkissemantics:Theterm.NETFrameworkisused genericallytorefertoseveraldistinctelements,eachofwhichisimportanttocodequality inadifferentway.Inordertoenableourdiscussiononcodequality,andtomakeitclearer, weneedtofirstbreakdowntheFrameworkintoitsconstituentelements.

TheCLRandRelatedLanguages
WhendevelopersspeakofprogrammingfortheFramework,theyreusuallywritingcodein eithertheC#orVisualBasic(formerlyVB.NET)languagesalthoughotherlanguagesare available(MicrosoftprovidesC++andJ#;othermanufacturersprovideotherlanguages). Thebeautyofthisapproachisthattheprogrammercanwriteinthelanguagethatheor sheismostcomfortablewith.IfyouneedtoportcodefromaCOBOL,APL,Fortran,orother system,thatcodecanbeusedwithinthe.NETFramework,providingthatyouhavesupport forthatlanguage. ThelanguageinwhichtheprogramiswrittenisNOTthelanguagethattheFramework uses.Whenadeveloperbuilds(orcompiles,althoughthattermistechnicallyinaccurate)a C#project,whatsproducedisnotanexecutablecapableofrunningindependentlyona computersOS.Instead,VisualStudiosmainjobistotranslateyourVisualBasic,C#,J#,or whatevercodeintotheCommonIntermediateLanguage(CIL). Note YoullstillseethetermMSILprettyoften,althoughsincethelanguage specificationwasformalizedandstandardizedasECMA335,thetermCILis morecorrect.

Chapter 1 HeresanexampleofCILcode:
.methodstaticvoidmain() { .entrypoint .maxstack1 ldstr"Helloworld!" callvoid[mscorlib]System.Console::WriteLine(string) ret }

Itsactuallyaprettyunintuitive,hardtoreadlanguage,whichiswhyfewdeveloperswork initdirectly(fortheoldschoolaudience,thisisalotlikeAssemblylanguage).Onceyour codehasbeenconvertedtoCIL,itsfurtherassembledintobytecode(whichisessentiallya binarycompactformofshorthandforCIL),creatinga.NETassemblytypicallyanEXEor DLLfile,dependingonhowitwillbeexecuted.Figure1.1illustratesthisprocess.

Figure1.1:Compiling.NETFrameworkcode.

Chapter 1 WhenauserrunsanassemblycontainingCIL,theFrameworksCLRspringsintoaction. TheCLRreceivesthebytecodefromtheassemblyandexecutesaJustInTime(JIT) compilerthatgeneratescodecapableofexecutingontheplatformwithintheCLR.This modelallowscodetobewrittenonceandtobeexecutedonanyplatformforwhichaCLR isavailable.ThereisaperformancehitwhiletheJITconvertsthebytecodetoexecutable binary,butitcachestheresultingnativeimageforfutureuse(itautomaticallyrecompiles whenthesourceassemblyisseentohavechanged).AFrameworkutilitycalledNGENcan beusedtogeneratenativeimagesinadvance;thisprocesseliminatestheinitial performancepenaltybuttiesthenativeimagetoasingleplatform.Thatisonereason,for example,WindowsPowerShell(whichiswrittenintheFramework)isdistributedin differentversionsfordifferentWindowsOSs. TheCLRactsasatypeofvirtualmachine.TheCLRisresponsibleforexecutingFramework applications,handlingtheirmemoryusage,managinggarbagecollection,handling exceptions,managingsecurity,andsoforth.UnlikeJava,whichtypicallypermitsvery limitedaccesstotheunderlyinghostOS,theCLRisdesignedtoprovideaccesstothenative WindowsOSfeaturesalthoughitdoessoonlythroughastrictsetofsecuritycontrols.

The.NETFrameworkClassLibrary
Anintegralpartof.NETdevelopmentisthe.NETFrameworkclasslibrarywhatwecan properlyrefertoastheFramework.Thisisanextensivecollectionofpreprogrammed classesthatgivedevelopersmuchofthefunctionalitytheyneedtowriteapplications. Frameworkclassesexisttoconnecttodatabases,creategraphicaluserinterfaces(GUIs), andsoforth;developersjusttooversimplifyabitconnectthevariousclassestoone anothertocreateapplications.Thus,developersarelessconcernedaboutlowleveldetails suchashowtoopenandreadafile,andmoreconcernedabouthighlevelfunctionality, suchasimplementingbusinesslogic. TheFrameworkisextensible.Additionalclassescanbeaddedtocoverfunctionalitythat theFrameworkitselfdoesntaddressandthatadeveloperdoesntwanttocreatemanually. Classesforremoteconnectivity,creationofchartsandgraphs,alternativeUIelements,and soforthareallpopular. EachversionoftheFrameworkclasslibraryisunique,anddevelopersmusttargeta specificversionwhencreatingtheirapplications.Frameworkversionsarenotnecessarily cumulativenoraretheynecessarilycrosscompatible.Forexample,ifyoucreatean applicationthatusesfeaturesfromonlyv2oftheFrameworkbutyourprojecttargetsv3.5, yourapplicationwillrunonlyifv3.5oftheFrameworkisinstalledeventhoughv2 technicallycontainsalltheneededfunctionality. EachversionoftheFrameworktendstoaddnewclassestowhatcamebefore;eachversion mayalsocontainchangestofunctionalityintroducedinpreviousversions.Figure1.2 showsthemajorportionsoftheFrameworkasofv3.5,alongwithinitialplansforfuture versions.Asyoucansee,theFrameworkistrulyenormousmuchlargerandmoreall inclusivethansimilarclasslibrariesforlanguagessuchasC++.

Chapter 1

Figure1.2:The.NETFrameworkclasslibrary.

VisualStudio
Althoughyoucouldtechnicallycreate.NETapplicationsusingnothingmorethanWindows Notepadandthefreelyavailablelanguagecompilers,youprobablywouldntenjoyit.An IDEprovidesnumerousfeaturestomakedevelopmenteasierandfaster,andVisualStudio isthedefactoIDEformost.NETdevelopers.Availableinvariouseditionsthatoffer differentfeaturesandfunctionality,VisualStudioisdesignedfor.NETdevelopment(as wellasfordevelopingunmanagedC++applications).Itincludesacorecodeeditorand projectmanagementtools,andinsomeeditions,offersfeaturessuchassourcecontrol connectivity,testingtools,andsoforth.VisualStudioisextensible;whileMicrosoftdirectly supportsVisualBasic,J#,C++,andC#,thirdpartieshaveextendedsupportforlanguages suchasJava,COBOL,Fortran,APL,Chrome,F#,Python,andRuby.Freeexpresseditions supportonlyasinglelanguageeitherVisualBasicorC#,inmostcases,althoughexpress editionsforJ#andC++arealsoavailable. Figure1.3showsVisualStudio,andillustratesoneofitsmajorIDEfeatures:IntelliSense, Microsoftsbrandnameforitscodehintingandcodecompletionfeatures.

Chapter 1

Figure1.3:VisualStudio. WellbediscussingVisualStudioinmoredetailinjustabit.

Issueswith.NETDevelopment
TheFrameworkisntentirelywithoutissuesandcritics,andifweregoingtouseittobuild qualityapplications,weneedtoconsidersomeofthemajorcriticismsandunderstandhow theymayimposelimitationsonourownabilitytodeliverqualitycode. ApplicationsthatruninamanagedenvironmentwhichiswhattheCLRistendtoruna bitslowerorrequiremoresystemresourcesinordertorunasquicklyasapplicationsthat runnativelyontheOS.Thisperformanceissue,infact,wasacontributortoMicrosofts difficultiesdeliveringontechnologypromisessuchasWinFSandAvalon(afilesystemand graphicssubsystembasedonmanagedcode)forWindowsVista.Thisisanimportant considerationbecauseyou,asadeveloper,havelittlecontrolovertheperformancehit introducedbytheCLR;ifacertainsetofperformancemetricsaremandatedinyour softwaresrequirements,youcouldrunintosituationsinwhichyoucantoptimizethe performancefurtherbecausetheCLRisactingasabottleneckofsorts.Youreunlikelyto findsituationswhereyoucantproduceacceptableperformance,butdependingonthe aggressiveness(andrealism)ofyourrequiredperformancemetrics,meetingthosemetrics maybechallenging.

Chapter 1 FrameworkassembliescontainabytecodeversionofCIL,meaningyouareessentially distributingyoursourcecode.Numerousutilitiesexistthatcandecompilea.NET assemblyintoC#.Infact,mostoftheactualFrameworkclassescanbedecompiled,as Microsoftreliesonintellectualproperty(IP)lawtoprotectitssourcecode.Smaller developerswithfewerlawyersoftenturntoobfuscationtools,whichperformvarious semantictrickstorenderdecompiledcodelessreadable.ModernversionsofVisualStudio, infact,comewithacommunityeditionofapopularcommercialobfuscator,giving developersabaselineobfuscationcapabilityandtacitlyacknowledgingthedownsideof bytecodeassemblies. ManagedenvironmentssuchastheCLRmustperiodicallycleanupaftertheapplications theyrun.Thisprocess,calledgarbagecollection,involvesfreeingupandhelpingtode fragmentmemorythatisnolongerinusebytheapplicationsuchasmemorythathad beenallocatedforvariablesthatarenolongerinscope.Garbagecollectionhaltsexecution oftheapplicationforabit,andalthoughthistimeperiodisusuallyimperceptible,itcanin someinstancesbeperceivedaspoorapplicationquality.Developersmusttakesomecare todealwithmemoryaccordingtobestpracticessothatgarbagecollectiondoesntbecome animpedimenttotheapplication. TheexactversionoftheFrameworkyoudevelopforisimportant.Olderversions,suchas v2,arefairlyubiquitous,havingbeenaroundforsometimeandhavingbeenpreinstalled onmostmodernversionsofWindows.Newerversionsmaynotbeavailableonallclient computers,meaningthatrunningyourapplicationfirstrequiresuserstoinstalltheproper versionoftheFramework.VisualStudiohastraditionallybeenpooratallowingdevelopers totargetaspecificversionoftheFramework;VisualStudio2005,forexample,was introducedwithv2oftheFrameworkanddoesntreallyliketocompileassembliesthat arecompatiblewithv1.1oftheFrameworkeventhoughitcouldcreatesuchassemblies. TheFrameworkitselfaddsagreatdealofoverheadtoyourapplicationsfootprint:upto 197MBforv3.5oftheFramework.Althoughthisismitigatedbythefactthatmultiple applicationscansharethesameFrameworkinstallation,userswhoneedtohavev1.1,v2, v3,andv3.5installedtosupportvariousapplicationsaretakingaprettybighitintermsof drivespace.

TheMicrosoftVisualStudioEnvironment
ItmightseemlikeoverkilltotalkaboutanIDEinabookaboutcodequality,buttheIDEis whereyourewritingyourcode,sotheIDEiswherequalitybegins.AndinfactyourIDE candoalottohelporharmyourcodequality,dependingonhowyouusethatIDE.

Chapter 1

ABriefHistoryofVisualStudio
VisualStudiowasfirstreleasedin1997,bundlingmanyofMicrosoftsprogrammingtools forthefirsttime.Priortothatrelease,productssuchasVisualC++andVisualBasicwere independenttoolswiththeirown,uniqueIDEs.VisualStudio97includedVisualBasic5.0 andVisualC++5.0thiswasbeforethe.NETFrameworkwasevenaglimmerinanyones eye.VisualStudio97alsoincludedVisualJ++,VisualFoxPro5.0,andVisualInterDevfor WebdevelopmentaswellasMicrosoftsMSDNLibrarydocumentation. In1998,VisualStudio6.0wasintroducedandwasthelastversioncreatedtorununder Windows95,Windows98,orWindowsMe.Thiswasstillpre.NETFramework,witha focusonComponentObjectModel(COM)development,butitofferedamoreconsistent andunifiedIDEalthoughtheunifiedIDEwasusedonlybyVisualJ++andVisualInterDev; VisualBasic,C++,andFoxProcontinuedtousetheirowndistinctIDEs.Itoriginally includedVisualJ++,butthatwasdiscontinuedafterMicrosoftslegalsettlementwithSun Microsystems. In2002,VisualStudio.NETwasreleasedtocorrespondwiththefirstreleaseofthe Frameworkitself.ThisintroducedthecompletetransitiontoCLRmanagedcode,a commonIDEfortheincludedVisualBasic.NET,C#,andJ#programminglanguagesaswell asManagedC++,asetofextensionstoC++thatallowedfor.NETdevelopmentinthat language.VisualFoxProwasremovedfromVisualStudioandplacedonitsown developmenttrack;itisnota.NETFrameworklanguage. VisualStudio.NET2003included.NETFrameworkv1.1aswellasthe.NETCompact Frameworkformobiledevices.Thiswasafairlyminorupgradeinmanyrespects. AmoremajorupgradecameinVisualStudio2005,whenthe.NETmonikerwasdropped fromthename(Microsofthadbythistimedropped.NETfromthemanythingsithad beenappliedto,excepttheFrameworkitself).V2oftheFrameworkaccompaniedVisual Studio2005,andprojecttypesforASP.NETWebserviceswereaddedtotheIDE.64bit supportwasintroduced,althoughtheVisualStudioapplicationitselfwasonly32bit. SubsequentaddonstoVisualStudio2005enabledsupportfor.NETFrameworkv3 features,includingWindowsWorkflowFoundation,WindowsCommunicationFoundation, andWindowsPresentationFoundation.ThisversionofVisualStudioalsointroduced numerousteameditionswithtaskspecificfunctionalityforapplicationarchitects, developers,testers,andsoforth. VisualStudio2008isthelatestversionasofthiswritingandcontainsnumerousupgrades. AnewWindowsPresentationFrameworkdesignerisincluded,alongwithanew HTML/CSSeditorforWebapplications.J#hasbeendroppedfromthebundle,andthe defaultFrameworktargetversionisv3.5.Thisisthefirstversiontotrulysupporttargeting earlierFrameworkversions,including2.0,3.0,3.5,theSilverlightCoreCLR,ortheCompare Framework.Newcodeanalysistools,includingthenewCodeMetricstool,areincludedin somepremiumeditions,andtheintegrateddebuggerintroducedsupportforeasier debuggingofmultithreadedapplications.

Chapter 1 Note Asofthiswriting,VisualStudio2010isunderdevelopment.

VisualStudioDevelopmentMethodsandTechniques
Foranexperienceddeveloper,VisualStudioisastraightforwardIDE.Anentiresoftware applicationcanbedevelopedinVisualStudio,whetheritsaWindowsGUIapplication,a Webapplication,aWebservice,orwhatever;theIDEcontainsallthenecessaryvisual designersurfaces,codeeditorsupport,integratedhelp,andotherfeaturesneededto produceacompleteapplication. TheIDEalsoofferssetupanddeploymentwizardstohelpbuildWindowsapplication installers,deployWebsitestoaWebserver,andsoforth.AnembeddedWebserverallows developerstoperformimmediatetestingofWebapplicationswithoutneedingtodeploya separateWebserver,whichmakesunittestingthatmucheasierandthatmuchmore accessible. Perhapsitshouldgowithoutsaying,butbeawarethatVisualStudiosupportsonly.NET Frameworkdevelopment.ItdoesnotexplicitlysupportolderMicrosoftdevelopment languagessuchaspreFrameworkVisualBasicnordoesitexplicitlysupportlanguages suchasPHP.VisualStudioisextensible,soitsnotunthinkableforittobeextendedto supporttheselanguages,butgenerallyspeaking,VisualStudiousersareinterestedin developingFrameworkbasedapplications. Note Actually,VisualStudiodoessupportdevelopmentinoneunmanaged language:VisualC++.Thatlanguagecontinuestoenjoywidespreadsupport anduse. VisualStudioincludesbuiltinsupportforVisualSourceSafeandMicrosoftsTeam FoundationServersourcecontrolcapabilitiesbutdoesnotnativelysupportotherversion repositoriessuchasSubVersion,ClearCase,orCVS. Note Manyoftheseversioningsystemshavetheirownclientsthatactasplugins totheVisualStudioIDE. TheIDEprovidesbasicrefactoringandcodebeautifiercapabilitiesandprovidesbasic supportforcomparingdifferentversionsofafile.Thesefeaturesallhelpdeveloperscreate codethatconformstointernalstandardsaswellasindustrybestpracticesbothofwhich areimportant,asweshallseelater,tobuildingqualitycode.

Chapter 1

VisualStudioSolutions,ProjectsandProcedures
VisualStudiosbasicunitofworkisaproject,whichmoreorlessrepresentsasingle application.However,VisualStudiorecognizesthatmanylargescalesoftwaresolutions actuallyinvolvemultiplediscreteprojects.Therefore,adevelopermayhaveanentire VisualStudiosolutionopenintheIDEatonce;thissolutioncanconsistofprojectsforback endcode,Webservices,WindowsGUIapps,middletiercomponents,andsoforth,allowing anentireapplicationtobetestedwithintheconfinesoftheIDE. Thiscapabilitycanofferagreatdealofpowerandflexibilityfordevelopersbutalso requirescoordinationinorderforittoworkwell.Forexample,adevelopermaybe workingonaparticularmiddletiercomponentandmaycheckouttheassociatedfilesfrom versioncontrolinordertoworkonthem.Anotherdevelopermaybeworkingonaclient applicationandmighthaveareadonlycopyofthefirstdevelopersmiddletiercomponent code.Thissetupallowsbothdeveloperstoworkindependently,buttheseconddeveloper willalwaysbeworkingonanoutofdatecopyofthemiddletiercode.Thatmaybefinefor basicunittesting,butatsomepoint,allthelatestcodeneedstocometogetherinasingle place,suchasafulltestenvironmentwheredailybuildsorotheragreeduponunitsof workaredeployedformoreformalintegrationtesting.VisualStudioitselfdoesntprovide toolsspecificallyformanagingtheinherentdisconnectbetweendevelopersworkingasa team,althoughfrankly,noIDEreallydoesorcould.Thischallengeisamanagementissue andprovidesagoodexampleofwhyeffectivemanagementskillsandprocessesareneeded incomplexdevelopmentprojects.

IssueswithVisualStudioDevelopmentandNativeToolsets
IfVisualStudiohasaweakness,orweaknesses,itrelatestocodetesting.Althoughthe VisualStudioTeamTesteditionofferstestspecificfunctionality,noeditionofVisualStudio canbeconsideredafullfledgedtoolforapplicationtesting.Itlacksstrongsupportfortest assetmanagement,lacksthesecurityandauditingcontrolsnecessaryforstrongtestasset management,andlacksmuchofthehigherendautomationandtestmanagement capabilitiesfoundinthirdpartytools. Note Testassetsreferstoavarietyofresources,includingsampledata,whichis usedtotestanapplicationsbehaviornotonlytoproperinputbutalsoits handlingofimproperinput.Amajorrootcauseofpoorapplicationqualityis poortestdata:testdatathatisnotrealworlddoesnotleadtorealworld qualitytesting.Thatsaid,realworldtestdatamaycomewithsignificant baggageintermsofsensitivity,security,andprivacy,soatestasset managementtoolmustbeabletoproperlysecureandauditaccesstotest data.Iftestdatawill,forexample,includerealworldcustomerdata,that datamustbetreatedwithsensitivityforitsprivacyandinsome jurisdictions,alluseofthattestdatamustbeaudited.VisualStudiodoesnot providethislevelofmanagementcapabilityfortestassets.

10

Chapter 1 AnotherconcernwithVisualStudiodevelopment,withregardstocodequality,involves managementreporting.EvenwhenalldevelopersareusingtheTeameditionsofVisual Studio,therearerelativelyimmaturebuiltinmeansforamanagertoreportondeveloper productivity,reviewdeveloperunittestingresults,reviewformalresultsfromQAtesters, andsoforth.Giventherolemanagementmustplayinproperlycoordinatingdevelopment andtestingandinensuringthedeliveryofaqualityapplication,VisualStudioslackof managementtoolscanbeconsideredsignificant. Thatsaid,weshouldrecognizethatMicrosoftwantsVisualStudiotobeanIDE,notabeall, endallsoftwaredevelopmentsystem.MicrosoftneversetouttomakeVisualStudioatool formanagersnordiditsetouttobuildenterpriseclasstestassetmanagement.Microsoft reliesonarichecosystemofthirdpartyIndependentSoftwareVendors(ISVs)toprovide thesemorebusinessspecificcapabilities,andmanyISVsdosobyintegratingtheirtoolsets directlyintoVisualStudioitself.AnylackinginVisualStudioshouldntbeconstruedasa failureonMicrosoftspartbutratherasrecognitionthatsoftwaredevelopmentis complicatedandoftenrequirestoolsthataremorespecifictoagivenlineofbusinessor developmentmodel.

UnderstandingandAssessingCodeQuality
Isitpossibletolookatcodeandassessitsqualitywithoutevenrunningtheapplication? Certainlywecanassessanaspectofthecodesqualitystatically,justaswecanassessother aspectsbyrunningtheapplication.Itsimportanttounderstandthat,ultimately,code qualityisthecombinationofthesethings.

Yardsticks:Errors,Completeness,Security,andPerformance
Howdoyou,andyourorganization,measurecodequality?Businesspeopletendtofocuson whetheranapplicationdoeswhattheyneedinthewaytheyneeditdone.Callthat completeness.Businesspeoplealsofocusoftenaboveallelseontheirperceptionofthe applicationsperformance.Aretheytellingcustomers,Sorry,thecomputersareslow today?Ifso,theylikelyperceivetheapplicationasoneofpoorquality.Toooften,infact, developersarentarmedwithasimpletoolthatwouldallowthemtomeetthosequality expectations:alistofactualexpectations!Inotherwords,ifyoudontknowwhatfeatures andperformanceareexpected,youprobablywontdeliverthem.Thatswherewellwritten requirementscanhelpdrivebetterquality,simplybylettingyouknowwhatsexpectedof theapplication. Note Remember:Manythingscancontributetoapoorqualityapplication.Most peoplewill,however,alwaysattributepoorapplicationqualitytopoorcode quality.Ensuringthatthecodeisofhighqualityallowsyou,asadeveloper,to defendyourworkmoreeasily.

11

Chapter 1 Mostanyonewillagreethaterrorsareasignofpoorquality.Obviously,someerrorssuch asamissingfileoranunavailablenetworkconnectionareoutsideyourimmediate control,buthandlingthoseerrorsituationsgracefullycanatleastprovideanimproved perceptionofquality.Gracefulfailurecanalsohelptroubleshooterssuchassystems administratorsorhelpdeskstaffsolveproblemsfaster.Ifyourapplicationcanbeclearon whattheexternalproblemis,troubleshooterscanfocusonthatproblemandnotonyour application.Ofcourse,youneedtomakesurethatthecodepathsleadingtogracefulfailure aredeterministic:displayinganetworkerrorwheninfactthenetworkisfineisasure waytohaveyourapplicationthoughtofaslowquality.Andnoonelikesseeingan Unexpectederrormessagepopupontheirscreen. Securityissomethingmanydevelopersdontthinkofastheyrewritingcode,and unfortunately,itssomethingthatoftenmaynotbeaproblemforsometimeafteran applicationhasbeenreleasedandisinuse.Buteventually,ifsecurityisntcodedinfrom thestart,itwillbeaproblem,andtherearefewsymptomsofpoorqualitythatcostmoreto dealwith.Securityisntfuntocode,andinmostcasesitwindsupmakingapplications morecomplicatedandcomplexthantheywouldbeotherwise,butintodaysworld,a securelycodedapplicationissimplyarequirement. Alloftheseyardsticksarevaluableindicatorsofqualitybecausetheyfocusonenduser perceptions,whicharecriticallyimportantinmeasuringanapplicationsoverallsuccessor failure.However,alltheseyardsticksareverysubjectiveandcanbeverydifficultto measure.Forthatreason,itisinadditiontotheseyardsticksbeneficialtohavemore measureablemetricsagainstwhichtojudgethequalityofyourcode.

CommonlyUsedCodeMetrics
Tosaythattherearenumerousformalmetricsforcodequalityissomethingofan understatement.Massivequantitiesofliteraturehavebeenpublishedonthetopic.One commontheme,however,isthatmeasuringbugsisnotameasureofqualityitsa measureofnonquality,tocoinaphrase.Measuringerrordensityperthousandlinesof codeoverthecourseofayeardoesnttellyouwhetheryourcodeisgood;itonlytellsyouif yourcodeisbad.Notthattrackingerrorsisntessential;theyrejustnotthebeall,endall ofmeasuringcodequality. In1993,theInstituteofElectricalandElectronicsEngineers(IEEE)publishedasoftware qualitymetricsmethodologythatwasintendedasasystematicapproachforestablishing qualityrequirements,validatingqualitymetrics,andsoforth.Theresthatword requirementsagain.Figure1.4showstheIEEEsbasicmethodology.

Figure1.4:IEEEsoftwarequalitymetricsmethodology. 12

Chapter 1 Withoutestablishingyourrequirements,youhavenothingagainstwhichtomeasure quality!Althoughvarioussoftwaredevelopmentmethodologiesprovidemeansfor measuringquality,allbeginwithwellwrittenrequirements,whichmustdefinewhat qualitymeansforthatapplication.SoftwareMeasurement:AVisualizationToolkitfor ProjectControlandProcessMeasurement,bySimmons,Ellis,Fujihara,andKuo,was publishedin1997andinmanywaysisthebesttreatmentofcurrentsoftwaremetrics.Its adensetome,butitswortharead,asitalsoexploreshistoricallyverifiedformulasthatdo thingslikepredictthenumberofdefectsperthousandlinesofcodebasedonprojectsize (middlesizedprojectstendtohavetheleastbugs,forexample).Simmons,et.Al,proposea basicmetricsetthatencompassesreliability,verification,andusability,witheachactingas thelegofatriangle: Usabilityisaproductsfitnessforitsintendedpurpose. Verificationistheabilitytodeterminewhetheraproductisusableandreliable. Reliabilityisusuallydefinedasbugpotential,bugfixefficiency,andbugsthatstill existinfinishedcode.

Morerecently,thefunctionpointhasbeenproposedasaqualitymetricbecauseitdoesnt relyonsimplelinesofcodecounts,whichrarelyprovidesatisfactoryqualitymetrics. Instead,afunctionpointrepresentsinterfaceswithintheapplicationbecauseinterfacesare mostoftenwhereerrorsoccur.AtypicalfunctionpointdevelopedbyIBMlookslikethis: Multiply4timesthenumberofexternalinputs Multiply5timesthenumberofexternaloutputs Multiply10timesthenumberoflogicalinternalfiles Multiply7timesthenumberofexternalinterfacefiles Multiple4timesthenumberofonlineinquiriessupported

Thesearecalledaverageweightingfactors,orWij.Xijisthenumberofeachcomponenttype intheapplication.FeedallthatinfoafunctionliketheoneshowninFigure1.5.

Figure1.5:Functionpointmetricformula. Thenyouuseascaleofzeroto5toratethepotentialimpactof14generalsystem characteristics,with5representingaverylikelyimpactontheapplicationoverall,and0 representingalesserimpact.

13

Chapter 1 Thesystemcharacteristicsare: Datacommunications Distributedfunctions Performance Heavilyusedconfiguration Transactionrate Onlinedataentry Enduserefficiency Onlineupdate Complexprocessing Reusability Installationease Operationalease Multiplesites Facilitationofchange

AddyourscoresandcallthesumCi,andusetheformulainFigure1.6tofindavalue adjustmentfactor(VAF).

Figure1.6:Functionpointmetricformula. ThencomeupwithyourfinalfunctionpointvaluebyusingtheformulaFP=FCVAF.Your functionpointvalueisascoreindicatingthepotentialqualityofthesoftware(amongst otherthings).Itsnotmeasuringbugsbutrather(inpart)thepotentialforreallybadbugs. Note Ifyoucantgetenoughofthemath,checkout http://www.informit.com/articles/article.aspx?p=30306,whichcontainsan excellentdiscussionofcurrentmetricstheory. Nokidding.Thisiswhykidsinschoolaretoldthatsoftwaredevelopmentrequiresan affinityformath.Itsalsowhyautomatedtoolsexisttohelpassesssoftwarequality.

14

Chapter 1

AutomatingCodeQualityAssessmentandUsingCodeQualityAssessmentstoDrive Development
Withcodequalityassessmentsinvolvingsomuchmath,counting,andotherfairlytedious tasks,itsnotsurprisingthattoolsexisttohelpautomatetheprocess.Mostcommercially availabletoolsoffermetricsbasedonmanypopularindustrystandardsandmethodologies. Assessmenttoolsoftenproduceeverythingfromsimplenumericscorestocomplex reports,includingvisualizationssuchasmatrixplots,tablelenses,andsoforth. Automatedassessmenttoolscanbequitecomplex.Inadditiontogatheringbasic informationsuchasthenumberoflinesofcodeandinterfacesbetweencodemodules,they mayanalyzeUIcode,databasecode,andsoforth,whichmustactuallyparseyour programminglanguageandmakeassessmentdecisions.Abenefitoftheseassessmentsis thatyoucandothemfrequently,asyourcodegrows,andyoucanusethemtoidentify highimpactareaswithahighdefectpotential.Identifyingtheseareasofyourcodequickly helpsyouputmorefocusonthemtohelppreventbugsduringdevelopmentandduringall phasesoftesting.

UltimateQuality:DoesItMeettheRequirements?
Theresnobettermeasurementofanapplicationsqualitythantheanswertoonesimple question:Doestheapplicationmeetitsrequirements?Andthefollowupquestions:Doesit performasrequired?Offerthefunctionalityrequired?Meettherequiredsecurity standards?Respondtoerrorsasrequired?Withoutclearlyarticulatedrequirements,you cannotjudgeanapplicationsquality. Iliveinaniceenoughhouse.Itsonestory,hasinsulatedwindows,hasgreatinsulationin theroof,andisnttoodraftyinthewintertime.Isitaqualityhouse?Basedonmy requirementsforenergyefficiency,itdefinitelyis.Myparents,however,prefertwostory houses,likewindowsthatslideupratherthansidewaystoopen(theyreeasiertoclean, Momsays),andwantagaragethatsabitwiderthanmine.Sobytheirrequirementsfor formandfunction,myhouseisntofveryhighquality.Withoutanyofourrequirementsin mind,itsimpossibletomakeaqualitystatementaboutthehouse.Evenahomeinspector hasrequirements:Isituptocode?Isthereanyrotordecay?Isanythingbrokenoroutof kilter?Everyonehasdifferentmeasurementsforquality. Thatswhywrittenrequirementsaresoimportantforprogrammers.Withoutthem,youll neverknowwhetherwhatyoureproducingisquality.Maybeyouvefinetunedeverycode totheminimumnumberofstatements,optimizeddatabaseaccess,andspenthours agonizingovertheGUIcolorscheme.Afterallthateffort,itsapoorqualityapplicationifit doesntproducetheprintedoutputusersreallyneed.

15

Chapter 1 Thegreatpartaboutwelldocumentedrequirementsisthattheyarenotsubjective. Instead,theyserveasameasurablechecklist.Eitheryourapplicationdoeseverythingon thechecklistoritdoesnot.Themorechecks,thebettertheapplicationquality.Thebest partaboutawellwrittensetofrequirementsisthatyou,asadeveloper,needtoworrya lotlessaboutthethingsnotintherequirements!Therequirementsdontaddressprinted output?Well,dontspendtoomuchtimeonprinting,then,becauseitsobviouslynot importanttoanyone.Instead,youcanfocusonwhatisintherequirements,doagoodjob implementingthem,andhaveafinalapplicationthateveryonecan(orshould)agreeisof highquality. Thereare,ofcourse,underthehoodaspectsofcodingthatdontmakeitinto requirementsdocuments.Goodcodingpracticesleadtoeasierlongtermcode maintenance,betterapplicationstability,betterapplicationsecurity,andotherfactorsthat oftenarentwritteninasetofrequirementsbutthatarestillperceivedassignsofpoor quality,andsoarethingsyoustillneedtofocuson.Thatswhatmuchofthisguidewill focuson,too.

TopCodeQualitySnafus
TheSANSInstituteandacollectionofcomputerexpertsrecentlypublishedalistoftheir top25codeproblemsallofwhich,ultimately,relatetocodequality.Althoughmanyof theseproblemsrelatetosecurity,othersalsorelatetogeneralstabilityandotherissues. Itsusefultoreviewthislistinthisfirstchapter,asmanyoftheseissuesareoneswellfocus onspecificallyasexamplesthroughoutlaterchapters. Improperinputvalidation.Simplyput,youreaskingfortroubleifyouassumeany inputeitherfromusers,datastores,orothersystemsconformtoyour expectations(forexample,youaskfortheirage,expectinganumber,andtheuser typesoldenoughtoknowbetter). Improperencodingorescapingofoutput.Thisisattherootofmostinjection basedsoftwareattacksandisofparticularconcernbecauseasOSsbecomemore hardenedapplicationsarefastbecomingafavoritetarget. SQLInjection.Hackerswilluseaninputstatementtoexecutetheirowncode againstyourdatabase.Itisyourjobtopreventthemfromdoingso. Crosssitescripting.IntheworldofWebdevelopment,thisisoneofthemost popularwaystoattackcode.Qualitycodecanstopitcold. OScommandinjection.Unsurprisingly,injectingcommandsintotheOSisa popularattack.EvenGooglesfirstreleaseofitsAndroidmobilephoneOShadthis problem. Cleartexttransmissionofsensitiveinformation.Whenyouaskauserfor credentialsandtheusertrustsyou,youneedtoprotectthatinformation.Passingit throughthenetwork(orworseyet,theInternet)inplainsightwhereanyonewitha sniffercanreaditisjustirresponsible.Qualitycodebuildssecurityintoeveryaspect ofanapplicationandisalwayscarefulwithhowithandlesdata. 16

Chapter 1 Crosssiterequestforgery.Thiscombinationofsocialengineeringandscripting attackcanleaveunsuspectingWebapplicationsvulnerable. Errormessageinformationleak.Clearerrormessagesareobviouslydesirablebut toomuchinformationisntgoodespeciallyifsensitiveinformationisdisplayed (forexample,errormessagesthatprovidethenameorcredentialsoftheservice account). Memorybufferoverflows.Oneofthemostcommonerrorswithnativecode programsiswhenamemoryvariableisnotcontrolled.Ahackerentersaninputthat overwritestheexecutableportionoftheprogram.Thus,thehackerscodeexecutes. Simplyput,sloppyprogramming;andeventodaysadvancedprogramming frameworksdontautomaticallyprovide100%protection. Externalcontrolofstatedata.Storingstatedatainadatabaseorelsewhereisfine butdontassumethatstoreistamperproofunlessittrulyis,andmakesureyour applicationisvalidatingthatdatawhenitsreadbackin. Externalcontroloffilenamesandpaths.Aswithmanyinjectionattacks,using userinputtoconstructfilenamesandpathsleavesopportunitiestoattackandcrash anapplication. Externalcontrolofsearchpath.IfyourapplicationdependsonunderlyingOS searchpaths,anattackercangaincontrolofthatandmisdirectapplicationresource requests.Neverassumeanapplicationisrunninginasafesandbox. Codeinjection.Dynamiccodeofferscoolcapabilitiesbutalsoprovidesan opportunityforseriousvulnerabilities. Downloadedcode.ThereisalotofinterestingcodepostedontheInternet.Dont dependonanythinggeneratedoutsideyourapplicationsowncode.Unlessproper codingsecuritymeasuresareemployed,downloadedcodecanbeeasilyhijacked. Improperresourceshutdownorrelease.DontleaveittotheOStorelease resourcesautomaticallyexplicitlycleanupafteryourself. Improperinitialization.Dontassumeanythingaboutyourapplicationsstarting state;properlyinitializeeverythingyouplantouse. Incorrectcalculation.Usinguserinputincalculationsisanopportunityfor unexpectedbufferoverflowsandotherproblems. Improperaccesscontrol.Youneedtocontinuallychecktomakesureusersare allowedtodowhattheyretryingtodo;dontputallyoursecurityintoonefront doorandgiveattackersanopportunitytobypassthatthroughunexpectedcode paths. Usingbadcryptography.40bitencryptionisso1980s.Usingoutdatedorbroken algorithmsisasbad(orworse)thanusingnoneatall.Dontdevelopyourown encryptionschemes,either;usestrong,industrystandardlibraries.

17

Chapter 1 Hardcodedpasswords.Badidea.Allsoftwarecanbedecompiledandyour passwordcanberevealed.Yetthishasbeenacommonpoorcodingpracticefor morethanfourdecades.Andmaybeitisnotagoodideatokeeppasswordinan unencryptedXMLconfigurationfileonyouserver? Insecurepermissionassignmentforcriticalresources.Sensitivedatashouldbe securedatmanylayers:withinyourapplication,inmiddletiercomponents,atthe database,andsoforth. Useofnonrandomrandomvalues.Securityfeaturesoftenrelyonrandomness, butcomputersarentalwaysgoodatgeneratingrandomnumbers.Areyoumaking yoursoftwaressecurityisnttoopredictable? Executionwithunnecessaryprivileges.Inallprobability,yourapplicationdoesnt needtoberunbyasystemsadministrator,somakesureitwillrunwithoutthat unnecessaryprivilege.Ifyouthinkyoumusthavethatkindofpermission,youmight bedoingsomethingwrong. Clientsideenforcementofserversidesecurity.Ifaserverenforcessecurity measures,donttrytoduplicatethatinyourclientapplication;instead,respondto securityerrorsasappropriate.Yourclientapplicationcanbedecompiledandused tothwartthesecurityontheserveritself.

Althoughsecurityheavy,theproblemshighlightedinthislistalsomanifestasstability problems,createlongtermmaintenanceproblems,anddisplayotheraspectsofpoor quality.Wellreturntosomeoftheseexamplesagainaswelookatwaystoimprovethe qualityofthecodewerelease.

WhattoExpectinthisDefinitiveGuide
Sowhatscomingnext?InChapter2,welldiveintocodingstandardsandbestpractices. Youdbeshocked,andpossiblyhorrified,atthenumberofdevelopersouttherewhoare stillfollowingcodingstandardsoriginallydevelopedforVisualBasicv1.Thus,wellbe goingbacktobasicsandreallygettingintomoderncodingpractices.Wellnotonlycover whatyoushoulddobutalsowhatyoushouldntandmostimportantly,why.Welllookat howsomeofVisualStudiostimesavingtoolscan,ifyourenotcareful,actuallycreatea negativeimpactoncodequality,sowellalsolookatwaystousethosefeaturessafely. Wellwrapupbylookingatdifferentdevelopmentmethodologies,comparingand contrastingthemsothatyoucanselectone,orahybridofthem,thatworksbestforyou. Nodeveloperworksalone,soChapter3willfocusoncodeanalysisandpeerreviews,a criticaltoolinimprovingapplicationquality.Wellexaminethedifferencesbetween manualandautomatedcodereviews,andlookatasetofcodereviewrules.Codeanalysisis reallyaprettycomplicatedtopic,sowellspendlotsoftimelookingatconsiderationssuch asmaintainabilityindices,depthofinheritanceconcerns,andsoforth.

18

Chapter 1 InChapter4,wellbeginlookingatwaystoaddresscodingerrors.Hey,theyreinevitable, sowemightaswelllearntodealwiththem,right?Wellcreateasortoftaxonomyfor differenttypesoferrors,andlookatspecificwaystoprevent,mitigate,andaddresseach type.Obviously,gettingridoferrorsisabigstepinimprovingcodequality,sowellalso lookattoolsyoucanusetoeliminatebugsmoreeasily.IllalsopresentmyUnifiedTheory ofBugs,whichwillhelpanydeveloperwhostruggleswithdebuggingreallyunderstand howtoproceed.Evenifyoureanexperienceddeveloper,Ithinkyoullfindsomethings herethatareusefulandmostespeciallythingsthatyoucansharewithlessexperienced membersofyourteam. Chapter5iswherewelladdressperformanceandsecurityproblems.Theyrenotbugsper se,buttheyredefinitelythingsthatleadtoaloweredperceptionofqualityinafinished application.Welllookatdifferentwaysofdetectingcodingproblems,explorewhere securityproblemscomefrom,andreallylookatthethingsyou,asadeveloper,candoto insistonbetterperformanceandsecurityfromyouapplications.Youmightbesurprisedat whereIeventuallylaytheblameforbadperformanceandsecurity,butIthinkyoullbe happywiththeresult. WelldiveintotestinginChapter6,andstartlookingatbothmanualtestingandautomated testing.Wellexploretheimportanceofsolidusecasesandtestingassets,andlookathow badcasesandassetscanleadyoutothinkyoureproducingaqualityappandleadto unpleasantsurpriseswhenyoufindoutdifferentlylaterondowntheline.Welllookat differenttypesoftesting,suchasunitandsystemtesting,andmakesureweagreeonthe valueofeachtype. Finally,Chapter7iswherewelllookatautomateddebugging,codeanalysis,andtesting. Theresreallynopointinusingautomatedtoolsuntilyouvemastereddoingthings properlywithoutautomation;Imabigbelieverthatalthoughautomationcanmakethings lessboringandmoreconsistent,itcantactuallyaddmuchinthewayofqualityonitsown. Yourqualitywillonlybeasgoodaswhatyouautomate,whichiswhyweregettingto automationonlyafterweveexploredallthoseotherwaystoimprovecodequality. Sothatsourbattleplan.Ihopeyoullstickwithmethrougheachchapter,andIhopeyoull findplentyofinformationtohelpyouproducehigherqualitycode.

DownloadAdditionaleBooksfromRealtimeNexus!
RealtimeNexusTheDigitalLibraryprovidesworldclassexpertresourcesthatIT professionalsdependontolearnaboutthenewesttechnologies.IfyoufoundthiseBookto beinformative,weencourageyoutodownloadmoreofourindustryleadingtechnology eBooksandvideoguidesatRealtimeNexus.Pleasevisit http://nexus.realtimepublishers.com.

19

También podría gustarte