how to be a programmer en

100

Upload: chuck-norris

Post on 08-Jul-2016

30 views

Category:

Documents


1 download

DESCRIPTION

Programming instructions visit https://braydie.gitbooks.io/how-to-be-a-programmer/content/en/index.html for more informationDisclaimer:The content of this document is not mine. Credits goes to Robert L. Read. License http://creativecommons.org/licenses/by-sa/4.0/ No Changes were made.

TRANSCRIPT

Page 1: How to Be a Programmer En
Page 2: How to Be a Programmer En

0

1

1.1

1.1.1

1.1.2

1.1.3

1.1.4

1.1.5

1.1.6

1.1.7

1.1.8

1.1.9

1.1.10

1.1.11

1.1.12

1.2

1.2.1

1.2.2

1.2.3

1.2.4

1.2.5

1.2.6

1.2.7

1.2.8

1.2.9

1.2.10

1.2.11

2

2.1

2.1.1

TableofContentsIntroduction

Beginner

PersonalSkills

LearntoDebug

HowtoDebugbySplittingtheProblemSpace

HowtoRemoveanError

HowtoDebugUsingaLog

HowtoUnderstandPerformanceProblems

HowtoFixPerformanceProblems

HowtoOptimizeLoops

HowtoDealwithI/OExpense

HowtoManageMemory

HowtoDealwithIntermittentBugs

HowtoLearnDesignSkills

HowtoConductExperiments

TeamSkills

WhyEstimationisImportant

HowtoEstimateProgrammingTime

HowtoFindOutInformation

HowtoUtilizePeopleasInformationSources

HowtoDocumentWisely

HowtoWorkwithPoorCode

HowtoUseSourceCodeControl

HowtoUnitTest

TakeBreakswhenStumped

HowtoRecognizeWhentoGoHome

HowtoDealwithDifficultPeople

Intermediate

PersonalSkills

HowtoStayMotivated

HowtobeaProgrammer

2

Page 3: How to Be a Programmer En

2.1.2

2.1.3

2.1.4

2.1.5

2.1.6

2.1.7

2.1.8

2.1.9

2.1.10

2.1.11

2.2

2.2.1

2.2.2

2.2.3

2.2.4

2.2.5

2.3

2.3.1

2.3.2

2.3.3

2.3.4

2.3.5

2.3.6

2.3.7

2.3.8

3

3.1

3.1.1

3.1.2

3.1.3

3.2

3.2.1

3.2.2

3.2.3

HowtobeWidelyTrusted

HowtoTradeoffTimevs.Space

HowtoStressTest

HowtoBalanceBrevityandAbstraction

HowtoLearnNewSkills

LearntoType

HowtoDoIntegrationTesting

CommunicationLanguages

HeavyTools

Howtoanalyzedata

TeamSkills

HowtoManageDevelopmentTime

HowtoManageThird-PartySoftwareRisks

HowtoManageConsultants

HowtoCommunicatetheRightAmount

HowtoDisagreeHonestlyandGetAwaywithIt

Judgment

HowtoTradeoffQualityAgainstDevelopmentTime

HowtoManageSoftwareSystemDependence

HowtoDecideifSoftwareisTooImmature

HowtoMakeaBuyvs.BuildDecision

HowtoGrowProfessionally

HowtoEvaluateInterviewees

HowtoKnowWhentoApplyFancyComputerScience

HowtoTalktoNon-Engineers

Advanced

TechnologicalJudgment

HowtoTelltheHardFromtheImpossible

HowtoUtilizeEmbeddedLanguages

ChoosingLanguages

CompromisingWisely

HowtoFightSchedulePressure

HowtoUnderstandtheUser

HowtoGetaPromotion

HowtobeaProgrammer

3

Page 4: How to Be a Programmer En

3.3

3.3.1

3.3.2

3.3.3

3.3.4

3.3.5

3.3.6

3.3.7

3.3.8

3.3.9

3.3.10

3.3.11

4

5

6

ServingYourTeam

HowtoDevelopTalent

HowtoChooseWhattoWorkOn

HowtoGettheMostFromYourTeam-mates

HowtoDivideProblemsUp

HowtoHandleBoringTasks

HowtoGatherSupportforaProject

HowtoGrowaSystem

HowtoCommunicateWell

HowtoTellPeopleThingsTheyDon'tWanttoHear

HowtoDealwithManagerialMyths

HowtoDealwithOrganizationalChaos

AppendixA*Bibliography/Websiteography

AppendixB*History(AsofJanuary2016)

AppendixC*Contributions(AsofJanuary2016)

Glossary

HowtobeaProgrammer

4

Page 5: How to Be a Programmer En

HowtobeaProgrammer:CommunityVersionRobertL.ReadwithCommunity

Copyright2002,2003,2016RobertL.Read

LicensedunderCreativeCommonsAttribution-ShareAlike4.0InternationalLicense.

IntroductionTobeagoodprogrammerisdifficultandnoble.Thehardestpartofmakingrealacollectivevisionofasoftwareprojectisdealingwithone'scoworkersandcustomers.Writingcomputerprogramsisimportantandtakesgreatintelligenceandskill.Butitisreallychild'splaycomparedtoeverythingelsethatagoodprogrammermustdotomakeasoftwaresystemthatsucceedsforboththecustomerandmyriadcolleaguesforwhomsheispartiallyresponsible.InthisessayIattempttosummarizeasconciselyaspossiblethosethingsthatIwishsomeonehadexplainedtomewhenIwastwenty-one.

Thisisverysubjectiveand,therefore,thisessayisdoomedtobepersonalandsomewhatopinionated.Iconfinemyselftoproblemsthataprogrammerisverylikelytohavetofaceinherwork.ManyoftheseproblemsandtheirsolutionsaresogeneraltothehumanconditionthatIwillprobablyseempreachy.Ihopeinspiteofthisthatthisessaywillbeuseful.

Computerprogrammingistaughtincourses.Theexcellentbooks:ThePragmaticProgrammer[Prag99],CodeComplete[CodeC93],RapidDevelopment[RDev96],andExtremeProgrammingExplained[XP99]allteachcomputerprogrammingandthelargerissuesofbeingagoodprogrammer.TheessaysofPaulGraham[PGSite]andEricRaymond[Hacker]shouldcertainlybereadbeforeoralongwiththisarticle.ThisessaydiffersfromthoseexcellentworksbyemphasizingsocialproblemsandcomprehensivelysummarizingtheentiresetofnecessaryskillsasIseethem.

Inthisessaythetermbossisusedtorefertowhomevergivesyouprojectstodo.Iusethewordsbusiness,company,andtribe,synonymouslyexceptthatbusinessconnotesmoneymaking,companyconnotesthemodernworkplaceandtribeisgenerallythepeopleyoushareloyaltywith.

Welcometothetribe.

HowtobeaProgrammer

5Introduction

Page 6: How to Be a Programmer En

Contents1. Beginner

PersonalSkillsLearntoDebugHowtoDebugbySplittingtheProblemSpaceHowtoRemoveanErrorHowtoDebugUsingaLogHowtoUnderstandPerformanceProblemsHowtoFixPerformanceProblemsHowtoOptimizeLoopsHowtoDealwithI/OExpenseHowtoManageMemoryHowtoDealwithIntermittentBugsHowtoLearnDesignSkillsHowtoConductExperiments

TeamSkillsWhyEstimationisImportantHowtoEstimateProgrammingTimeHowtoFindOutInformationHowtoUtilizePeopleasInformationSourcesHowtoDocumentWiselyHowtoWorkwithPoorCodeHowtoUseSourceCodeControlHowtoUnitTestTakeBreakswhenStumpedHowtoRecognizeWhentoGoHomeHowtoDealwithDifficultPeople

2. IntermediatePersonalSkills

HowtoStayMotivatedHowtobeWidelyTrustedHowtoTradeoffTimevs.SpaceHowtoStressTestHowtoBalanceBrevityandAbstractionHowtoLearnNewSkillsLearntoTypeHowtoDoIntegrationTestingCommunicationLanguagesHeavyTools

HowtobeaProgrammer

6Introduction

Page 7: How to Be a Programmer En

HowtoanalyzedataTeamSkills

HowtoManageDevelopmentTimeHowtoManageThird-PartySoftwareRisksHowtoManageConsultantsHowtoCommunicatetheRightAmountHowtoDisagreeHonestlyandGetAwaywithIt

JudgmentHowtoTradeoffQualityAgainstDevelopmentTimeHowtoManageSoftwareSystemDependenceHowtoDecideifSoftwareisTooImmatureHowtoMakeaBuyvs.BuildDecisionHowtoGrowProfessionallyHowtoEvaluateIntervieweesHowtoKnowWhentoApplyFancyComputerScienceHowtoTalktoNon-Engineers

3. AdvancedTechnologicalJudgment

HowtoTelltheHardFromtheImpossibleHowtoUtilizeEmbeddedLanguagesChoosingLanguages

CompromisingWiselyHowtoFightSchedulePressureHowtoUnderstandtheUserHowtoGetaPromotion

ServingYourTeamHowtoDevelopTalentHowtoChooseWhattoWorkOnHowtoGettheMostFromYourTeam-matesHowtoDivideProblemsUpHowtoHandleBoringTasksHowtoGatherSupportforaProjectHowtoGrowaSystemHowtoCommunicateWellHowtoTellPeopleThingsTheyDon'tWanttoHearHowtoDealwithManagerialMythsHowtoDealwithOrganizationalChaos

4. Glossary5. AppendixA-Bibliography/Websiteography6. AppendixB-History(AsofJanuary2016)

HowtobeaProgrammer

7Introduction

Page 8: How to Be a Programmer En

7. AppendixC-Contributions(AsofJanuary2016)

HowToBeAProgrammer:CommunityVersionbyRobertL.ReadwithCommunityislicensedunderaCreativeCommonsAttribution-ShareAlike4.0InternationalLicense.

HowtobeaProgrammer

8Introduction

Page 9: How to Be a Programmer En

1.BeginnerPersonalSkills

LearntoDebugHowtoDebugbySplittingtheProblemSpaceHowtoRemoveanErrorHowtoDebugUsingaLogHowtoUnderstandPerformanceProblemsHowtoFixPerformanceProblemsHowtoOptimizeLoopsHowtoDealwithI/OExpenseHowtoManageMemoryHowtoDealwithIntermittentBugsHowtoLearnDesignSkillsHowtoConductExperiments

TeamSkillsWhyEstimationisImportantHowtoEstimateProgrammingTimeHowtoFindOutInformationHowtoUtilizePeopleasInformationSourcesHowtoDocumentWiselyHowtoWorkwithPoorCodeHowtoUseSourceCodeControlHowtoUnitTestTakeBreakswhenStumpedHowtoRecognizeWhentoGoHomeHowtoDealwithDifficultPeople

HowtobeaProgrammer

9Beginner

Page 10: How to Be a Programmer En

LearntoDebugDebuggingisthecornerstoneofbeingaprogrammer.Thefirstmeaningoftheverb"debug"istoremoveerrors,butthemeaningthatreallymattersistoseeintotheexecutionofaprogrambyexaminingit.Aprogrammerthatcannotdebugeffectivelyisblind.

Idealists,thosewhothinkdesign,analysis,complexitytheory,andthelikearemorefundamentalthandebugging,arenotworkingprogrammers.Theworkingprogrammerdoesnotliveinanidealworld.Evenifyouareperfect,youaresurroundedbyandmustinteractwithcodewrittenbymajorsoftwarecompanies,organizationslikeGNU,andyourcolleagues.Mostofthiscodeisimperfectandimperfectlydocumented.Withouttheabilitytogainvisibilityintotheexecutionofthiscode,theslightestbumpwillthrowyoupermanently.Oftenthisvisibilitycanbegainedonlybyexperimentation:thatis,debugging.

Debuggingisabouttherunningofprograms,notprogramsthemselves.Ifyoubuysomethingfromamajorsoftwarecompany,youusuallydon'tgettoseetheprogram.Buttherewillstillariseplaceswherethecodedoesnotconformtothedocumentation(crashingyourentiremachineisacommonandspectacularexample),orwherethedocumentationismute.Morecommonly,youcreateanerror,examinethecodeyouwrote,andhavenocluehowtheerrorcanbeoccurring.Inevitably,thismeanssomeassumptionyouaremakingisnotquitecorrectorsomeconditionarisesthatyoudidnotanticipate.Sometimes,themagictrickofstaringintothesourcecodeworks.Whenitdoesn't,youmustdebug.

Togetvisibilityintotheexecutionofaprogramyoumustbeabletoexecutethecodeandobservesomethingaboutit.Sometimesthisisvisible,likewhatisbeingdisplayedonascreen,orthedelaybetweentwoevents.Inmanyothercases,itinvolvesthingsthatarenotmeanttobevisible,likethestateofsomevariablesinsidethecode,whichlinesofcodeareactuallybeingexecuted,orwhethercertainassertionsholdacrossacomplicateddatastructure.Thesehiddenthingsmustberevealed.

Thecommonwaysoflookingintothe‘innards’ofanexecutingprogramcanbecategorizedas:

Usingadebuggingtool,Printlining-Makingatemporarymodificationtotheprogram,typicallyaddinglinesthatprintinformationout,andLogging-Creatingapermanentwindowintotheprogramsexecutionintheformofalog.

HowtobeaProgrammer

10Beginner

Page 11: How to Be a Programmer En

Debuggingtoolsarewonderfulwhentheyarestableandavailable,buttheprintliningandloggingareevenmoreimportant.Debuggingtoolsoftenlagbehindlanguagedevelopment,soatanypointintimetheymaynotbeavailable.Inaddition,becausethedebuggingtoolmaysubtlychangethewaytheprogramexecutesitmaynotalwaysbepractical.Finally,therearesomekindsofdebugging,suchascheckinganassertionagainstalargedatastructure,thatrequirewritingcodeandchangingtheexecutionoftheprogram.Itisgoodtoknowhowtousedebuggingtoolswhentheyarestable,butitiscriticaltobeabletoemploytheothertwomethods.

Somebeginnersfeardebuggingwhenitrequiresmodifyingcode.Thisisunderstandable-itisalittlelikeexploratorysurgery.Butyouhavetolearntopokeatthecodeandmakeitjump;youhavetolearntoexperimentonitandunderstandthatnothingthatyoutemporarilydotoitwillmakeitworse.Ifyoufeelthisfear,seekoutamentor-welosealotofgoodprogrammersatthedelicateonsetoftheirlearningtothisfear.

NextHowtoDebugbySplittingtheProblemSpace

HowtobeaProgrammer

11Beginner

Page 12: How to Be a Programmer En

HowtoDebugbySplittingtheProblemSpaceDebuggingisfun,becauseitbeginswithamystery.Youthinkitshoulddosomething,butinsteaditdoessomethingelse.Itisnotalwaysquitesosimple---anyexamplesIcangivewillbecontrivedcomparedtowhatsometimeshappensinpractice.Debuggingrequirescreativityandingenuity.Ifthereisasinglekeytodebuggingitistousethedivideandconquertechniqueonthemystery.

Suppose,forexample,youcreatedaprogramthatshoulddotenthingsinasequence.Whenyourunit,itcrashes.Sinceyoudidn'tprogramittocrash,younowhaveamystery.Whenyoulookattheoutput,youseethatthefirstseventhingsinthesequencewererunsuccessfully.Thelastthreearenotvisiblefromtheoutput,sonowyourmysteryissmaller:‘Itcrashedonthing#8,#9,or#10.’

Canyoudesignanexperimenttoseewhichthingitcrashedon?Sure.Youcanuseadebuggerorwecanaddprintlinestatements(ortheequivalentinwhateverlanguageyouareworkingin)after#8and#9.Whenwerunitagain,ourmysterywillbesmaller,suchas‘Itcrashedonthing#9.’Ifindthatbearinginmindexactlywhatthemysteryisatanypointintimehelpskeeponefocused.Whenseveralpeopleareworkingtogetherunderpressureonaproblemitiseasytoforgetwhatthemostimportantmysteryis.

Thekeytodivideandconquerasadebuggingtechniqueisthesameasitisforalgorithmdesign:aslongasyoudoagoodjobsplittingthemysteryinthemiddle,youwon'thavetosplitittoomanytimes,andyouwillbedebuggingquickly.Butwhatisthemiddleofamystery?Thereiswheretruecreativityandexperiencecomesin.

Toatruebeginner,thespaceofallpossibleerrorslookslikeeverylineinthesourcecode.Youdon'thavethevisionyouwilllaterdeveloptoseetheotherdimensionsoftheprogram,suchasthespaceofexecutedlines,thedatastructure,thememorymanagement,theinteractionwithforeigncode,thecodethatisrisky,andthecodethatissimple.Fortheexperiencedprogrammer,theseotherdimensionsformanimperfectbutveryusefulmentalmodelofallthethingsthatcangowrong.Havingthatmentalmodeliswhathelpsonefindthemiddleofthemysteryeffectively.

Onceyouhaveevenlysubdividedthespaceofallthatcangowrong,youmusttrytodecideinwhichspacetheerrorlies.Inthesimplecasewherethemysteryis:‘Whichsingleunknownlinemakesmyprogramcrash?’,youcanaskyourself:‘IstheunknownlineexecutedbeforeorafterthislinethatIjudgetobeexecutedinthemiddleoftherunningprogram?’Usuallyyouwillnotbesoluckyastoknowthattheerrorexistsinasingleline,or

HowtobeaProgrammer

12Beginner

Page 13: How to Be a Programmer En

evenasingleblock.Oftenthemysterywillbemorelike:‘Eitherthereisapointerinthatgraphthatpointstothewrongnode,ormyalgorithmthataddsupthevariablesinthatgraphdoesn'twork.’Inthatcaseyoumayhavetowriteasmallprogramtocheckthatthepointersinthegraphareallcorrectinordertodecidewhichpartofthesubdividedmysterycanbeeliminated.

NextHowtoRemoveanError

HowtobeaProgrammer

13Beginner

Page 14: How to Be a Programmer En

HowtoRemoveanErrorI'veintentionallyseparatedtheactofexaminingaprogram'sexecutionfromtheactoffixinganerror.Butofcourse,debuggingdoesalsomeanremovingthebug.Ideallyyouwillhaveperfectunderstandingofthecodeandwillreachan‘A-Ha!’momentwhereyouperfectlyseetheerrorandhowtofixit.Butsinceyourprogramwilloftenuseinsufficientlydocumentedsystemsintowhichyouhavenovisibility,thisisnotalwayspossible.Inothercasesthecodeissocomplicatedthatyourunderstandingcannotbeperfect.

Infixingabug,youwanttomakethesmallestchangethatfixesthebug.Youmayseeotherthingsthatneedimprovement;butdon'tfixthoseatthesametime.Attempttoemploythescientificmethodofchangingonethingandonlyonethingatatime.Thebestprocessforthisistobeabletoeasilyreproducethebug,thenputyourfixinplace,andthenreruntheprogramandobservethatthebugnolongerexists.Ofcourse,sometimesmorethanonelinemustbechanged,butyoushouldstillconceptuallyapplyasingleatomicchangetofixthebug.

Sometimes,therearereallyseveralbugsthatlooklikeone.Itisuptoyoutodefinethebugsandfixthemoneatatime.Sometimesitisunclearwhattheprogramshoulddoorwhattheoriginalauthorintended.Inthiscase,youmustexerciseyourexperienceandjudgmentandassignyourownmeaningtothecode.Decidewhatitshoulddo,andcommentitorclarifyitinsomewayandthenmakethecodeconformtoyourmeaning.Thisisanintermediateoradvancedskillthatissometimesharderthanwritingtheoriginalfunctioninthefirstplace,buttherealworldisoftenmessy.Youmayhavetofixasystemyoucannotrewrite.

NextHowtoDebugUsingaLog

HowtobeaProgrammer

14Beginner

Page 15: How to Be a Programmer En

HowtoDebugUsingaLogLoggingisthepracticeofwritingasystemsothatitproducesasequenceofinformativerecords,calledalog.Printliningisjustproducingasimple,usuallytemporary,log.Absolutebeginnersmustunderstandanduselogsbecausetheirknowledgeoftheprogrammingislimited;systemarchitectsmustunderstandanduselogsbecauseofthecomplexityofthesystem.Theamountofinformationthatisprovidedbythelogshouldbeconfigurable,ideallywhiletheprogramisrunning.Ingeneral,logsofferthreebasicadvantages:

Logscanprovideusefulinformationaboutbugsthatarehardtoreproduce(suchasthosethatoccurintheproductionenvironmentbutthatcannotbereproducedinthetestenvironment).Logscanprovidestatisticsanddatarelevanttoperformance,suchasthetimepassingbetweenstatements.Whenconfigurable,logsallowgeneralinformationtobecapturedinordertodebugunanticipatedspecificproblemswithouthavingtomodifyand/orredeploythecodejusttodealwiththosespecificproblems.

Theamounttooutputintothelogisalwaysacompromisebetweeninformationandbrevity.Toomuchinformationmakesthelogexpensiveandproducesscrollblindness,makingithardtofindtheinformationyouneed.Toolittleinformationanditmaynotcontainwhatyouneed.Forthisreason,makingwhatisoutputconfigurableisveryuseful.Typically,eachrecordinthelogwillidentifyitspositioninthesourcecode,thethreadthatexecuteditifapplicable,theprecisetimeofexecution,and,commonly,anadditionalusefulpieceofinformation,suchasthevalueofsomevariable,theamountoffreememory,thenumberofdataobjects,etc.Theselogstatementsaresprinkledthroughoutthesourcecodebutareparticularlyatmajorfunctionalitypointsandaroundriskycode.Eachstatementcanbeassignedalevelandwillonlyoutputarecordifthesystemiscurrentlyconfiguredtooutputthatlevel.Youshoulddesignthelogstatementstoaddressproblemsthatyouanticipate.Anticipatetheneedtomeasureperformance.

Ifyouhaveapermanentlog,printliningcannowbedoneintermsofthelogrecords,andsomeofthedebuggingstatementswillprobablybepermanentlyaddedtotheloggingsystem.

NextHowtoUnderstandPerformanceProblems

HowtobeaProgrammer

15Beginner

Page 16: How to Be a Programmer En

HowtoUnderstandPerformanceProblemsLearningtounderstandtheperformanceofarunningsystemisunavoidableforthesamereasonthatlearningdebuggingis.Evenifyouunderstandperfectlypreciselythecostofthecodeyouwrite,yourcodewillmakecallsintoothersoftwaresystemsthatyouhavelittlecontroloverorvisibilityinto.However,inpracticeperformanceproblemsarealittledifferentandalittleeasierthandebuggingingeneral.

Supposethatyouoryourcustomersconsiderasystemorasubsystemtobetooslow.Beforeyoutrytomakeitfaster,youmustbuildamentalmodelofwhyitisslow.Todothisyoucanuseaprofilingtooloragoodlogtofigureoutwherethetimeorotherresourcesarereallybeingspent.Thereisafamousdictumthat90%ofthetimewillbespentin10%ofthecode.Iwouldaddtothattheimportanceofinput/outputexpense(I/O)toperformanceissues.OftenmostofthetimeisspentinI/Oinonewayoranother.FindingtheexpensiveI/Oandtheexpensive10%ofthecodeisagoodfirststeptobuildingyourmentalmodel.

Therearemanydimensionstotheperformanceofacomputersystem,andmanyresourcesconsumed.Thefirstresourcetomeasureiswall-clocktime,thetotaltimethatpassesforthecomputation.Loggingwall-clocktimeisparticularlyvaluablebecauseitcaninformaboutunpredictablecircumstancesthatariseinsituationswhereotherprofilingisimpractical.However,thismaynotalwaysrepresentthewholepicture.Sometimessomethingthattakesalittlelongerbutdoesn'tburnupsomanyprocessorsecondswillbemuchbetterinthecomputingenvironmentyouactuallyhavetodealwith.Similarly,memory,networkbandwidth,databaseorotherserveraccessesmay,intheend,befarmoreexpensivethanprocessorseconds.

Contentionforsharedresourcesthataresynchronizedcancausedeadlockandstarvation.Deadlockistheinabilitytoproceedbecauseofimpropersynchronizationorresourcedemands.Starvationisthefailuretoscheduleacomponentproperly.Ifitcanbeatallanticipated,itisbesttohaveawayofmeasuringthiscontentionfromthestartofyourproject.Evenifthiscontentiondoesnotoccur,itisveryhelpfultobeabletoassertthatwithconfidence.

NextHowtoFixPerformanceProblems

HowtobeaProgrammer

16Beginner

Page 17: How to Be a Programmer En

HowtoFixPerformanceProblemsMostsoftwareprojectscanbemadewithrelativelylittleeffort10to100timesfasterthantheyareatthetimetheyarefirstreleased.Undertime-to-marketpressure,itisbothwiseandeffectivetochooseasolutionthatgetsthejobdonesimplyandquickly,butlessefficientlythansomeothersolution.However,performanceisapartofusability,andoftenitmusteventuallybeconsideredmorecarefully.

Thekeytoimprovingtheperformanceofaverycomplicatedsystemistoanalyseitwellenoughtofindthebottlenecks,orplaceswheremostoftheresourcesareconsumed.Thereisnotmuchsenseinoptimizingafunctionthataccountsforonly1%ofthecomputationtime.Asaruleofthumbyoushouldthinkcarefullybeforedoinganythingunlessyouthinkitisgoingtomakethesystemorasignificantpartofitatleasttwiceasfast.Thereisusuallyawaytodothis.Considerthetestandqualityassuranceeffortthatyourchangewillrequire.Eachchangebringsatestburdenwithit,soitismuchbettertohaveafewbigchanges.

Afteryou'vemadeatwo-foldimprovementinsomething,youneedtoatleastrethinkandperhapsreanalyzetodiscoverthenext-most-expensivebottleneckinthesystem,andattackthattogetanothertwo-foldimprovement.

Often,thebottlenecksinperformancewillbeanexampleofcountingcowsbycountinglegsanddividingbyfour,insteadofcountingheads.Forexample,I'vemadeerrorssuchasfailingtoprovidearelationaldatabasesystemwithaproperindexonacolumnIlookupalot,whichprobablymadeitatleast20timesslower.OtherexamplesincludedoingunnecessaryI/Oininnerloops,leavingindebuggingstatementsthatarenolongerneeded,unnecessarymemoryallocation,and,inparticular,inexpertuseoflibrariesandothersubsystemsthatareoftenpoorlydocumentedwithrespecttoperformance.Thiskindofimprovementissometimescalledlow-hangingfruit,meaningthatitcanbeeasilypickedtoprovidesomebenefit.

Whatdoyoudowhenyoustarttorunoutoflow-hangingfruit?Well,youcanreachhigher,orchopthetreedown.Youcancontinuemakingsmallimprovementsoryoucanseriouslyredesignasystemorasubsystem.(Thisisagreatopportunitytouseyourskillsasagoodprogrammer,notonlyinthenewdesignbutalsoinconvincingyourbossthatthisisagoodidea.)However,beforeyouarguefortheredesignofasubsystem,youshouldaskyourselfwhetherornotyourproposalwillmakeitfivetotentimebetter.

NextHowtoOptimizeLoops

HowtobeaProgrammer

17Beginner

Page 18: How to Be a Programmer En

HowtoOptimizeLoopsSometimesyou'llencounterloops,orrecursivefunctions,thattakealongtimetoexecuteandarebottlenecksinyourproduct.Beforeyoutrytomaketheloopalittlefaster,spendafewminutesconsideringifthereisawaytoremoveitentirely.Wouldadifferentalgorithmdo?Couldyoucomputethatwhilecomputingsomethingelse?Ifyoucan'tfindawayaroundit,thenyoucanoptimizetheloop.Thisissimple;movestuffout.Intheend,thiswillrequirenotonlyingenuitybutalsoanunderstandingoftheexpenseofeachkindofstatementandexpression.Herearesomesuggestions:

Removefloatingpointoperations.Don'tallocatenewmemoryblocksunnecessarily.Foldconstantstogether.MoveI/Ointoabuffer.Trynottodivide.Trynottodoexpensivetypecasts.Moveapointerratherthanrecomputingindices.

Thecostofeachoftheseoperationsdependsonyourspecificsystem.Onsomesystemscompilersandhardwaredothesethingsforyou.Clear,efficientcodeisbetterthancodethatrequiresanunderstandingofaparticularplatform.

NextHowtoDealwithI/OExpense

HowtobeaProgrammer

18Beginner

Page 19: How to Be a Programmer En

HowtoDealwithI/OExpenseForalotofproblems,processorsarefastcomparedtothecostofcommunicatingwithahardwaredevice.ThiscostisusuallyabbreviatedI/O,andcanincludenetworkcost,diskI/O,databasequeries,fileI/O,andotheruseofsomehardwarenotveryclosetotheprocessor.ThereforebuildingafastsystemisoftenmoreaquestionofimprovingI/Othanimprovingthecodeinsometightloop,orevenimprovinganalgorithm.

TherearetwoveryfundamentaltechniquestoimprovingI/O:cachingandrepresentation.CachingisavoidingI/O(generallyavoidingthereadingofsomeabstractvalue)bystoringacopyofthatvaluelocallysonoI/Oisperformedtogetthevalue.Thefirstkeytocachingistomakeitcrystalclearwhichdataisthemasterandwhicharecopies.Thereisonlyonemaster-period.Cachingbringswithitthedangerthatthecopysometimescan'treflectchangestothemasterinstantaneously.

RepresentationistheapproachofmakingI/Ocheaperbyrepresentingdatamoreefficiently.Thisisoftenintensionwithotherdemands,likehumanreadabilityandportability.

Representationscanoftenbeimprovedbyafactoroftwoorthreefromtheirfirstimplementation.Techniquesfordoingthisincludeusingabinaryrepresentationinsteadofonethatishumanreadable,transmittingadictionaryofsymbolsalongwiththedatasothatlongsymbolsdon'thavetobeencoded,and,attheextreme,thingslikeHuffmanencoding.

Athirdtechniquethatissometimespossibleistoimprovethelocalityofreferencebypushingthecomputationclosertothedata.Forinstance,ifyouarereadingsomedatafromadatabaseandcomputingsomethingsimplefromit,suchasasummation,trytogetthedatabaseservertodoitforyou.Thisishighlydependentonthekindofsystemyou'reworkingwith,butyoushouldexploreit.

NextHowtoManageMemory

HowtobeaProgrammer

19Beginner

Page 20: How to Be a Programmer En

HowtoManageMemoryMemoryisapreciousresourcethatyoucan'taffordtorunoutof.Youcanignoreitforawhilebuteventuallyyouwillhavetodecidehowtomanagememory.

Spacethatneedstopersistbeyondthescopeofasinglesubroutineisoftencalledheapallocated.Achunkofmemoryisuseless,hencegarbage,whennothingreferstoit.Dependingonthesystemyouuse,youmayhavetoexplicitlydeallocatememoryyourselfwhenitisabouttobecomegarbage.Moreoftenyoumaybeabletouseasystemthatprovidesagarbagecollector.Agarbagecollectornoticesgarbageandfreesitsspacewithoutanyactionrequiredbytheprogrammer.Garbagecollectioniswonderful:itlessenserrorsandincreasescodebrevityandconcisioncheaply.Useitwhenyoucan.

Butevenwithgarbagecollection,youcanfillupallmemorywithgarbage.Aclassicmistakeistouseahashtableasacacheandforgettoremovethereferencesinthehashtable.Sincethereferenceremains,thereferentisnon-collectablebutuseless.Thisiscalledamemoryleak.Youshouldlookforandfixmemoryleaksearly.Ifyouhavelongrunningsystemsmemorymayneverbeexhaustedintestingbutwillbeexhaustedbytheuser.

Thecreationofnewobjectsismoderatelyexpensiveonanysystem.Memoryallocateddirectlyinthelocalvariablesofasubroutine,however,isusuallycheapbecausethepolicyforfreeingitcanbeverysimple.Youshouldavoidunnecessaryobjectcreation.

Animportantcaseoccurswhenyoucandefineanupperboundonthenumberofobjectsyouwillneedatonetime.Iftheseobjectsalltakeupthesameamountofmemory,youmaybeabletoallocateasingleblockofmemory,orabuffer,toholdthemall.Theobjectsyouneedcanbeallocatedandreleasedinsidethisbufferinasetrotationpattern,soitissometimescalledaringbuffer.Thisisusuallyfasterthanheapallocation.

Sometimesyouhavetoexplicitlyfreeallocatedspacesoitcanbereallocatedratherthanrelyongarbagecollection.Thenyoumustapplycarefulintelligencetoeachchunkofallocatedmemoryanddesignawayforittobedeallocatedattheappropriatetime.Themethodmaydifferforeachkindofobjectyoucreate.Youmustmakesurethateveryexecutionofamemoryallocatingoperationismatchedbyamemorydeallocatingoperationeventually.Thisissodifficultthatprogrammersoftensimplyimplementarudimentaryformorgarbagecollection,suchasreferencecounting,todothisforthem.

NextHowtoDealwithIntermittentBugs

HowtobeaProgrammer

20Beginner

Page 21: How to Be a Programmer En

HowtoDealwithIntermittentBugsTheintermittentbugisacousinofthe50-foot-invisible-scorpion-from-outer-spacekindofbug.Thisnightmareoccurssorarelythatitishardtoobserve,yetoftenenoughthatitcan'tbeignored.Youcan'tdebugbecauseyoucan'tfindit.

Althoughafter8hoursyouwillstarttodoubtit,theintermittentbughastoobeythesamelawsoflogiceverythingelsedoes.Whatmakesithardisthatitoccursonlyunderunknownconditions.Trytorecordthecircumstancesunderwhichthebugdoesoccur,sothatyoucanguessatwhatthevariabilityreallyis.Theconditionmayberelatedtodatavalues,suchas‘ThisonlyhappenswhenweenterWyomingasavalue.’Ifthatisnotthesourceofvariability,thenextsuspectshouldbeimproperlysynchronizedconcurrency.

Try,try,trytoreproducethebuginacontrolledway.Ifyoucan'treproduceit,setatrapforitbybuildingaloggingsystem,aspecialoneifyouhaveto,thatcanlogwhatyouguessyouneedwhenitreallydoesoccur.Resignyourselftothatifthebugonlyoccursinproductionandnotatyourwhim,thismaybealongprocess.Thehintsthatyougetfromthelogmaynotprovidethesolutionbutmaygiveyouenoughinformationtoimprovethelogging.Theimprovedloggingsystemmaytakealongtimetobeputintoproduction.Then,youhavetowaitforthebugtoreoccurtogetmoreinformation.Thiscyclecangoonforsometime.

ThestupidestintermittentbugIevercreatedwasinamulti-threadedimplementationofafunctionalprogramminglanguageforaclassproject.Ihadverycarefullyensuredcorrectconcurrentevaluationofthefunctionalprogram,goodutilizationofalltheCPUsavailable(eight,inthiscase).Isimplyforgottosynchronizethegarbagecollector.Thesystemcouldrunalongtime,oftenfinishingwhatevertaskIbegan,beforeanythingnoticeablewentwrong.I'mashamedtoadmitIhadbeguntoquestionthehardwarebeforemymistakedawnedonme.

Atworkwerecentlyhadanintermittentbugthattookusseveralweekstofind.Wehavemulti-threadedapplicationserversinJava™behindApache™webservers.Tomaintainfastpageturns,wedoallI/Oinsmallsetoffourseparatethreadsthataredifferentthanthepage-turningthreads.Everyonceinawhilethesewouldapparentlyget‘stuck’andceasedoinganythinguseful,sofarasourloggingallowedustotell,forhours.Sincewehadfourthreads,thiswasnotinitselfagiantproblem-unlessallfourgotstuck.Thenthequeuesemptiedbythesethreadswouldquicklyfillupallavailablememoryandcrashourserver.Ittookusaboutaweektofigurethismuchout,andwestilldidn'tknowwhatcausedit,whenitwouldhappen,orevenwhatthethreadswheredoingwhentheygot‘stuck’.

HowtobeaProgrammer

21Beginner

Page 22: How to Be a Programmer En

Thisillustratessomeriskassociatedwiththird-partysoftware.WewereusingalicensedpieceofcodethatremovedHTMLtagsfromtext.Duetoitsplaceoforiginweaffectionatelyreferredtothisas‘theFrenchstripper‘.Althoughwehadthesourcecode(thankgoodness!)wehadnotstudieditcarefullyuntilbyturninguptheloggingonourserverswefinallyrealizedthattheemailthreadsweregettingstuckintheFrenchstripper.

Thestripperperformedwellexceptonsomelongandunusualkindsoftexts.Onthesetexts,thecodewasquadraticorworse.Thismeansthattheprocessingtimewasproportionaltothesquareofthelengthofthetext.Hadthesetextsoccurredcommonly,wewouldhavefoundthebugrightaway.Iftheyhadneveroccurredatall,wewouldneverhavehadaproblem.Asithappens,ittookusweekstofinallyunderstandandresolvetheproblem.

NextHowtoLearnDesignSkills

HowtobeaProgrammer

22Beginner

Page 23: How to Be a Programmer En

HowtoLearnDesignSkillsTolearnhowtodesignsoftware,studytheactionofamentorbybeingphysicallypresentwhentheyaredesigning.Thenstudywell-writtenpiecesofsoftware.Afterthat,youcanreadsomebooksonthelatestdesigntechniques.

Thenyoumustdoityourself.Startwithasmallproject.Whenyouarefinallydone,considerhowthedesignfailedorsucceededandhowyoudivergedfromyouroriginalconception.Thenmoveontolargerprojects,hopefullyinconjunctionwithotherpeople.Designisamatterofjudgementthattakesyearstoacquire.Asmartprogrammercanlearnthebasicsadequatelyintwomonthsandcanimprovefromthere.

Itisnaturalandhelpfultodevelopyourownstyle,butrememberthatdesignisanart,notascience.Peoplewhowritebooksonthesubjecthaveavestedinterestinmakingitseemscientific.Don'tbecomedogmaticaboutparticulardesignstyles.

NextHowtoConductExperiments

HowtobeaProgrammer

23Beginner

Page 24: How to Be a Programmer En

HowtoConductExperimentsThelate,greatEdsgerDijkstrahaseloquentlyexplainedthatComputerScienceisnotanexperimentalscience[ExpCS]anddoesn'tdependonelectroniccomputers.Asheputsitreferringtothe1960s[Knife],

...theharmwasdone:thetopicbecameknownas“computerscience”-which,actually,islikereferringtosurgeryas“knifescience”-anditwasfirmlyimplantedinpeople'smindsthatcomputingscienceisaboutmachinesandtheirperipheralequipment.

Programmingoughtnottobeanexperimentalscience,butmostworkingprogrammersdonothavetheluxuryofengaginginwhatDijkstrameansbycomputingscience.Wemustworkintherealmofexperimentation,justassome,butnotall,physicistsdo.Ifthirtyyearsfromnowprogrammingcanbeperformedwithoutexperimentation,itwillbeagreataccomplishmentofComputerScience.

Thekindsofexperimentsyouwillhavetoperforminclude:

Testingsystemswithsmallexamplestoverifythattheyconformtothedocumentationortounderstandtheirresponsewhenthereisnodocumentation,Testingsmallcodechangestoseeiftheyactuallyfixabug,Measuringtheperformanceofasystemundertwodifferentconditionsduetoimperfectknowledgeoftheirperformancecharacteristics,Checkingtheintegrityofdata,andCollectingstatisticsthatmayhintatthesolutiontodifficultorhard-to-repeatbugs.

Idon'tthinkinthisessayIcanexplainthedesignofexperiments;youwillhavetostudyandpractice.However,Icanoffertwobitsofadvice.

First,trytobeveryclearaboutyourhypothesis,ortheassertionthatyouaretryingtotest.Italsohelpstowritethehypothesisdown,especiallyifyoufindyourselfconfusedorareworkingwithothers.

Youwilloftenfindyourselfhavingtodesignaseriesofexperiments,eachofwhichisbasedontheknowledgegainedfromthelastexperiment.Therefore,youshoulddesignyourexperimentstoprovidethemostinformationpossible.Unfortunately,thisisintensionwithkeepingeachexperimentsimple-youwillhavetodevelopthisjudgementthroughexperience.

NextTeamSkills-WhyEstimationisImportant

HowtobeaProgrammer

24Beginner

Page 25: How to Be a Programmer En

WhyEstimationisImportantTogetaworkingsoftwaresysteminactiveuseasquicklyaspossiblerequiresnotonlyplanningthedevelopment,butalsoplanningthedocumentation,deployment,andmarketing.Inacommercialprojectitalsorequiressalesandfinance.Withoutpredictabilityofthedevelopmenttime,itisimpossibletoplantheseeffectively.

Goodestimationprovidespredictability.Managersloveit,aswelltheyshould.Thefactthatitisimpossible,boththeoreticallyandpractically,topredictaccuratelyhowlongitwilltaketodevelopsoftwareisoftenlostonmanagers.Weareaskedtodothisimpossiblethingallthetime,andwemustfaceuptoithonestly.However,itwouldbedishonestnottoadmittheimpossibilityofthistask,andwhennecessary,explainit.Thereisalotofroomformiscommunicationaboutestimates,aspeoplehaveastartlingtendencytothinkwishfullythatthesentence:

Iestimatethat,ifIreallyunderstandtheproblem,itisabout50%likelythatwewillbedoneinfiveweeks(ifnoonebothersusduringthattime).

reallymeans:

Ipromisetohaveitalldonefiveweeksfromnow.

Thiscommoninterpretationproblemrequiresthatyouexplicitlydiscusswhattheestimatemeanswithyourbossorcustomerasiftheywereasimpleton.Restateyourassumptions,nomatterhowobvioustheyseemtoyou.

NextHowtoEstimateProgrammingTime

HowtobeaProgrammer

25Beginner

Page 26: How to Be a Programmer En

HowtoEstimateProgrammingTimeEstimationtakespractice.Italsotakeslabour.Ittakessomuchlabouritmaybeagoodideatoestimatethetimeitwilltaketomaketheestimate,especiallyifyouareaskedtoestimatesomethingbig.

Whenaskedtoprovideanestimateofsomethingbig,themosthonestthingtodoistostall.Mostengineersareenthusiasticandeagertoplease,andstallingcertainlywilldispleasethestalled.Butanon-the-spotestimateprobablywon'tbeaccurateandhonest.

Whilestalling,itmaybepossibletoconsiderdoingorprototypingthetask.Ifpoliticalpressurepermits,thisisthemostaccuratewayofproducingtheestimate,anditmakesrealprogress.

Whennotpossibletotakethetimeforsomeinvestigation,youshouldfirstestablishthemeaningoftheestimateveryclearly.Restatethatmeaningasthefirstandlastpartofyourwrittenestimate.Prepareawrittenestimatebyde-constructingthetaskintoprogressivelysmallersubtasksuntileachsmalltaskisnomorethanaday;ideallyatmostinlength.Themostimportantthingisnottoleaveanythingout.Forinstance,documentation,testing,timeforplanning,timeforcommunicatingwithothergroups,andvacationtimeareallveryimportant.Ifyouspendpartofeachdaydealingwithknuckleheads,putalineitemforthatintheestimate.Thisgivesyourbossvisibilityintowhatisusingupyourtimeataminimum,andmightgetyoumoretime.

Iknowgoodengineerswhopadestimatesimplicitly,butIrecommendthatyoudonot.Oneoftheresultsofpaddingistrustinyoumaybedepleted.Forinstance,anengineermightestimatethreedaysforataskthatshetrulythinkswilltakeoneday.Theengineermayplantospendtwodaysdocumentingit,ortwodaysworkingonsomeotherusefulproject.Butitwillbedetectablethatthetaskwasdoneinonlyoneday(ifitturnsoutthatway),andtheappearanceofslackingoroverestimatingisborn.It'sfarbettertogivepropervisibilityintowhatyouareactuallydoing.Ifdocumentationtakestwiceaslongascodingandtheestimatesaysso,tremendousadvantageisgainedbymakingthisvisibletothemanager.

Padexplicitlyinstead.Ifataskwillprobablytakeoneday-butmighttaketendaysifyourapproachdoesn'twork-notethissomehowintheestimateifyoucan;ifnot,atleastdoanaverageweightedbyyourestimatesoftheprobabilities.Anyriskfactorthatyoucanidentifyandassignanestimatetoshouldgointotheschedule.Onepersonisunlikelytobesickinanygivenweek.Butalargeprojectwithmanyengineerswillhavesomesicktime;likewisevacationtime.Andwhatistheprobabilityofamandatorycompany-widetrainingseminar?Ifitcanbeestimated,stickitin.Thereareofcourse,unknownunknowns,orunk-unks.Unk-

HowtobeaProgrammer

26Beginner

Page 27: How to Be a Programmer En

unksbydefinitioncannotbeestimatedindividually.Youcantrytocreateagloballineitemforallunk-unks,orhandletheminsomeotherwaythatyoucommunicatetoyourboss.Youcannot,however,letyourbossforgetthattheyexist,anditisdevilishlyeasyforanestimatetobecomeaschedulewithouttheunk-unksconsidered.

Inateamenvironment,youshouldtrytohavethepeoplewhowilldotheworkdotheestimate,andyoushouldtrytohaveteam-wideconsensusonestimates.Peoplevarywidelyinskill,experience,preparedness,andconfidence.Calamitystrikeswhenastrongprogrammerestimatesforherselfandthenweakprogrammersareheldtothisestimate.Theactofhavingthewholeteamagreeonaline-by-linebasistotheestimateclarifiestheteamunderstanding,aswellasallowingtheopportunityfortacticalreassignmentofresources(forinstance,shiftingburdenawayfromweakerteammemberstostronger).

Iftherearebigrisksthatcannotbeevaluated,itisyourdutytostatesoforcefullyenoughthatyourmanagerdoesnotcommittothemandthenbecomeembarrassedwhentheriskoccurs.Hopefullyinsuchacasewhateverisneededwillbedonetodecreasetherisk.

IfyoucanconvinceyourcompanytouseExtremeProgramming,youwillonlyhavetoestimaterelativelysmallthings,andthisisbothmorefunandmoreproductive.

NextHowtoFindOutInformation

HowtobeaProgrammer

27Beginner

Page 28: How to Be a Programmer En

HowtoFindOutInformationThenatureofwhatyouneedtoknowdetermineshowyoushouldfindit.

Ifyouneedinformationaboutconcretethingsthatareobjectiveandeasytoverify,forexamplethelatestpatchlevelofasoftwareproduct,askalargenumberofpeoplepolitelybysearchingtheinternetforitorbypostingonadiscussiongroup.Don'tsearchontheinternetforanythingthatsmacksofeitheropinionorsubjectiveinterpretation:theratioofdriveltotruthistoohigh.

Ifyouneedgeneralknowledgeaboutsomethingsubjectivethehistoryofwhatpeoplehavethoughtaboutit,gotothelibrary(thephysicalbuildinginwhichbooksarestored).Forexample,tolearnaboutmathormushroomsormysticism,gotothelibrary.

Ifyouneedtoknowhowtodosomethingthatisnottrivialgettwoorthreebooksonthesubjectandreadthem.Youmightlearnhowtodosomethingtrivial,likeinstallasoftwarepackage,fromtheInternet.Youcanevenlearnimportantthings,likegoodprogrammingtechnique,butyoucaneasilyspendmoretimesearchingandsortingtheresultsandattemptingtodivinetheauthorityoftheresultsthanitwouldtaketoreadthepertinentpartofasolidbook.

Ifyouneedinformationthatnooneelsecouldbeexpectedtoknowforexample,‘doesthissoftwarethatisbrandnewworkongiganticdatasets?’,youmuststillsearchtheinternetandthelibrary.Afterthoseoptionsarecompletelyexhausted,youmaydesignanexperimenttoascertainit.

Ifyouwantanopinionoravaluejudgementthattakesintoaccountsomeuniquecircumstance,talktoanexpert.Forinstance,ifyouwanttoknowwhetherornotitisagoodideatobuildamoderndatabasemanagementsysteminLISP,youshouldtalktoaLISPexpertandadatabaseexpert.

Ifyouwanttoknowhowlikelyitisthatafasteralgorithmforaparticularapplicationexiststhathasnotyetbeenpublished,talktosomeoneworkinginthatfield.

Ifyouwanttomakeapersonaldecisionthatonlyyoucanmakelikewhetherornotyoushouldstartabusiness,tryputtingintowritingalistofargumentsforandagainsttheidea.Ifthatfails,considerdivination.Supposeyouhavestudiedtheideafromallangles,havedoneallyourhomework,andworkedoutalltheconsequencesandprosandconsinyourmind,andyetstillremainindecisive.Younowmustfollowyourheartandtellyourbraintoshutup.

HowtobeaProgrammer

28Beginner

Page 29: How to Be a Programmer En

Themultitudeofavailabledivinationtechniquesareveryusefulfordeterminingyourownsemi-consciousdesires,astheyeachpresentacompleteambiguousandrandompatternthatyourownsubconsciouswillassignmeaningto.

NextHowtoUtilizePeopleasInformationSources

HowtobeaProgrammer

29Beginner

Page 30: How to Be a Programmer En

HowtoUtilizePeopleasInformationSourcesRespecteveryperson'stimeandbalanceitagainstyourown.Askingsomeoneaquestionaccomplishesfarmorethanjustreceivingtheanswer.Thepersonlearnsaboutyou,bothbyenjoyingyourpresenceandhearingtheparticularquestion.Youlearnaboutthepersoninthesameway,andyoumaylearntheansweryouseek.Thisisusuallyfarmoreimportantthanyourquestion.

However,thevalueofthisdiminishesthemoreyoudoit.Youare,afterall,usingthemostpreciouscommodityapersonhas:theirtime.Thebenefitsofcommunicationmustbeweighedagainstthecosts.Furthermore,theparticularcostsandbenefitsderiveddifferfrompersontoperson.Istronglybelievethatanexecutiveof100peopleshouldspendfiveminutesamonthtalkingtoeachpersoninherorganization,whichwouldbeabout5%oftheirtime.Buttenminutesmightbetoomuch,andfiveminutesistoomuchiftheyhaveonethousandemployees.Theamountoftimeyouspendtalkingtoeachpersoninyourorganizationdependsontheirrole(morethantheirposition).Youshouldtalktoyourbossmorethanyourboss'sboss,butyoushouldtalktoyourboss'sbossalittle.Itmaybeuncomfortable,butIbelieveyouhaveadutytotalkalittlebittoallyoursuperiors,eachmonth,nomatterwhat.

Thebasicruleisthateveryonebenefitsfromtalkingtoyoualittlebit,andthemoretheytalktoyou,thelessbenefittheyderive.Itisyourjobtoprovidethemthisbenefit,andtogetthebenefitofcommunicatingwiththem,keepingthebenefitinbalancewiththetimespent.

Itisimportanttorespectyourowntime.Iftalkingtosomeone,evenifitwillcostthemtime,willsaveyouagreatdealoftime,thenyoushoulddoitunlessyouthinktheirtimeismorevaluablethanyours,tothetribe,bythatfactor.

Astrangeexampleofthisisthesummerintern.Asummerinterninahighlytechnicalpositioncan'tbeexpectedtoaccomplishtoomuch;theycanbeexpectedtopesterthehelloutofeverybodythere.Sowhyisthistolerated?Becausethepesteredarereceivingsomethingimportantfromtheintern.Theygetachancetoshow-offalittle.Theygetachancetohearsomenewideas,maybe;theygetachancetoseethingsfromadifferentperspective.Theymayalsobetryingtorecruittheintern,butevenifthisisnotthecasethereismuchtogain.

Youshouldaskpeopleforalittlebitoftheirwisdomandjudgementwheneveryouhonestlybelievetheyhavesomethingtosay.Thisflattersthemandyouwilllearnsomethingandteachthemsomething.AgoodprogrammerdoesnotoftenneedtheadviceofaVice

HowtobeaProgrammer

30Beginner

Page 31: How to Be a Programmer En

PresidentofSales,butifyoueverdo,youbesuretoaskforit.Ionceaskedtolisteninonafewsalescallstobetterunderstandthejobofoursalesstaff.Thistooknomorethan30minutesbutIthinkthatsmalleffortmadeanimpressiononthesalesforce.

NextHowtoDocumentWisely

HowtobeaProgrammer

31Beginner

Page 32: How to Be a Programmer En

HowtoDocumentWiselyLifeistooshorttowritecrapnobodywillread;ifyouwritecrap,nobodywillreadit.Thereforealittlegooddocumentationisbest.Managersoftendon'tunderstandthis,becauseevenbaddocumentationgivesthemafalsesenseofsecuritythattheyarenotdependentontheirprogrammers.Ifsomeoneabsolutelyinsiststhatyouwritetrulyuselessdocumentation,say'yes'andquietlybeginlookingforabetterjob.

There'snothingquiteaseffectiveasputtinganaccurateestimateoftheamountoftimeitwilltaketoproducegooddocumentationintoanestimatetoslackenthedemandfordocumentation.Thetruthiscoldandhard:documentation,liketesting,cantakemanytimeslongerthandevelopingcode.

Writinggooddocumentationis,firstofall,goodwriting.Isuggestyoufindbooksonwriting,studythem,andpractice.Butevenifyouarealousywriterorhavepoorcommandofthelanguageinwhichyoumustdocument,theGoldenRuleisallyoureallyneed:'Dountoothersasyouwouldhavethemdountoyou.'Taketimetoreallythinkaboutwhowillbereadingyourdocumentation,whattheyneedtogetoutofit,andhowyoucanteachthattothem.Ifyoudothat,youwillbeanaboveaveragedocumentationwriter,andagoodprogrammer.

Whenitcomestoactuallydocumentingcodeitself,asopposedtoproducingdocumentsthatcanactuallybereadbynon-programmers,thebestprogrammersI'veeverknownholdauniversalsentiment:writeself-explanatorycodeandonlydocumentcodeintheplacesthatyoucannotmakeitclearbywritingthecodeitself.Therearetwogoodreasonsforthis.First,anyonewhoneedstoseecode-leveldocumentationwillinmostcasesbeabletoandprefertoreadthecodeanyway.Admittedly,thisseemseasiertotheexperiencedprogrammerthantothebeginner.Moreimportantlyhowever,isthatthecodeandthedocumentationcannotbeinconsistentifthereisnodocumentation.Thesourcecodecanatworstbewrongandconfusing.Thedocumentation,ifnotwrittenperfectly,canlie,andthatisathousandtimesworse.

Thisdoesnotmakeiteasierontheresponsibleprogrammer.Howdoesonewriteself-explanatorycode?Whatdoesthatevenmean?Itmeans:

Writingcodeknowingthatsomeonewillhavetoreadit;Applyingthegoldenrule;Choosingasolutionthatisstraightforward,evenifyoucouldgetbywithanothersolutionfaster;Sacrificingsmalloptimizationsthatobfuscatethecode;

HowtobeaProgrammer

32Beginner

Page 33: How to Be a Programmer En

Thinkingaboutthereaderandspendingsomeofyourprecioustimetomakeiteasieronher;andNoteverusingafunctionnamelikefoo,bar,ordoIt!

NextHowtoWorkwithPoorCode

HowtobeaProgrammer

33Beginner

Page 34: How to Be a Programmer En

HowtoWorkwithPoorCodeItisverycommontohavetoworkwithpoorqualitycodethatsomeoneelsehaswritten.Don'tthinktoopoorlyofthem,however,untilyouhavewalkedintheirshoes.Theymayhavebeenaskedveryconsciouslytogetsomethingdonequicklytomeetschedulepressure.Regardless,inordertoworkwithunclearcodeyoumustunderstandit.Tounderstandittakeslearningtime,andthattimewillhavetocomeoutofsomeschedule,somewhere,andyoumustinsistonit.Tounderstandit,youwillhavetoreadthesourcecode.Youwillprobablyhavetoexperimentwithit.

Thisisagoodtimetodocument,evenifitisonlyforyourself,becausetheactoftryingtodocumentthecodewillforceyoutoconsideranglesyoumightnothaveconsidered,andtheresultingdocumentmaybeuseful.Whileyou'redoingthis,considerwhatitwouldtaketorewritesomeorallofthecode.Woulditactuallysavetimetorewritesomeofit?Couldyoutrustitbetterifyourewroteit?Becarefulofarrogancehere.Ifyourewriteit,itwillbeeasierforyoutodealwith,butwillitreallybeeasierforthenextpersonwhohastoreadit?Ifyourewriteit,whatwillthetestburdenbe?Willtheneedtore-testitoutweighanybenefitsthatmightbegained?

Inanyestimatethatyoumakeforworkagainstcodeyoudidn'twrite,thequalityofthatcodeshouldaffectyourperceptionoftheriskofproblemsandunk-unks.

Itisimportanttorememberthatabstractionandencapsulation,twoofaprogrammer'sbesttools,areparticularlyapplicabletolousycode.Youmaynotbeabletoredesignalargeblockofcode,butifyoucanaddacertainamountofabstractiontoityoucanobtainsomeofthebenefitsofagooddesignwithoutreworkingthewholemess.Inparticular,youcantrytowalloffthepartsthatareparticularlybadsothattheymayberedesignedindependently.

NextHowtoUseSourceCodeControl

HowtobeaProgrammer

34Beginner

Page 35: How to Be a Programmer En

HowtoUseSourceCodeControlSourcecodecontrolsystems(alsoknownasVersionControlSystems)letyoumanageprojectseffectively.They'reveryusefulforonepersonandessentialforagroup.Theytrackallchangesindifferentversionssothatnocodeiseverlostandmeaningcanbeassignedtochanges.Onecancreatethrow-awayanddebuggingcodewithconfidencewithasourcecodecontrolsystem,sincethecodeyoumodifyiskeptcarefullyseparatefromcommitted,officialcodethatwillbesharedwiththeteamorreleased.

IwaslatetoappreciatethebenefitsofsourcecodecontrolsystemsbutnowIwouldn'tlivewithoutoneevenonaone-personproject.Generallytheyarenecessarywhenyouhaveteamworkingonthesamecodebase.However,theyhaveanothergreatadvantage:theyencouragethinkingaboutthecodeasagrowing,organicsystem.Sinceeachchangeismarkedasanewrevisionwithanewnameornumber,onebeginstothinkofthesoftwareasavisiblyprogressiveseriesofimprovements.Ithinkthisisespeciallyusefulforbeginners.

Agoodtechniqueforusingasourcecodecontrolsystemistostaywithinafewdaysofbeingup-to-dateatalltime.Codethatcan'tbefinishedinafewdaysischeckedin,butinawaythatitisinactiveandwillnotbecalled,andthereforenotcreateanyproblemsforanybodyelse.Committingamistakethatslowsdownyourteam-matesisaseriouserror;itisoftentaboo.

NextHowtoUnitTest

HowtobeaProgrammer

35Beginner

Page 36: How to Be a Programmer En

HowtoUnitTestUnittesting,thetestingofanindividualpieceofcodedfunctionalitybytheteamthatwroteit,isapartofcoding,notsomethingdifferentfromit.Partofdesigningthecodeisdesigninghowitwillbetested.Youshouldwritedownatestplan,evenifitisonlyonesentence.Sometimesthetestwillbesimple:'Doesthebuttonlookgood?'Sometimesitwillbecomplex:'Didthismatchingalgorithmreturnpreciselythecorrectmatches?'

Useassertioncheckingandtestdriverswheneverpossible.Thisnotonlycatchesbugsearly,butisveryusefullateronandletsyoueliminatemysteriesthatyouwouldotherwisehavetoworryabout.

TheExtremeProgrammingdevelopersarewritingextensivelyonunittestingeffectively;Icandonobetterthantorecommendtheirwritings.

NextTakeBreakswhenStumped

HowtobeaProgrammer

36Beginner

Page 37: How to Be a Programmer En

TakeBreakswhenStumpedWhenstumped,takeabreak.Isometimesmeditatefor15minuteswhenstumpedandtheproblemmagicallyunravelswhenIcomebacktoit.Anight'ssleepsometimesdoesthesamethingonalargerscale.It'spossiblethattemporarilyswitchingtoanyotheractivitymaywork.

NextHowtoRecognizeWhentoGoHome

HowtobeaProgrammer

37Beginner

Page 38: How to Be a Programmer En

HowtoRecognizeWhentoGoHomeComputerprogrammingisanactivitythatisalsoaculture.Theunfortunatefactisthatitisnotaculturethatvaluesmentalorphysicalhealthverymuch.Forbothcultural/historicalreasons(theneedtoworkatnightonunloadedcomputers,forexample)andbecauseofoverwhelmingtime-to-marketpressureandthescarcityofprogrammers,computerprogrammersaretraditionallyoverworked.Idon'tthinkyoucantrustallthestoriesyouhear,butIthink60hoursaweekiscommon,and50isprettymuchaminimum.Thismeansthatoftenmuchmorethanthatisrequired.Thisisseriousproblemforagoodprogrammer,whoisresponsiblenotonlyforthemselvesbuttheirteam-matesaswell.Youhavetorecognizewhentogohome,andsometimeswhentosuggestthatotherpeoplegohome.Therecan'tbeanyfixedrulesforsolvingthisproblem,anymorethantherecanbefixedrulesforraisingachild,forthesamereason---everyhumanbeingisdifferent.

Beyond60hoursaweekisanextraordinaryeffortforme,whichIcanapplyforshortperiodsoftime(aboutoneweek),andthatissometimesexpectedofme.Idon'tknowifitisfairtoexpect60hoursofworkfromaperson;Idon'tevenknowif40isfair.Iamsure,however,thatitisstupidtoworksomuchthatyouaregettinglittleoutofthatextrahouryouwork.Formepersonally,that'sanymorethan60hoursaweek.Ipersonallythinkaprogrammershouldexercisenoblesseobligeandshoulderaheavyburden.However,itisnotaprogrammer'sdutytobeapatsy.Thesadfactisprogrammersareoftenaskedtobepatsiesinordertoputonashowforsomebody,forexampleamanagertryingtoimpressanexecutive.Programmersoftensuccumbtothisbecausetheyareeagertopleaseandnotverygoodatsayingno.Therearefourdefencesagainstthis:

Communicateasmuchaspossiblewitheveryoneinthecompanysothatnoonecanmisleadtheexecutivesaboutwhatisgoingon,Learntoestimateandscheduledefensivelyandexplicitlyandgiveeveryonevisibilityintowhatthescheduleisandwhereitstands,Learntosayno,andsaynoasateamwhennecessary,andQuitifyouhaveto.

Mostprogrammersaregoodprogrammers,andgoodprogrammerswanttogetalotdone.Todothat,theyhavetomanagetheirtimeeffectively.Thereisacertainamountofmentalinertiaassociatedwithgettingwarmed-uptoaproblemanddeeplyinvolvedinit.Manyprogrammersfindtheyworkbestwhentheyhavelong,uninterruptedblocksoftimeinwhichtogetwarmed-upandconcentrate.However,peoplemustsleepandperformotherduties.

HowtobeaProgrammer

38Beginner

Page 39: How to Be a Programmer En

Eachpersonneedstofindawaytosatisfyboththeirhumanrhythmandtheirworkrhythm.Eachprogrammerneedstodowhateverittakestoprocureefficientworkperiods,suchasreservingcertaindaysinwhichyouwillattendonlythemostcriticalmeetings.

SinceIhavechildren,Itrytospendeveningswiththemsometimes.Therhythmthatworksbestformeistoworkaverylongday,sleepintheofficeorneartheoffice(Ihavealongcommutefromhometowork)thengohomeearlyenoughthenextdaytospendtimewithmychildrenbeforetheygotobed.Iamnotcomfortablewiththis,butitisthebestcompromiseIhavebeenabletoworkout.Gohomeifyouhaveacontagiousdisease.Youshouldgohomeifyouarethinkingsuicidalthoughts.Youshouldtakeabreakorgohomeifyouthinkhomicidalthoughtsformorethanafewseconds.Youshouldsendsomeonehomeiftheyshowseriousmentalmalfunctioningorsignsofmentalillnessbeyondmilddepression.Ifyouaretemptedtobedishonestordeceptiveinawaythatyounormallyarenotduetofatigue,youshouldtakeabreak.Don'tusecocaineoramphetaminestocombatfatigue.Don'tabusecaffeine.

NextHowtoDealwithDifficultPeople

HowtobeaProgrammer

39Beginner

Page 40: How to Be a Programmer En

HowtoDealwithDifficultPeopleYouwillprobablyhavetodealwithdifficultpeople.Youmayevenbeadifficultpersonyourself.Ifyouarethekindofpersonwhohasalotofconflictswithco-workersandauthorityfigures,youshouldcherishtheindependencethisimplies,butworkonyourinterpersonalskillswithoutsacrificingyourintelligenceorprinciples.

Thiscanbeverydisturbingtosomeprogrammerswhohavenoexperienceinthissortofthingandwhosepreviouslifeexperiencehastaughtthempatternsofbehaviourthatarenotusefulintheworkplace.Difficultpeopleareofteninuredtodisagreementandtheyarelessaffectedbysocialpressuretocompromisethanothers.Thekeyistorespectthemappropriately,whichismorethanyouwillwanttobutnotasmuchastheymightwant.

Programmershavetoworktogetherasateam.Whendisagreementarises,itmustberesolvedsomehow,itcannotbeduckedforlong.Difficultpeopleareoftenextremelyintelligentandhavesomethingveryusefultosay.Itiscriticalthatyoulistenandunderstandthedifficultpersonwithoutprejudicecausedbytheperson.Afailuretocommunicateisoftenthebasisofdisagreementbutitcansometimesberemovedwithgreatpatience.Trytokeepthiscommunicationcoolandcordial,anddon'tacceptanybaitsforgreaterconflictthatmaybeoffered.Afterareasonableperiodoftryingtounderstand,makeadecision.

Don'tletabullyforceyoutodosomethingyoudon'tagreewith.Ifyouaretheleader,dowhatyouthinkisbest.Don'tmakeadecisionforanypersonalreasons,andbepreparedtoexplainthereasonsforyourdecision.Ifyouareateam-matewithadifficultperson,don'tlettheleader'sdecisionhaveanypersonalimpact.Ifitdoesn'tgoyourway,doittheotherwaywhole-heartedly.

Difficultpeopledochangeandimprove.I'veseenitwithmyowneyes,butitisveryrare.However,everyonehastransitoryupsanddowns.

Oneofthechallengesthateveryprogrammerbutespeciallyleadersfaceiskeepingthedifficultpersonfullyengaged.Theyaremorepronetoduckworkandresistpassivelythanothers.

NextIntermediateskills

HowtobeaProgrammer

40Beginner

Page 41: How to Be a Programmer En

2.IntermediatePersonalSkills

HowtoStayMotivatedHowtobeWidelyTrustedHowtoTradeoffTimevs.SpaceHowtoStressTestHowtoBalanceBrevityandAbstractionHowtoLearnNewSkillsLearntoTypeHowtoDoIntegrationTestingCommunicationLanguagesHeavyToolsHowtoanalyzedata

TeamSkillsHowtoManageDevelopmentTimeHowtoManageThird-PartySoftwareRisksHowtoManageConsultantsHowtoCommunicatetheRightAmountHowtoDisagreeHonestlyandGetAwaywithIt

JudgmentHowtoTradeoffQualityAgainstDevelopmentTimeHowtoManageSoftwareSystemDependenceHowtoDecideifSoftwareisTooImmatureHowtoMakeaBuyvs.BuildDecisionHowtoGrowProfessionallyHowtoEvaluateIntervieweesHowtoKnowWhentoApplyFancyComputerScienceHowtoTalktoNon-Engineers

HowtobeaProgrammer

41Intermediate

Page 42: How to Be a Programmer En

HowtoStayMotivatedItisawonderfulandsurprisingfactthatprogrammersarehighlymotivatedbythedesiretocreateartifactsthatarebeautiful,useful,ornifty.Thisdesireisnotuniquetoprogrammersnoruniversalbutitissostrongandcommonamongprogrammersthatitseparatesthemfromothersinotherroles.

Thishaspracticalandimportantconsequences.Ifprogrammersareaskedtodosomethingthatisnotbeautiful,useful,ornifty,theywillhavelowmorale.There'salotofmoneytobemadedoingugly,stupid,andboringstuff;butintheend,funwillmakethemostmoneyforthecompany.

Obviously,thereareentireindustriesorganizedaroundmotivationaltechniquessomeofwhichapplyhere.ThethingsthatarespecifictoprogrammingthatIcanidentifyare:

Usethebestlanguageforthejob.Lookforopportunitiestoapplynewtechniques,languages,andtechnologies.Trytoeitherlearnorteachsomething,howeversmall,ineachproject.

Finally,ifpossible,measuretheimpactofyourworkintermsofsomethingthatwillbepersonallymotivating.Forexample,whenfixingbugs,countingthenumberofbugsthatIhavefixedisnotatallmotivationaltome,becauseitisindependentofthenumberthatmaystillexist,andisalsoaffectsthetotalvalueI'maddingtomycompany'scustomersinonlythesmallestpossibleway.Relatingeachbugtoahappycustomer,however,ispersonallymotivatingtome.

NextHowtobeWidelyTrusted

HowtobeaProgrammer

42Intermediate

Page 43: How to Be a Programmer En

HowtobeWidelyTrustedTobetrustedyoumustbetrustworthy.Youmustalsobevisible.Ifnooneknowsaboutyou,notrustwillbeinvestedinyou.Withthoseclosetoyou,suchasyourteammates,thisshouldnotbeanissue.Youestablishtrustbybeingresponsiveandinformativetothoseoutsideyourdepartmentorteam.Occasionallysomeonewillabusethistrust,andaskforunreasonablefavours.Don'tbeafraidofthis,justexplainwhatyouwouldhavetogiveupdoingtoperformthefavour.

Don'tpretendtoknowsomethingthatyoudon't.Withpeoplethatarenotteammates,youmayhavetomakeacleardistinctionbetween'notknowingrightoffthetopofmyhead'and'notbeingabletofigureitout,ever.'

NextHowtoTradeoffTimevs.Space

HowtobeaProgrammer

43Intermediate

Page 44: How to Be a Programmer En

HowtoTradeoffTimevs.SpaceYoucanbeagoodprogrammerwithoutgoingtocollege,butyoucan'tbeagoodintermediateprogrammerwithoutknowingbasiccomputationalcomplexitytheory.Youdon'tneedtoknow'bigO'notation,butIpersonallythinkyoushouldbeabletounderstandthedifferencebetween'constant-time','nlogn'and'nsquared'.Youmightbeabletointuithowtotrade-offtimeagainstspacewithoutthisknowledge,butinitsabsenceyouwillnothaveafirmbasisforcommunicatingwithyourcolleagues.

Indesigningorunderstandinganalgorithm,theamountoftimeittakestorunissometimesafunctionofthesizeoftheinput.Whenthatistrue,wecansayanalgorithm'sworst/expected/best-caserunningtimeis'nlogn'ifitisproportionaltothesize($n$)timesthelogarithmofthesize.Thenotationandwayofspeakingcanbealsobeappliedtothespacetakenupbyadatastructure.

Tome,computationalcomplexitytheoryisbeautifulandasprofoundasphysics-andalittlebitgoesalongway!

Time(processorcycles)andspace(memory)canbetradedoffagainsteachother.Engineeringisaboutcompromise,andthisisafineexample.Itisnotalwayssystematic.Ingeneral,however,onecansavespacebyencodingthingsmoretightly,attheexpenseofmorecomputationtimewhenyouhavetodecodethem.Youcansavetimebycaching,thatis,spendingspacetostorealocalcopyofsomething,attheexpenseofhavingtomaintaintheconsistencyofthecache.Youcansometimessavetimebymaintainingmoreinformationinadatastructure.Thisusuallycostasmallamountofspacebutmaycomplicatethealgorithm.

Improvingthespace/timetrade-offcanoftenchangeoneortheotherdramatically.However,beforeyouworkonthisyoushouldaskyourselfifwhatyouareimprovingisreallythethingthatneedsthemostimprovement.It'sfuntoworkonanalgorithm,butyoucan'tletthatblindyoutothecoldhardfactthatimprovingsomethingthatisnotaproblemwillnotmakeanynoticeabledifferenceandwillcreateatestburden.

Memoryonmoderncomputersappearscheap,becauseunlikeprocessortime,youcan'tseeitbeinguseduntilyouhitthewall;butthenfailureiscatastrophic.Therearealsootherhiddencoststousingmemory,suchasyoureffectonotherprogramsthatmustberesident,andthetimetoallocateanddeallocateit.Considerthiscarefullybeforeyoutradeawayspacetogainspeed.

NextHowtoStressTest

HowtobeaProgrammer

44Intermediate

Page 45: How to Be a Programmer En

HowtoStressTestStresstestingisfun.Atfirstitappearsthatthepurposeofstresstestingistofindoutifthesystemworksunderaload.Inreality,itiscommonthatthesystemdoesworkunderaloadbutfailstoworkinsomewaywhentheloadisheavyenough.Icallthishittingthewallor

bonking[1].Theremaybesomeexceptions,butthereisalmostalwaysa‘wall’.Thepurposeofstresstestingistofigureoutwherethewallis,andthenfigureouthowtomovethewallfurtherout.

Aplanforstresstestingshouldbedevelopedearlyintheproject,becauseitoftenhelpstoclarifyexactlywhatisexpected.Istwosecondsforawebpagerequestamiserablefailureorasmashingsuccess?Is500concurrentusersenough?That,ofcourse,depends,butonemustknowtheanswerwhendesigningthesystemthatanswerstherequest.Thestresstestneedstomodelrealitywellenoughtobeuseful.Itisn'treallypossibletosimulate500erraticandunpredictablehumansusingasystemconcurrentlyveryeasily,butonecanatleastcreate500simulationsandtrytomodelsomepartofwhattheymightdo.

Instresstesting,startoutwithalightloadandloadthesystemalongsomedimension-suchasinputrateorinputsize-untilyouhitthewall.Ifthewallistooclosetosatisfyyourneeds,figureoutwhichresourceisthebottleneck(thereisusuallyadominantone.)Isitmemory,processor,I/O,networkbandwidth,ordatacontention?Thenfigureouthowyoucanmovethewall.Notethatmovingthewall,thatis,increasingthemaximumloadthesystemcanhandle,mightnothelpormightactuallyhurttheperformanceofalightlyloadedsystem.Usuallyperformanceunderheavyloadismoreimportantthanperformanceunderalightload.

Youmayhavetogetvisibilityintoseveraldifferentdimensionstobuildupamentalmodelofit;nosingletechniqueissufficient.Forinstance,loggingoftengivesagoodideaofthewall-clocktimebetweentwoeventsinthesystem,butunlesscarefullyconstructed,doesn'tgivevisibilityintomemoryutilizationorevendatastructuresize.Similarly,inamodernsystem,anumberofcomputersandmanysoftwaresystemsmaybecooperating.Particularlywhenyouarehittingthewall(thatis,theperformanceisnon-linearinthesizeoftheinput)theseothersoftwaresystemsmaybeabottleneck.Visibilityintothesesystems,evenifonlymeasuringtheprocessorloadonallparticipatingmachines,canbeveryhelpful.

Knowingwherethewallisisessentialnotonlytomovingthewall,butalsotoprovidingpredictabilitysothatthebusinesscanbemanagedeffectively.

[1]"tohit"

HowtobeaProgrammer

45Intermediate

Page 46: How to Be a Programmer En

NextHowtoBalanceBrevityandAbstraction

HowtobeaProgrammer

46Intermediate

Page 47: How to Be a Programmer En

HowtoBalanceBrevityandAbstractionAbstractioniskeytoprogramming.Youshouldcarefullychoosehowabstractyouneedtobe.Beginningprogrammersintheirenthusiasmoftencreatemoreabstractionthanisreallyuseful.Onesignofthisisifyoucreateclassesthatdon'treallycontainanycodeanddon'treallydoanythingexceptservetoabstractsomething.Theattractionofthisisunderstandablebutthevalueofcodebrevitymustbemeasuredagainstthevalueofabstraction.Occasionally,oneseesamistakemadebyenthusiasticidealists:atthestartoftheprojectalotofclassesaredefinedthatseemwonderfullyabstractandonemayspeculatethattheywillhandleeveryeventualitythatmayarise.Astheprojectprogressesandfatiguesetsin,thecodeitselfbecomesmessy.Functionbodiesbecomelongerthantheyshouldbe.Theemptyclassesareaburdentodocumentthatisignoredwhenunderpressure.Thefinalresultwouldhavebeenbetteriftheenergyspentonabstractionhadbeenspentonkeepingthingsshortandsimple.Thisisaformofspeculativeprogramming.Istronglyrecommendthearticle'SuccinctnessisPower'byPaulGraham[PGSite].

Thereisacertaindogmaassociatedwithusefultechniquessuchasinformationhidingandobjectorientedprogrammingthataresometimestakentoofar.Thesetechniquesletonecodeabstractlyandanticipatechange.Ipersonallythink,however,thatyoushouldnotproducemuchspeculativecode.Forexample,itisanacceptedstyletohideanintegervariableonanobjectbehindmutatorsandaccessors,sothatthevariableitselfisnotexposed,onlythelittleinterfacetoit.Thisdoesallowtheimplementationofthatvariabletobechangedwithoutaffectingthecallingcode,andisperhapsappropriatetoalibrarywriterwhomustpublishaverystableAPI.ButIdon'tthinkthebenefitofthisoutweighsthecostofthewordinessofitwhenmyteamownsthecallingcodeandhencecanrecodethecalleraseasilyasthecalled.Fourorfiveextralinesofcodeisaheavypricetopayforthisspeculativebenefit.

Portabilityposesasimilarproblem.Shouldcodebeportabletoadifferentcomputer,compiler,softwaresystemorplatform,orsimplyeasilyported?Ithinkanon-portable,short-and-easily-portedpieceofcodeisbetterthanalongportableone.Itisrelativelyeasyandcertainlyagoodideatoconfinenon-portablecodetodesignatedareas,suchasaclassthatmakesdatabasequeriesthatarespecifictoagivenDBMS.

NextHowtoLearnNewSkills

HowtobeaProgrammer

47Intermediate

Page 48: How to Be a Programmer En

HowtoLearnNewSkillsLearningnewskills,especiallynon-technicalones,isthegreatestfunofall.Mostcompanieswouldhavebettermoraleiftheyunderstoodhowmuchthismotivatesprogrammers.

Humanslearnbydoing.Book-readingandclass-takingareuseful.Butcouldyouhaveanyrespectforaprogrammerwhohadneverwrittenaprogram?Tolearnanyskill,youhavetoputyourselfinaforgivingpositionwhereyoucanexercisethatskill.Whenlearninganewprogramminglanguage,trytodoasmallprojectinitbeforeyouhavetodoalargeproject.Whenlearningtomanageasoftwareproject,trytomanageasmallonefirst.

Agoodmentorisnoreplacementfordoingthingsyourself,butisalotbetterthanabook.Whatcanyouofferapotentialmentorinexchangefortheirknowledge?Ataminimum,youshouldoffertostudyhardsotheirtimewon'tbewasted.

Trytogetyourbosstoletyouhaveformaltraining,butunderstandthatitisoftennotmuchbetterthanthesameamountoftimespentsimplyplayingwiththenewskillyouwanttolearn.Itis,however,easiertoaskfortrainingthanplaytimeinourimperfectworld,eventhoughalotofformaltrainingisjustsleepingthroughlectureswaitingforthedinnerparty.

Ifyouleadpeople,understandhowtheylearnandassistthembyassigningthemprojectsthataretherightsizeandthatexerciseskillstheyareinterestedin.Don'tforgetthatthemostimportantskillsforaprogrammerarenotthetechnicalones.Giveyourpeopleachancetoplayandpracticecourage,honesty,andcommunication.

NextLearntoType

HowtobeaProgrammer

48Intermediate

Page 49: How to Be a Programmer En

LearntoTypeLearntotouch-type.Thisisanintermediateskillbecausewritingcodeissohardthatthespeedatwhichyoucantypeisirrelevantandcan'tputmuchofadentinthetimeittakestowritecode,nomatterhowgoodyouare.However,bythetimeyouareanintermediateprogrammeryouwillprobablyspendalotoftimewritingnaturallanguagetoyourcolleaguesandothers.Thisisafuntestofyourcommitment;ittakesdedicatedtimethatisnotmuchfuntolearnsomethinglikethat.LegendhasitthatwhenMichaelTiemannwasatMCCpeoplewouldstandoutsidehisdoortolistentothehumgeneratedbyhiskeystrokeswhichweresorapidastobeindistinguishable.

NextHowtoDoIntegrationTesting

HowtobeaProgrammer

49Intermediate

Page 50: How to Be a Programmer En

HowtoDoIntegrationTestingIntegrationtestingisthetestingoftheintegrationofvariouscomponentsthathavebeenunittested.Integrationisexpensiveanditcomesoutinthetesting.Youmustincludetimeforthisinyourestimatesandyourschedule.

Ideallyyoushouldorganizeaprojectsothatthereisnotaphaseattheendwhereintegrationmustexplicitlytakeplace.Itisfarbettertograduallyintegratethingsastheyarecompletedoverthecourseoftheproject.Ifitisunavoidableestimateitcarefully.

NextCommunicationLanguages

HowtobeaProgrammer

50Intermediate

Page 51: How to Be a Programmer En

CommunicationLanguagesTherearesomelanguages,thatis,formallydefinedsyntacticsystems,thatarenotprogramminglanguagesbutcommunicationlanguages-theyaredesignedspecificallytofacilitatecommunicationthroughstandardization.In2003themostimportantoftheseareUML,XML,andSQL.Youshouldhavesomefamiliaritywithallofthesesothatyoucancommunicatewellanddecidewhentousethem.

UMLisarichformalsystemformakingdrawingsthatdescribedesigns.Itsbeautyliesinthatitisbothvisualandformal,capableofconveyingagreatdealofinformationifboththeauthorandtheaudienceknowUML.Youneedtoknowaboutitbecausedesignsaresometimescommunicatedinit.ThereareveryhelpfultoolsformakingUMLdrawingsthatlookveryprofessional.InalotofcasesUMListooformal,andIfindmyselfusingasimplerboxesandarrowsstylefordesigndrawings.ButI'mfairlysureUMLisatleastasgoodforyouasstudyingLatin.

XMLisastandardfordefiningnewstandards.Itisnotasolutiontodatainterchangeproblems,thoughyousometimesseeitpresentedasifitwas.Rather,itisawelcomeautomationofthemostboringpartofdatainterchange,namely,structuringtherepresentationintoalinearsequenceandparsingbackintoastructure.Itprovidessomenicetype-andcorrectness-checking,thoughagainonlyafractionofwhatyouarelikelytoneedinpractice.

SQLisaverypowerfulandrichdataqueryandmanipulationlanguagethatisnotquiteaprogramminglanguage.Ithasmanyvariations,typicallyquiteproduct-dependent,whicharelessimportantthanthestandardizedcore.SQListhelinguafrancaofrelationaldatabases.Youmayormaynotworkinanyfieldthatcanbenefitfromanunderstandingofrelationaldatabases,butyoushouldhaveabasicunderstandingofthemandthesyntaxandmeaningofSQL.

NextHeavyTools

HowtobeaProgrammer

51Intermediate

Page 52: How to Be a Programmer En

HeavyToolsAsourtechnologicalcultureprogresses,softwaretechnologymovesfrominconceivable,toresearch,tonewproducts,tostandardizedproducts,towidelyavailableandinexpensiveproducts.Theseheavytoolscanpullgreatloads,butcanbeintimidatingandrequirealargeinvestmentinunderstanding.Theintermediateprogrammerhastoknowhowtomanagethemandwhentheyshouldbeusedorconsidered.

Tomymindrightnowsomeofthebestheavytoolsare:

RelationalDatabases,Full-textSearchEngines,Mathlibraries,OpenGL,XMLparsers,andSpreadsheets.

NextHowtoanalyzedata

HowtobeaProgrammer

52Intermediate

Page 53: How to Be a Programmer En

HowtoanalyzedataDataanalysisisaprocessintheearlystagesofsoftwaredevelopment,whenyouexamineabusinessactivityandfindtherequirementstoconvertitintoasoftwareapplication.Thisisaformaldefinition,whichmayleadyoutobelievethatdataanalysisisanactionthatyoushouldbetterleavetothesystemsanalysts,whileyou,theprogrammer,shouldfocusoncodingwhatsomebodyelsehasdesigned.Ifwefollowstrictlythesoftwareengineeringparadigm,itmaybecorrect.Experiencedprogrammersbecomedesignersandthesharpestdesignersbecomebusinessanalysts,thusbeingentitledtothinkaboutallthedatarequirementsandgiveyouawelldefinedtasktocarryout.Thisisnotentirelyaccurate,becausedataisthecorevalueofeveryprogrammingactivity.Whateveryoudoinyourprograms,youareeithermovingaroundormodifyingdata.Thebusinessanalystisanalysingtheneedsinalargerscale,andthesoftwaredesignerisfurthersqueezingsuchscalesothat,whentheproblemlandsonyourdesk,itseemsthatallyouneedtodoistoapplycleveralgorithmsandstartmovingexistingdata.

Notso.

Nomatteratwhichstageyoustartlookingatit,dataisthemainconcernofawelldesignedapplication.Ifyoulookcloselyathowabusinessanalystgetstherequirementsoutofthecustomer'srequests,you'llrealizethatdataplaysafundamentalrole.TheanalystcreatessocalledDataFlowDiagrams,wherealldatasourcesareidentifiedandtheflowofinformationisshaped.Havingclearlydefinedwhichdatashouldbepartofthesystem,thedesignerwillshapeupthedatasources,intermsofdatabaserelations,dataexchangeprotocols,andfileformats,sothatthetaskisreadytobepasseddowntotheprogrammer.However,theprocessisnotoveryet,becauseyou(theprogrammer)evenafterthisthoroughprocessofdatarefinement,arerequiredtoanalyzedatatoperformthetaskinthebestpossibleway.ThebottomlineofyourtaskisthecoremessageofNiklausWirth,thefatherofseverallanguages."Algorithms+DataStructures=Programs."Thereisneveranalgorithmstandingalone,doingsomethingtoitself.Everyalgorithmissupposedtodosomethingtoatleastonepieceofdata.

Therefore,sincealgorithmsdon'tspintheirwheelsinavacuum,youneedtoanalyzeboththedatathatsomebodyelsehasidentifiedforyouandthedatathatisnecessarytowritedownyourcode.Atrivialexamplewillmakethematterclearer.Youareimplementingasearchroutineforalibrary.Accordingtoyourspecifications,theusercanselectbooksbyacombinationofgenre,author,title,publisher,printingyear,andnumberofpages.TheultimategoalofyourroutineistoproducealegalSQLstatementtosearchtheback-enddatabase.Basedontheserequirements,youhaveseveralchoices:checkeachcontrolin

HowtobeaProgrammer

53Intermediate

Page 54: How to Be a Programmer En

turn,usinga"switch"statement,orseveral"if"ones;makeanarrayofdatacontrols,checkingeachelementtoseeifitisset;create(oruse)anabstractcontrolobjectfromwhichinheritallyourspecificcontrols,andconnectthemtoanevent-drivenengine.Ifyourrequirementsincludealsotuningupthequeryperformance,bymakingsurethattheitemsarecheckedinaspecificorder,youmayconsiderusingatreeofcomponentstobuildyourSQLstatement.Asyoucansee,thechoiceofthealgorithmdependsonthedatayoudecidetouse,ortocreate.Suchdecisionscanmakeallthedifferencebetweenanefficientalgorithmandadisastrousone.However,efficiencyisnottheonlyconcern.Youmayuseadozennamedvariablesinyourcodeandmakeitasefficientasitcaneverbe.Butsuchapieceofcodemightnotbeeasilymaintainable.Perhapschoosinganappropriatecontainerforyourvariablescouldkeepthesamespeedandinadditionallowyourcolleaguestounderstandthecodebetterwhentheylookatitnextyear.Furthermore,choosingawelldefineddatastructuremayallowthemtoextendthefunctionalityofyourcodewithoutrewritingit.Inthelongrun,yourchoicesofdatadetermineshowlongyourcodewillsurviveafteryouarefinishedwithit.Letmegiveyouanotherexample,justsomemorefoodforthought.Let'ssupposethatyourtaskistofindallthewordsinadictionarywithmorethanthreeanagrams,whereananagrammustbeanotherwordinthesamedictionary.Ifyouthinkofitasacomputationaltask,youwillendupwithanendlesseffort,tryingtoworkoutallthecombinationsofeachwordandthencomparingittotheotherwordsinthelist.However,ifyouanalyzethedataathand,you'llrealizethateachwordmayberepresentedbyarecordcontainingtheworditselfandasortedarrayofitslettersasID.Armedwithsuchknowledge,findinganagramsmeansjustsortingthelistontheadditionalfieldandpickinguptheonesthatsharethesameID.Thebruteforcealgorithmmaytakeseveraldaystorun,whilethesmartoneisjustamatterofafewseconds.Rememberthisexamplethenexttimeyouarefacinganintractableproblem.

NextTeamSkills-HowtoManageDevelopmentTime

HowtobeaProgrammer

54Intermediate

Page 55: How to Be a Programmer En

HowtoManageDevelopmentTimeTomanagedevelopmenttime,maintainaconciseandup-to-dateprojectplan.Aprojectplanisanestimate,aschedule,asetofmilestonesformarkingprogress,andanassignmentofyourteamoryourowntimetoeachtaskontheestimate.Itshouldalsoincludeotherthingsyouhavetoremembertodo,suchasmeetingwiththequalityassurancepeople,preparingdocumentation,ororderingequipment.Ifyouareonateam,theprojectplanshouldbeaconsensualagreement,bothatthestartandasyougo.

Theprojectplanexiststohelpmakedecisions,nottoshowhoworganizedyouare.Iftheprojectplaniseithertoolongornotup-to-date,itwillbeuselessformakingdecisions.Inreality,thesedecisionsareaboutindividualpersons.Theplanandyourjudgementletyoudecideifyoushouldshifttasksfromonepersontoanother.Themilestonesmarkyourprogress.Ifyouuseafancyprojectplanningtool,donotbeseducedintocreatingaBigDesignUpFront(BDUF)fortheproject,butuseittomaintainconcisionandup-to-dateness.

Ifyoumissamilestone,youshouldtakeimmediateactionsuchasinformingyourbossthatthescheduledcompletionofthatprojecthasslippedbythatamount.Theestimateandschedulecouldneverhavebeenperfecttobeginwith;thiscreatestheillusionthatyoumightbeabletomakeupthedaysyoumissedinthelatterpartoftheproject.Youmight.Butitisjustaslikelythatyouhaveunderestimatedthatpartasthatyouhaveoverestimatedit.Thereforethescheduledcompletionoftheprojecthasalreadyslipped,whetheryoulikeitornot.

Makesureyourplanincludestimefor:internalteammeetings,demos,documentation,scheduledperiodicactivities,integrationtesting,dealingwithoutsiders,sickness,vacations,maintenanceofexistingproducts,andmaintenanceofthedevelopmentenvironment.Theprojectplancanserveasawaytogiveoutsidersoryourbossaviewintowhatyouoryourteamisdoing.Forthisreasonitshouldbeshortandup-to-date.

NextHowtoManageThird-PartySoftwareRisks

HowtobeaProgrammer

55Intermediate

Page 56: How to Be a Programmer En

HowtoManageThird-PartySoftwareRisksAprojectoftendependsonsoftwareproducedbyorganizationsthatitdoesnotcontrol.Therearegreatrisksassociatedwiththirdpartysoftwarethatmustberecognizedbyeveryoneinvolved.

Never,ever,restanyhopesonvapour.Vapourisanyallegedsoftwarethathasbeenpromisedbutisnotyetavailable.Thisisthesurestwaytogooutofbusiness.Itisunwisetobemerelyscepticalofasoftwarecompany'spromisetoreleaseacertainproductwithacertainfeatureatacertaindate;itisfarwisertoignoreitcompletelyandforgetyoueverheardit.Neverletitbewrittendowninanydocumentsusedbyyourcompany.

Ifthird-partysoftwareisnotvapour,itisstillrisky,butatleastitisariskthatcanbetackled.Ifyouareconsideringusingthird-partysoftware,youshoulddevoteenergyearlyontoevaluatingit.Peoplemightnotliketohearthatitwilltaketwoweeksortwomonthstoevaluateeachofthreeproductsforsuitability,butithastobedoneasearlyaspossible.Thecostofintegratingcannotbeaccuratelyestimatedwithoutaproperevaluation.

Understandingthesuitabilityofexistingthirdpartysoftwareforaparticularpurposeisverytribalknowledge.Itisverysubjectiveandgenerallyresidesinexperts.Youcansavealotoftimeifyoucanfindthoseexperts.Oftentimesaprojectwilldependonathird-partysoftwaresystemsocompletelythatiftheintegrationfailstheprojectwillfail.Expressriskslikethatclearlyinwritingintheschedule.Trytohaveacontingencyplan,suchasanothersystemthatcanbeusedortheabilitytowritethefunctionalityyourselfiftheriskcan'tberemovedearly.Neverletascheduledependonvapour.

NextHowtoManageConsultants

HowtobeaProgrammer

56Intermediate

Page 57: How to Be a Programmer En

HowtoManageConsultantsUseconsultants,butdon'trelyonthem.Theyarewonderfulpeopleanddeserveagreatdealofrespect.Sincetheygettoseealotofdifferentprojects,theyoftenknowmoreaboutspecifictechnologiesandevenprogrammingtechniquesthanyouwill.Thebestwaytousethemisaseducatorsin-housethatcanteachbyexample.

However,theyusuallycannotbecomepartoftheteaminthesamesensethatregularemployeesare,ifonlybecauseyoumaynothaveenoughtimetolearntheirstrengthsandweaknesses.Theirfinancialcommitmentismuchlower.Theycanmovemoreeasily.Theymayhavelesstogainifthecompanydoeswell.Somewillbegood,somewillbeaverage,andsomewillbebad,buthopefullyyourselectionofconsultantswillnotbeascarefulasyourselectionofemployees,soyouwillgetmorebadones.

Ifconsultantsaregoingtowritecode,youmustreviewitcarefullyasyougoalong.Youcannotgettotheendoftheaprojectwiththeriskofalargeblockofcodethathasnotbeenreviewed.Thisistrueofallteammembers,really,butyouwillusuallyhavemoreknowledgeoftheteammembersclosertoyou.

NextHowtoCommunicatetheRightAmount

HowtobeaProgrammer

57Intermediate

Page 58: How to Be a Programmer En

HowtoCommunicatetheRightAmountCarefullyconsiderthecostofameeting;itcostsitsdurationmultipliedbythenumberofparticipants.Meetingsaresometimesnecessary,butsmallerisusuallybetter.Thequalityofcommunicationinsmallmeetingsisbetter,andlesstimeoveralliswasted.Ifanyonepersonisboredatameetingtakethisasasignthatthemeetingshouldbesmaller.

Everythingpossibleshouldbedonetoencourageinformalcommunication.Moreusefulworkisdoneduringluncheswithcolleaguesthanduringanyothertime.Itisashamethatmorecompaniesdonotrecognizenorsupportthisfact.

NextHowtoDisagreeHonestlyandGetAwaywithIt

HowtobeaProgrammer

58Intermediate

Page 59: How to Be a Programmer En

HowtoDisagreeHonestlyandGetAwaywithItDisagreementisagreatopportunitytomakeagooddecision,butitshouldbehandleddelicately.Hopefullyyoufeelthatyouhaveexpressedyourthoughtsadequatelyandbeenheardbeforethedecisionismade.Inthatcasethereisnothingmoretosay,andyoushoulddecidewhetheryouwillstandbehindthedecisioneventhoughyoudisagreewithit.Ifyoucansupportthisdecisioneventhoughyoudisagree,sayso.Thisshowshowvaluableyouarebecauseyouareindependentandarenotayes-man,butrespectfulofthedecisionandateamplayer.

Sometimesadecisionthatyoudisagreewithwillbemadewhenthedecisionmakersdidnothavethefullbenefitofyouropinion.Youshouldthenevaluatewhethertoraisetheissueonthebasisofthebenefittothecompanyortribe.Ifitisasmallmistakeinyouropinion,itmaynotbeworthreconsidering.Ifitisalargemistakeinyouropinion,thenofcourseyoumustpresentanargument.

Usually,thisisnotaproblem.Insomestressfulcircumstancesandwithsomepersonalitytypesthiscanleadtothingsbeingtakenpersonally.Forinstance,someverygoodprogrammerslacktheconfidenceneededtochallengeadecisionevenwhentheyhavegoodreasontobelieveitiswrong.Intheworstofcircumstancesthedecisionmakerisinsecureandtakesitasapersonalchallengetotheirauthority.Itisbesttorememberthatinsuchcircumstancespeoplereactwiththereptilianpartoftheirbrains.Youshouldpresentyourargumentinprivate,andtrytoshowhownewknowledgechangesthebasisonwhichthedecisionwasmade.

Whetherthedecisionisreversedornot,youmustrememberthatyouwillneverbeabletosay‘Itoldyouso!’sincethealternatedecisionwasfullyexplored.

NextJudgment-HowtoTradeoffQualityAgainstDevelopmentTime

HowtobeaProgrammer

59Intermediate

Page 60: How to Be a Programmer En

HowtoTradeoffQualityAgainstDevelopmentTimeSoftwaredevelopmentisalwaysacompromisebetweenwhattheprojectdoesandgettingtheprojectdone.Butyoumaybeaskedtotradeoffqualitytospeedthedeploymentofaprojectinawaythatoffendsyourengineeringsensibilitiesorbusinesssensibilities.Forexample,youmaybeaskedtodosomethingthatisapoorsoftwareengineeringpracticeandthatwillleadtoalotofmaintenanceproblems.

Ifthishappensyourfirstresponsibilityistoinformyourteamandtoclearlyexplainthecostofthedecreaseinquality.Afterall,yourunderstandingofitshouldbemuchbetterthanyourboss'sunderstanding.Makeitclearwhatisbeinglostandwhatisbeinggained,andatwhatcostthelostgroundwillberegainedinthenextcycle.Inthis,thevisibilityprovidedbyagoodprojectplanshouldbehelpful.Ifthequalitytradeoffaffectsthequalityassuranceeffort,pointthatout(bothtoyourbossandqualityassurancepeople).Ifthequalitytradeoffwillleadtomorebugsbeingreportedafterthequalityassuranceperiod,pointthatout.

Ifshestillinsists,youshouldtrytoisolatetheshoddinessintoparticularcomponentsthatyoucanplantorewriteorimproveinthenextcycle.Explainthistoyourteamsothattheycanplanforit.

NinjaProgrammeratSlashdotsentinthisgem:

Rememberthatagooddesignwillberesilientagainstpoorcodeimplementations.Ifgoodinterfacesandabstractionsexistthroughoutthecode,thentheeventualrewriteswillbefarmorepainless.Ifitishardtowriteclearcodethatishardtofix,considerwhatiswrongwiththecoredesignthatiscausingthis.

NextHowtoManageSoftwareDependence

HowtobeaProgrammer

60Intermediate

Page 61: How to Be a Programmer En

HowtoManageSoftwareSystemDependenceModernsoftwaresystemstendtodependonalargenumberofcomponentsthatmaynotbedirectlyunderyourcontrol.Thisincreasesproductivitythroughsynergyandreuse.However,eachcomponentbringswithitsomeproblems:

Howwillyoufixbugsinthecomponent?Doesthecomponentrestrictyoutoparticularhardwareorsoftwaresystems?Whatwillyoudoifthecomponentfailscompletely?

Itisalwaysbesttoencapsulatethecomponentinsomewaysothatitisisolatedandsothatitcanbeswappedout.Ifthecomponentprovestobecompletelyunworkable,youmaybeabletogetadifferentone,butyoumayhavetowriteyourown.Encapsulationisnotportability,butitmakesportingeasier,whichisalmostasgood.

Havingthesourcecodeforacomponentdecreasestheriskbyafactoroffour.Withsourcecode,youcanevaluateiteasier,debugiteasier,findworkaroundseasier,andmakefixeseasier.Ifyoumakefixes,youshouldgivethemtotheownerofthecomponentandgetthefixesincorporatedintoanofficialrelease;otherwiseyouwilluncomfortablyhavetomaintainanunofficialversion.

NextHowtoDecideifSoftwareisTooImmature

HowtobeaProgrammer

61Intermediate

Page 62: How to Be a Programmer En

HowtoDecideifSoftwareisTooImmatureUsingsoftwareotherpeoplewroteisoneofthemosteffectivewaystoquicklybuildasolidsystem.Itshouldnotbediscouraged,buttherisksassociatedwithitmustbeexamined.Oneofthebiggestrisksistheperiodofbugginessandnearinoperabilitythatisoftenassociatedwithsoftwarebeforeitmatures,throughusage,intoausableproduct.Beforeyouconsiderintegratingwithasoftwaresystem,whethercreatedinhouseorbyathirdparty,itisveryimportanttoconsiderifitisreallymatureenoughtobeused.Herearetenquestionsyoushouldaskyourselfaboutit:

1. Isitvapour?(Promisesareveryimmature).2. Isthereanaccessiblebodyofloreaboutthesoftware?3. Areyouthefirstuser?4. Isthereastrongincentiveforcontinuation?5. Hasithadamaintenanceeffort?6. Willitsurvivedefectionofthecurrentmaintainers?7. Isthereaseasonedalternativeatleasthalfasgood?8. Isitknowntoyourtribeorcompany?9. Isitdesirabletoyourtribeorcompany?10. Canyouhirepeopletoworkonitevenifitisbad?

Alittleconsiderationofthesecriteriademonstratesthegreatvalueofwell-establishedfreesoftwareandopen-sourcesoftwareinreducingrisktotheentrepreneur.

NextHowtoMakeaBuyvs.BuildDecision

HowtobeaProgrammer

62Intermediate

Page 63: How to Be a Programmer En

HowtoMakeaBuyvs.BuildDecisionAnentrepreneurialcompanyorprojectthatistryingtoaccomplishsomethingwithsoftwarehastoconstantlymakeso-calledbuyvs.builddecisions.Thisturnofphraseisunfortunateintwoways:itseemstoignoreopen-sourceandfreesoftwarewhichisnotnecessarilybought.Evenmoreimportantly,itshouldperhapsbecalledanobtainandintegratevs.buildhereandintegratedecisionbecausethecostofintegrationmustbeconsidered.Thisrequiresagreatcombinationofbusiness,management,andengineeringsavvy.

Howwelldoyourneedsmatchthoseforwhichitwasdesigned?Whatportionofwhatyoubuywillyouneed?Whatisthecostofevaluatingtheintegration?Whatisthecostofintegration?Willbuyingincreaseordecreaselongtermmaintenancecosts?Willbuildingitputyouinabusinesspositionyoudon'twanttobein?

Youshouldthinktwicebeforebuildingsomethingthatisbigenoughtoserveasthebasisforanentireotherbusiness.Suchideasareoftenproposedbybrightandoptimisticpeoplethatwillhavealottocontributetoyourteam.Iftheirideaiscompelling,youmaywishtochangeyourbusinessplan;butdonotinvestinasolutionbiggerthanyourownbusinesswithoutconsciousthought.

Afterconsideringthesequestions,youshouldperhapspreparetwodraftprojectplans,oneforbuildingandoneforbuying.Thiswillforceyoutoconsidertheintegrationcosts.Youshouldalsoconsiderthelongtermmaintenancecostsofbothsolutions.Toestimatetheintegrationcosts,youwillhavetodoathoroughevaluationofthesoftwarebeforeyoubuyit.Ifyoucan'tevaluateit,youwillassumeanunreasonableriskinbuyingitandyoushoulddecideagainstbuyingthatparticularproduct.Ifthereareseveralbuydecisionsunderconsideration,someenergywillhavetobespentevaluatingeach.

NextHowtoGrowProfessionally

HowtobeaProgrammer

63Intermediate

Page 64: How to Be a Programmer En

HowtoGrowProfessionallyAssumeresponsibilityinexcessofyourauthority.Playtherolethatyoudesire.Expressappreciationforpeople'scontributiontothesuccessofthelargerorganization,aswellasthingsasthathelpyoupersonally.

Ifyouwanttobecomeateamleader,instigatetheformationofconsensus.Ifyouwanttobecomeamanager,takeresponsibilityfortheschedule.Youcanusuallydothiscomfortablywhileworkingwithaleaderoramanager,sincethisfreesthemuptotakegreaterresponsibility.Ifthatistoomuchtotry,doitalittleatatime.

Evaluateyourself.Ifyouwanttobecomeabetterprogrammer,asksomeoneyouadmirehowyoucanbecomelikethem.Youcanalsoaskyourboss,whowillknowlessbuthaveagreaterimpactonyourcareer.

Planwaystolearnnewskills,boththetrivialtechnicalkind,likelearninganewsoftwaresystem,andthehardsocialkind,likewritingwell,byintegratingthemintoyourwork.

NextHowtoEvaluateInterviewees

HowtobeaProgrammer

64Intermediate

Page 65: How to Be a Programmer En

HowtoEvaluateIntervieweesEvaluatingpotentialemployeesisnotgiventheenergyitdeserves.Abadhire,likeabadmarriage,isterrible.Asignificantportionofeveryone'senergyshouldbedevotedtorecruitment,thoughthisisrarelydone.

Therearedifferentinterviewingstyles.Somearetorturous,designedtoputthecandidateunderagreatdealofstress.Thisservesaveryvaluablepurposeofpossiblyrevealingcharacterflawsandweaknessesunderstress.Candidatesarenomorehonestwithinterviewersthantheyarewiththemselves,andthehumancapacityforself-deceptionisastonishing.

Youshould,ataminimum,givethecandidatetheequivalentofanoralexaminationonthetechnicalskillsfortwohours.Withpractice,youwillbeabletoquicklycoverwhattheyknowandquicklyretractfromwhattheydon'tknowtomarkouttheboundary.Intervieweeswillrespectthis.Ihaveseveraltimesheardintervieweessaythatthequalityoftheexaminationwasoneoftheirmotivationsforchoosingacompany.Goodpeoplewanttobehiredfortheirskills,notwheretheyworkedlastorwhatschooltheywenttoorsomeotherinessentialcharacteristic.

Indoingthis,youshouldalsoevaluatetheirabilitytolearn,whichisfarmoreimportantthanwhattheyknow.Youshouldalsowatchforthewhiffofbrimstonethatisgivenoffbydifficultpeople.Youmaybeabletorecognizeitbycomparingnotesaftertheinterview,butintheheatoftheinterviewitishardtorecognize.Howwellpeoplecommunicateandworkwithpeopleismoreimportantthanbeinguponthelatestprogramminglanguage.

Areaderhashadgoodluckusinga‘take-home’testforinterviewees.Thishastheadvantagethatcanuncovertheintervieweethatcanpresentthemselveswellbutcan'treallycode-andtherearemanysuchpeople.Ipersonallyhavenottriedthistechnique,butitsoundssensible.

Finally,interviewingisalsoaprocessofselling.Youshouldbesellingyourcompanyorprojecttothecandidate.However,youaretalkingtoaprogrammer,sodon'ttrytocolourthetruth.Startoffwiththebadstuff,thenfinishstrongwiththegoodstuff.

NextHowtoKnowWhentoApplyFancyComputerScience

HowtobeaProgrammer

65Intermediate

Page 66: How to Be a Programmer En

HowtoKnowWhentoApplyFancyComputerScienceThereisabodyofknowledgeaboutalgorithms,datastructures,mathematics,andothergee-whizstuffthatmostprogrammersknowaboutbutrarelyuse.Inpractice,thiswonderfulstuffistoocomplicatedandgenerallyunnecessary.Thereisnopointinimprovinganalgorithmwhenmostofyourtimeisspentmakinginefficientdatabasecalls,forinstance.Anunfortunateamountofprogrammingconsistsofgettingsystemstotalktoeachotherandusingverysimpledatastructurestobuildaniceuserinterface.

Whenishightechnologytheappropriatetechnology?Whenshouldyoucrackabooktogetsomethingotherthanarun-of-the-millalgorithm?Itissometimesusefultodothisbutitshouldbeevaluatedcarefully.

Thethreemostimportantconsiderationsforthepotentialcomputersciencetechniqueare:

Isitwellencapsulatedsothattherisktoothersystemsislowandtheoverallincreaseincomplexityandmaintenancecostislow?Isthebenefitstartling(forexample,afactoroftwoinamaturesystemorafactorofteninanewsystem)?Willyoubeabletotestandevaluateiteffectively?

Ifawell-isolatedalgorithmthatusesaslightlyfancyalgorithmcandecreasehardwarecostorincreaseperformancebyafactoroftwoacrossanentiresystem,thenitwouldbecriminalnottoconsiderit.Oneofthekeystoarguingforsuchanapproachistoshowthattheriskisreallyquitelow,sincetheproposedtechnologyhasprobablybeenwellstudied,theonlyissueistheriskofintegration.Hereaprogrammer'sexperienceandjudgementcantrulysynergizewiththefancytechnologytomakeintegrationeasy.

NextHowtoTalktoNon-Engineers

HowtobeaProgrammer

66Intermediate

Page 67: How to Be a Programmer En

HowtoTalktoNon-EngineersEngineersandprogrammersinparticulararegenerallyrecognizedbypopularcultureasbeingdifferentfromotherpeople.Thisimpliesthatotherpeoplearedifferentfromus.Thisisworthbearinginmindwhencommunicatingwithnon-engineers;youshouldalwaysunderstandtheaudience.

Non-engineersaresmart,butnotasgroundedincreatingtechnicalthingsasweare.Wemakethings.Theysellthingsandhandlethingsandcountthingsandmanagethings,buttheyarenotexpertsonmakingthings.Theyarenotasgoodatworkingtogetheronteamsasengineersare(therearenodoubtexceptions.)Theirsocialskillsaregenerallyasgoodasorbetterthanengineersinnon-teamenvironments,buttheirworkdoesnotalwaysdemandthattheypracticethekindofintimate,precisecommunicationandcarefulsubdivisionsoftasksthatwedo.

Non-engineersmaybetooeagertopleaseandtheymaybeintimidatedbyyou.Justlikeus,theymaysay‘yes’withoutreallymeaningittopleaseyouorbecausetheyarealittlescaredofyou,andthennotstandbehindtheirwords.

Non-programmerscanunderstandtechnicalthingsbuttheydonothavethethingthatissohardevenforus-technicaljudgement.Theydounderstandhowtechnologyworks,buttheycannotunderstandwhyacertainapproachwouldtakethreemonthsandanotheronethreedays.(Afterall,programmersareanecdotallyhorribleatthiskindofestimationaswell.)Thisrepresentsagreatopportunitytosynergizewiththem.

Whentalkingtoyourteamyouwill,withoutthinking,useasortofshorthand,anabbreviatedlanguagethatiseffectivebecauseyouwillhavemuchsharedexperienceabouttechnologyingeneralandyourproductinparticular.Ittakessomeeffortnottousethisshorthandwiththosethatdon'thavethatsharedexperience,especiallywhenmembersofyourownteamarepresent.Thisvocabularycreateawallbetweenyouandthosethatdonotshareit,and,evenworse,wastestheirtime.

Withyourteam,thebasicassumptionsandgoalsdonotneedtoberestatedoften,andmostconversationfocusesonthedetails.Withoutsiders,itmustbetheotherwayaround.Theymaynotunderstandthingsyoutakeforgranted.Sinceyoutakethemforgrantedanddon'trepeatthem,youcanleaveaconversationwithanoutsiderthinkingthatyouunderstandeachotherwhenreallythereisalargemisunderstanding.Youshouldassumethatyouwillmiscommunicateandwatchcarefullytofindthismiscommunication.Trytogetthemtosummarizeorparaphrasewhatyouaresayingtomakesuretheyunderstand.Ifyouhave

HowtobeaProgrammer

67Intermediate

Page 68: How to Be a Programmer En

theopportunitytomeetwiththemoften,spendalittlebitoftimeaskingifyouarecommunicatingeffectively,andhowyoucandoitbetter.Ifthereisaproblemincommunication,seektoalteryourownpracticesbeforebecomingfrustratedwiththeirs.

Iloveworkingwithnon-engineers.Itprovidesgreatopportunitiestolearnandtoteach.Youcanoftenleadbyexample,intermsoftheclarityofyourcommunication.Engineersaretrainedtobringorderoutofchaos,tobringclarityoutofconfusion,andnon-engineerslikethisaboutus.Becausewehavetechnicaljudgementandcanusuallyunderstandbusinessissues,wecanoftenfindasimplesolutiontoaproblem.

Oftennon-engineersproposesolutionsthattheythinkwillmakeiteasieronusoutofkindnessandadesiretodotherightthing,wheninfactamuchbetteroverallsolutionexistswhichcanonlybeseenbysynergizingtheoutsidersviewwithyourtechnicaljudgement.IpersonallylikeExtremeProgrammingbecauseitaddressesthisinefficiency;bymarryingtheestimationquicklytotheidea,itmakesiteasiertofindtheideathatisthebestcombinationofcostandbenefit.

NextAdvancedskills

HowtobeaProgrammer

68Intermediate

Page 69: How to Be a Programmer En

3.AdvancedTechnologicalJudgment

HowtoTelltheHardFromtheImpossibleHowtoUtilizeEmbeddedLanguagesChoosingLanguages

CompromisingWiselyHowtoFightSchedulePressureHowtoUnderstandtheUserHowtoGetaPromotion

ServingYourTeamHowtoDevelopTalentHowtoChooseWhattoWorkOnHowtoGettheMostFromYourTeam-matesHowtoDivideProblemsUpHowtoHandleBoringTasksHowtoGatherSupportforaProjectHowtoGrowaSystemHowtoCommunicateWellHowtoTellPeopleThingsTheyDon'tWanttoHearHowtoDealwithManagerialMythsHowtoDealwithOrganizationalChaos

HowtobeaProgrammer

69Advanced

Page 70: How to Be a Programmer En

HowtoTelltheHardFromtheImpossibleItisourjobtodothehardanddiscerntheimpossible.Fromthepointofviewofmostworkingprogrammers,somethingisimpossibleifeitheritcannotbegrownfromasimplesystemoritcannotbeestimated.Bythisdefinitionwhatiscalledresearchisimpossible.Alargevolumeofmereworkishard,butnotnecessarilyimpossible.

Thedistinctionisnotfacetiousbecauseyoumayverywellbeaskedtodowhatispracticallyimpossible,eitherfromascientificpointofvieworasoftwareengineeringpointofview.Itthenbecomesyourjobtohelptheentrepreneurfindareasonablesolutionwhichismerelyhardandgetsmostofwhattheywanted.Asolutionismerelyhardwhenitcanbeconfidentlyscheduledandtherisksareunderstood.

Itisimpossibletosatisfyavaguerequirement,suchas‘Buildasystemthatwillcomputethemostattractivehairstyleandcolourforanyperson.’Iftherequirementcanbemademorecrisp,itwilloftenbecomemerelyhard,suchas‘Buildasystemtocomputeanattractivehairstyleandcolourforaperson,allowthemtopreviewitandmakechanges,andhavethecustomersatisfactionbasedontheoriginalstylingbesogreatthatwemakealotofmoney.’Ifthereisnotcrispdefinitionofsuccess,youwillnotsucceed.

NextHowtoUtilizeEmbeddedLanguages

HowtobeaProgrammer

70Advanced

Page 71: How to Be a Programmer En

HowtoUtilizeEmbeddedLanguagesEmbeddingaprogramminglanguageintoasystemhasanalmosteroticfascinationtoaprogrammer.Itisoneofthemostcreativeactsthatcanbeperformed.Itmakesthesystemtremendouslypowerful.ItallowsyoutoexercisehermostcreativeandPrometheanskills.Itmakesthesystemintoyourfriend.

Thebesttexteditorsintheworldallhaveembeddedlanguages.Thiscanbeusedtotheextentthattheintendedaudiencecanmasterthelanguage.Ofcourse,useofthelanguagecanbemadeoptional,asitisintexteditors,sothatinitiatescanuseitandnooneelsehasto.

Iandmanyotherprogrammershavefallenintothetrapofcreatingspecialpurposeembeddedlanguages.Ifellintoittwice.Therealreadyexistmanylanguagesdesignedspecificallytobeembeddedlanguages.Youshouldthinktwicebeforecreatinganewone.

Therealquestiontoaskoneselfbeforeembeddingalanguageis:Doesthisworkwithoragainstthecultureofmyaudience?Ifyouintendedaudienceisexclusivelynon-programmers,howwillithelp?Ifyourintendedaudienceisexclusivelyprogrammers,wouldtheypreferanapplicationsprogrammersinterface(API)?Andwhatlanguagewillitbe?Programmersdon'twanttolearnanewlanguagethatisnarrowlyused;butifitmesheswiththeirculturetheywillnothavetospendmuchtimelearningit.Itisajoytocreateanewlanguage.Butweshouldnotletthatblindustotheneedsoftheuser.Unlessyouhavesometrulyoriginalneedsandideas,whynotuseanexistinglanguagesothatyoucanleveragethefamiliarityusersalreadyhavewithit?

NextChoosingLanguages

HowtobeaProgrammer

71Advanced

Page 72: How to Be a Programmer En

ChoosingLanguagesThesolitaryprogrammerthatloveshiswork(ahacker)canchoosethebestlanguageforthetask.Mostworkingprogrammershaveverylittlecontrolofthelanguagetheywilluse.Generally,thisissueisdictatedbypointy-hairedbosseswhoaremakingapoliticaldecision,ratherthanatechnologicaldecision,andlackthecouragetopromoteanunconventionaltoolevenwhentheyknow,oftenwithfirst-handknowledge,thatthelessacceptedtoolisbest.Inothercasestheveryrealbenefitofunityamongtheteam,andtosomeextentwithalargercommunity,precludeschoiceonthepartoftheindividual.Oftenmanagersaredrivenbytheneedtobeabletohireprogrammerswithexperienceinagivenlanguage.Nodoubttheyareservingwhattheyperceivetobethebestinterestsoftheprojectorcompany,andmustberespectedforthat.However,Ipersonallybelievethisisthemostwastefulanderroneouscommonpracticeyouarelikelytoencounter.

Butofcourse,thingsareneverone-dimensional.Evenifacorelanguageismandatedandbeyondyourcontrol,itisoftenthecasethattoolsandotherprogramscanandshouldbewritteninadifferentlanguage.Ifalanguageistobeembedded(andyoushouldalwaysconsiderit!)thechoiceoflanguagewilldependalotonthecultureoftheusers.Oneshouldtakeadvantageofthistoserveyourcompanyorprojectbyusingthebestlanguageforthejob,andinsodoingmakeworkmoreinteresting.

Programminglanguagesshouldreallybecallednotationsinthatlearningoneisnotatallasdifficultaslearninganaturallanguage.Tobeginnersandtosomeoutsiders'learninganewlanguage'seemsadauntingtask;butafteryouhavethreeunderyourbeltit'sreallyjustaquestionofbecomingfamiliarwiththeavailablelibraries.Onetendstothinkofalargesystemthathascomponentsinthreeorfourlanguagesasamessyhodgepodge;butIarguethatsuchasystemisinmanycasesstrongerthanaone-languagesysteminseveralways:

Thereisnecessarilyloosecouplingbetweenthecomponentsthatarewrittenindifferentnotations(thoughmaybenotcleaninterfaces),Youcanevolvetoanewlanguage/platformeasilybyrewritingeachcomponentindividually,Onelanguagemaynotbeagoodfitfortheoverallsystem-havingmultiplelanguagesforyourmodulesallowsyoutopicktherighttoolforthejob.

Someoftheseeffectsmayonlybepsychological;butpsychologymatters.Intheendthecostsoflanguagetyrannyoutweighanyadvantagethatitprovides.

NextCompromisingWisely-HowtoFightaSchedulePressure

HowtobeaProgrammer

72Advanced

Page 73: How to Be a Programmer En

HowtoFightSchedulePressureTime-to-marketpressureisthepressuretodeliveragoodproductquickly.Itisgoodbecauseitreflectsafinancialreality,andishealthyuptoapoint.Schedulepressureisthepressuretodeliversomethingfasterthanitcanbedeliveredanditiswasteful,unhealthy,andalltoocommon.

Schedulepressureexistsforseveralreasons.Thepeoplewhotaskprogrammersdonotfullyappreciatewhatastrongworkethicwehaveandhowmuchfunitistobeaprogrammer.Perhapsbecausetheyprojecttheirownbehaviourontous,theybelievethataskingforitsoonerwillmakeusworkhardertogetittheresooner.Thisisprobablyactuallytrue,buttheeffectisverysmall,andthedamageisverygreat.Additionally,theyhavenovisibilityintowhatitreallytakestoproducesoftware.Notbeingabletoseeit,andnotbeabletocreateitthemselves,theonlythingtheycandoisseetime-to-marketpressureandfussatprogrammersaboutit.

Thekeytofightingschedulepressureissimplytoturnitintotime-to-marketpressure.Thewaytodothistogivevisibilityintotherelationshipbetweentheavailablelabourandtheproduct.Producinganhonest,detailed,andmostofall,understandableestimateofallthelabourinvolvedisthebestwaytodothis.Ithastheaddedadvantageofallowinggoodmanagementdecisionstobemadeaboutpossiblefunctionalitytrade-offs.

Thekeyinsightthattheestimatemustmakeplainisthatlabourisanalmostincompressiblefluid.Youcan'tpackmoreintoaspanoftimeanymorethanyoucanpackmorewaterintoacontaineroverandabovethatcontainer'svolume.Inasense,aprogrammershouldneversay‘no’,butrathertosay‘Whatwillyougiveuptogetthatthingyouwant?’Theeffectofproducingclearestimateswillbetoincreasetherespectforprogrammers.Thisishowotherprofessionalsbehave.Programmers'hardworkwillbevisible.Settinganunrealisticschedulewillalsobepainfullyobvioustoeveryone.Programmerscannotbehoodwinked.Itisdisrespectfulanddemoralizingtoaskthemtodosomethingunrealistic.ExtremeProgrammingamplifiesthisandbuildsaprocessaroundit;Ihopethateveryreaderwillbeluckyenoughtouseit.

NextHowtoUnderstandtheUser

HowtobeaProgrammer

73Advanced

Page 74: How to Be a Programmer En

HowtoUnderstandtheUserItisyourdutytounderstandtheuser,andtohelpyourbossunderstandtheuser.Becausetheuserisnotasintimatelyinvolvedinthecreationofyourproductasyouare,theybehavealittledifferently:

Theusergenerallymakesshortpronouncements.Theuserhastheirownjob;theywillmainlythinkofsmallimprovementsinyourproduct,notbigimprovements.Theusercan'thaveavisionthatrepresentsthecompletebodyofyourproductusers.

Itisyourdutytogivethemwhattheyreallywant,notwhattheysaytheywant.Itishowever,bettertoproposeittothemandgetthemtoagreethatyourproposaliswhattheyreallywantbeforeyoubegin,buttheymaynothavethevisiontodothis.Yourconfidenceinyourownideasaboutthisshouldvary.Youmustguardagainstbotharroganceandfalsemodestyintermsofknowingwhatthecustomerreallywants.Programmersaretrainedtodesignandcreate.Marketresearchersaretrainedtofigureoutwhatpeoplewant.Thesetwokindsofpeople,ortwomodesofthoughtinthesameperson,workingharmoniouslytogethergivethebestchanceofformulatingthecorrectvision.

Themoretimeyouspendwithusersthebetteryouwillbeabletounderstandwhatwillreallybesuccessful.Youshouldtrytotestyourideasagainstthemasmuchasyoucan.Youshouldeatanddrinkwiththemifyoucan.

GuyKawasaki[Rules]hasemphasizedtheimportanceofwatchingwhatyourusersdoinadditiontolisteningtothem.

Ibelievecontractorsandconsultantsoftenhavetremendousproblemsgettingtheirclientstoclarifyintheirownmindswhattheyreallywant.Ifyouintendtobeaconsultant,Isuggestyouchooseyourclientsbasedontheirclear-headednessaswellastheirpocketbooks.

NextHowtoGetaPromotion

HowtobeaProgrammer

74Advanced

Page 75: How to Be a Programmer En

HowtoGetaPromotionTobepromotedtoarole,actoutthatrolefirst.

Togetpromotedtoatitle,findoutwhatisexpectedofthattitleanddothat.

Togetapayraise,negotiatearmedwithinformation.

Ifyoufeellikeyouarepastdueforapromotion,talktoyourbossaboutit.Askthemexplicitlywhatyouneedtodotogetpromoted,andtrytodoit.Thissoundstrite,butoftentimesyourperceptionofwhatyouneedtodowilldifferconsiderablyfromyourboss's.Alsothiswillpinyourbossdowninsomeways.

Mostprogrammersprobablyhaveanexaggeratedsenseoftheirrelativeabilitiesinsomeways---afterall,wecan'tallbeinthetop10%!However,Ihaveseensomepeoplewhowereseriouslyunappreciated.Onecannotexpecteveryone'sevaluationtoperfectlymatchrealityatalltimes,butIthinkpeoplearegenerallymoderatelyfair,withonecaveat:youcannotbeappreciatedwithoutvisibilityintoyourwork.Sometimes,duetohappenstanceorpersonalhabits,someonewillnotbenoticedmuch.Workingfromhomealotorbeinggeographicallyseparatedfromyourteamandbossmakesthisespeciallydifficult.

NextServingYourTeam-HowtoDevelopTalent

HowtobeaProgrammer

75Advanced

Page 76: How to Be a Programmer En

HowtoDevelopTalentNietschzeexaggeratedwhenhesaid[Stronger]:

Whatdoesnotdestroyme,makesmestronger.

Yourgreatestresponsibilityistoyourteam.Youshouldknoweachofthemwell.Youshouldstretchyourteam,butnotoverburdenthem.Youshouldusuallytalktothemaboutthewaytheyarebeingstretched.Iftheybuyintoit,theywillbewellmotivated.Oneachproject,oreveryotherproject,trytostretchtheminbothawaythattheysuggestandawaythatyouthinkwillbegoodforthem.Stretchthemnotbygivingthemmorework,butbygivingthemanewskillorbetteryetanewroletoplayontheteam.

Youshouldallowpeople(includingyourself)tofailoccasionallyandshouldplanforsomefailureinyourschedule.Ifthereisneveranyfailure,therecanbenosenseofadventure.Iftherearenotoccasionalfailures,youarenottryinghardenough.Whensomeonefails,youshouldbeasgentleasyoucanwiththemwhilenottreatingthemasthoughtheyhadsucceeded.

Trytogeteachteammembertobuyinandbewellmotivated.Askeachofthemexplicitlywhattheyneedtobewell-motivatediftheyarenot.Youmayhavetoleavethemdissatisfied,butyoushouldknowwhateverybodydesires.

Youcan'tgiveuponsomeonewhoisintentionallynotcarryingtheirshareoftheloadbecauseoflowmoraleordissatisfactionandjustletthembeslack.Youmusttrytogetthemwell-motivatedandproductive.Aslongasyouhavethepatience,keepthisup.Whenyourpatienceisexhausted,firethem.Youcannotallowsomeonewhoisintentionallyworkingbelowtheirleveltoremainontheteam,sinceitisnotfairtotheteam.

Makeitcleartothestrongmembersofyourteamthatyouthinktheyarestrongbysayingsoinpublic.Praiseshouldbepublicandcriticismprivate.

Thestrongmembersoftheteamwillnaturallyhavemoredifficulttasksthantheweakmembersoftheteam.Thisisperfectlynaturalandnobodywillbebotheredbyitaslongaseveryoneworkshard.

Itisanoddfactthatisnotreflectedinsalariesthatagoodprogrammerismoreproductivethan10badprogrammers.Thiscreatesastrangesituation.Itwilloftenbetruethatyoucouldmovefasterifyourweakprogrammerswouldjustgetoutoftheway.Ifyoudidthisyouwouldinfactmakemoreprogressintheshortterm.However,yourtribewouldlosesome

HowtobeaProgrammer

76Advanced

Page 77: How to Be a Programmer En

importantbenefits,namelythetrainingoftheweakermembers,thespreadingoftribalknowledge,andtheabilitytorecoverfromthelossofthestrongmembers.Thestrongmustbegentleinthisregardandconsidertheissuefromallangles.

Youcanoftengivethestrongerteammemberschallenging,butcarefullydelineated,tasks.

NextHowtoChooseWhattoWorkOn

HowtobeaProgrammer

77Advanced

Page 78: How to Be a Programmer En

HowtoChooseWhattoWorkOnYoubalanceyourpersonalneedsagainsttheneedsoftheteaminchoosingwhataspectofaprojecttoworkon.Youshoulddowhatyouarebestat,buttrytofindawaytostretchyourselfnotbytakingonmoreworkbutbyexercisinganewskill.Leadershipandcommunicationskillsaremoreimportantthantechnicalskills.Ifyouareverystrong,takeonthehardestorriskiesttask,anddoitasearlyaspossibleintheprojecttodecreaserisk.

NextHowtoGettheMostFromYourTeam-mates

HowtobeaProgrammer

78Advanced

Page 79: How to Be a Programmer En

HowtoGettheMostFromYourTeam-matesTogetthemostfromyourteam-mates,developagoodteamspiritandtrytokeepeveryindividualbothpersonallychallengedandpersonallyengaged.

Todevelopteamspirit,cornystufflikelogoizedclothingandpartiesaregood,butnotasgoodaspersonalrespect.Ifeveryonerespectseveryoneelse,nobodywillwanttoletanybodydown.Teamspiritiscreatedwhenpeoplemakesacrificesfortheteamandthinkintermsofthegoodoftheteambeforetheirownpersonalgood.Asaleader,youcan'taskformorethanyougiveyourselfinthisrespect.

Oneofthekeystoteamleadershipistofacilitateconsensussothateveryonehasbuyin.Thisoccasionallymeansallowingyourteam-matestobewrong.Thatis,ifitdoesnotharmtheprojecttoomuch,youmustletsomeofyourteamdothingstheirownway,basedonconsensus,evenifyoubelievewithgreatconfidenceitisthewrongthingtodo.Whenthishappens,don'tagree,simplydisagreeopenlyandaccepttheconsensus.Don'tsoundhurt,orlikeyou'rebeingforcedintoit,simplystatethatyoudisagreebutthinktheconsensusoftheteamismoreimportant.Thiswilloftencausethemtobacktrack.Don'tinsistthattheygothroughwiththeirinitialplaniftheydobacktrack.

Ifthereisanindividualwhowillnotconsentafteryouhavediscussedtheissuesfromallappropriatesides,simplyassertthatyouhavetomakeadecisionandthatiswhatyourdecisionis.Ifthereisawaytojudgeifyourdecisionwillbewrongorifitislatershowntobewrong,switchasquicklyasyoucanandrecognizethepersonswhowereright.

Askyourteam,bothasagroupandindividually,whattheythinkwouldcreateteamspiritandmakeforaneffectiveteam.

Praisefrequentlyratherthanlavishly.Especiallypraisethosewhodisagreewithyouwhentheyarepraiseworthy.Praiseinpublicandcriticizeinprivate;withoneexception:sometimesgrowthorthecorrectionofafaultcan'tbepraisedwithoutdrawingembarrassingattentiontotheoriginalfault,sothatgrowthshouldbepraisedinprivate.

NextHowtoDivideProblemsUp

HowtobeaProgrammer

79Advanced

Page 80: How to Be a Programmer En

HowtoDivideProblemsUpIt'sfuntotakeasoftwareprojectanddivideitupintotasksthatwillbeperformedbyindividuals.Thisshouldbedoneearly.Sometimesmanagersliketothinkthatanestimatecanbemadewithoutconsiderationoftheindividualsthatwillperformthework.Thisisimpossiblesincetheproductivityofindividualsvariessowidely.Whohasparticularknowledgeaboutacomponentalsoconstantlychangesandcanhaveanorderofmagnitudeeffectonperformance.

Justasacomposerconsidersthetimbreoftheinstrumentthatwillplayapartorthecoachofanathleticteamconsidersthestrengthsofeachplayer,theexperiencedteamleaderwillnotusuallybeabletoseparatethedivisionoftheprojectintotasksfromtheteammemberstowhichtheywillbeassigned.Thisispartofthereasonthatahigh-performingteamshouldnotbebrokenup.

Thereisacertaindangerinthisgiventhatpeoplewillbecomeboredastheybuildupontheirstrengthsandneverimprovetheirweaknessesorlearnnewskills.However,specializationisaveryusefulproductivitytoolwhennotoverused.

NextHowtoHandleBoringTasks

HowtobeaProgrammer

80Advanced

Page 81: How to Be a Programmer En

HowtoHandleBoringTasksSometimesitisnotpossibletoavoidboringtasksthatarecriticaltothesuccessofthecompanyortheproject.Thesetaskscanreallyhurtthemoraleofthosethathavetodothem.ThebesttechniquefordealingwiththisistoinvokeorpromoteLarryWall'sprogrammer'svirtueofLaziness.Trytofindsomewaytogetthecomputertodothetaskforyouortohelpyourteam-matesdothis.Workingforaweekonaprogramtodoataskthatwilltakeaweektodobyhandhasthegreatadvantageofbeingmoreeducationalandsometimesmorerepeatable.

Ifallelsefails,apologizetothosewhohavetodotheboringtask,butundernocircumstancesallowthemtodoitalone.Ataminimumassignateamoftwotodotheworkandpromotehealthyteamworktogetthetaskdone.

NextHowtoGatherSupportforaProject

HowtobeaProgrammer

81Advanced

Page 82: How to Be a Programmer En

HowtoGatherSupportforaProjectTogathersupportforaproject,createandcommunicateavisionthatdemonstratesrealvaluetotheorganizationasawhole.Attempttoletothersshareinyourvisioncreation.Thisgivesthemareasontosupportyouandgivesyouthebenefitoftheirideas.Individuallyrecruitkeysupportersforyourproject.Whereverpossible,show,don'ttell.Ifpossible,constructaprototypeoramock-uptodemonstrateyourideas.Aprototypeisalwayspowerfulbutinsoftwareitisfarsuperiortoanywrittendescription.

NextHowtoGrowaSystem

HowtobeaProgrammer

82Advanced

Page 83: How to Be a Programmer En

HowtoGrowaSystemTheseedofatreecontainstheideaoftheadultbutdoesnotfullyrealizetheformandpotencyoftheadult.Theembryogrows.Itbecomeslarger.Itlooksmoreliketheadultandhasmoreoftheuses.Eventuallyitbearsfruit.Later,itdiesanditsbodyfeedsotherorganisms.

Wehavetheluxuryoftreatingsoftwarelikethat.Abridgeisnotlikethat;thereisneverababybridge,butmerelyanunfinishedbridge.Bridgesarealotsimplerthansoftware.

Itisgoodtothinkofsoftwareasgrowing,becauseitallowsustomakeusefulprogressbeforewehaveaperfectmentalimage.Wecangetfeedbackfromusersandusethattocorrectthegrowth.Pruningoffweaklimbsishealthful.

Theprogrammermustdesignafinishedsystemthatcanbedeliveredandused.Buttheadvancedprogrammermustdomore.Youmustdesignagrowthpaththatendsinthefinishedsystem.Itisyourjobtotakeagermofanideaandbuildapaththattakesitassmoothlyaspossibleintoausefulartefact.

Todothis,youmustvisualizetheendresultandcommunicateitinawaythattheengineeringteamcangetexcitedabout.Butyoumustalsocommunicatetothemapaththatgoesfromwherevertheyarenowtowheretheywanttobewithnolargeleaps.Thetreemuststayalivethewholetime;itcannotbedeadatonepointandresurrectedlater.

Thisapproachiscapturedinspiraldevelopment.Milestonesthatarenevertoofarapartareusedtomarkprogressalongthepath.Intheultra-competitiveenvironmentofbusiness,itisbestifthemilestonescanbereleasedandmakemoneyasearlyaspossible,eveniftheyarefarawayfromawell-designedendpoint.Oneoftheprogrammer'sjobsistobalancetheimmediatepay-offagainstfuturepay-offbywiselychoosingagrowthpathexpressedinmilestones.

Theadvancedprogrammerhasthetripleresponsibilityofgrowingsoftware,teams,andpersons.

Areader,RobHafernik,sentinthiscommentonthissectionthatIcandonobetterthantoquoteinfull:

HowtobeaProgrammer

83Advanced

Page 84: How to Be a Programmer En

Ithinkyouunder-emphasizetheimportancehere.It'snotjustsystems,butalgorithms,userinterfaces,datamodels,andsoon.It'sabsolutelyvitalasyouworkonalargesystemtohavemeasurableprogresstowardintermediategoals.Nothingisasbadasthespecialhorrorofgettingdowntotheendanddiscoveringthatthewholethingjustisn'tgoingtowork(lookattherecentdebacleoftheVoterNewsSystem).Iwouldevengofurtherandstateitasalawofnature:nolarge,complexsystemcanbeimplementedfromscratch,itcanonlybeevolvedfromasimplesystemtoacomplexsysteminaseriesofintentionalsteps.

TowhichonecanonlyreplyFiatlux!

NextHowtoCommunicateWell

HowtobeaProgrammer

84Advanced

Page 85: How to Be a Programmer En

HowtoCommunicateWellTocommunicatewell,youhavetorecognizehowharditis.Itisaskilluntoitself.Itismadeharderbythefactthatthepersonswithwhomyouhavetocommunicateareflawed.Theydonotworkhardatunderstandingyou.Theyspeakpoorlyandwritepoorly.Theyareoftenoverworkedorbored,and,ataminimum,somewhatfocusedontheirownworkratherthanthelargerissuesyoumaybeaddressing.Oneoftheadvantagesoftakingclassesandpractisingwriting,publicspeaking,andlisteningisthatifyoubecomegoodatityoucanmorereadilyseewhereproblemslieandhowtocorrectthem.

Theprogrammerisasocialanimalwhosesurvivaldependsoncommunicationwithherteam.Theadvancedprogrammerisasocialanimalwhosesatisfactiondependsoncommunicationwithpeopleoutsideherteam.

Theprogrammerbringsorderoutofchaos.Oneinterestingwaytodothisistoinitiateaproposalofsomekindoutsidetheteam.Thiscanbedoneinastrawmanorwhite-paperformatorjustverbally.Thisleadershiphasthetremendousadvantageofsettingthetermsofthedebate.Italsoexposesyoutocriticism,andworse,rejectionandneglect.Theadvancedprogrammermustbepreparedtoacceptthis,becauseshehasauniquepowerandthereforeauniqueresponsibility.Entrepreneurswhoarenotprogrammersneedprogrammerstoprovideleadershipinsomeways.Programmersarethepartofthebridgebetweenideasandrealitythatrestsonreality.

Ihaven'tmasteredcommunicatingwell,butwhatI'mcurrentlytryingiswhatIthinkofafour-prongedapproach:AfterIhavemyideasinorderandamfullyprepared,Itrytospeakverbally,handpeopleawhite-paper(onrealpaper,aswellaselectronically)showthemademo,andthenpatientlyrepeatthisprocess.Ithinkalotoftimeswearenotpatientenoughinthiskindofdifficultcommunication.Youshouldnotbedisheartenedifyourideasarenotimmediatelyaccepted.Ifyouhaveinvestedenergyintheirpreparation,noonewillthinkpoorlyofyouforit.

NextHowtoTellPeopleThingsTheyDon'tWanttoHear

HowtobeaProgrammer

85Advanced

Page 86: How to Be a Programmer En

HowtoTellPeopleThingsTheyDon'tWanttoHearYouwilloftenhavetotellpeoplethingsthatwillmakethemuncomfortable.Rememberthatyouaredoingthisforareason.Evenifnothingcanbedoneabouttheproblem,youaretellingthemasearlyaspossiblesotheywillbewell-informed.

Thebestwaytotellsomeoneaboutaproblemistoofferasolutionatthesametime.Thesecondbestwayistoappealtothemforhelpwiththeproblem.Ifthereisadangerthatyouwon'tbebelieved,youshouldgathersomesupportforyourassertion.

Oneofthemostunpleasantandcommonthingsyouwillhavetosayis,‘Theschedulewillhavetoslip.’Theconscientiousprogrammerhatestosaythis,butmustsayitasearlyaspossible.Thereisnothingworsethanpostponingactionwhenamilestoneslips,eveniftheonlyactionistoinformeveryone.Indoingthis,itisbettertodoitasateam,atleastinspirit,ifnotphysically.Youwillwantyourteam'sinputonbothwhereyoustandandwhatcanbedoneaboutit,andtheteamwillhavetofacetheconsequenceswithyou.

NextHowtoDealwithManagerialMyths

HowtobeaProgrammer

86Advanced

Page 87: How to Be a Programmer En

HowtoDealwithManagerialMythsThewordmythsometimesmeansfiction.Butithasadeeperconnotation.Italsomeansastoryofreligioussignificancethatexplainstheuniverseandmankind'srelationshiptoit.Managerstendtoforgetwhattheylearnedasprogrammersandbelieveincertainmyths.Itwouldbeasrudeandunsuccessfultotrytoconvincethemthesemythsarefalseastotrytodisillusionadevoutlyreligiouspersonoftheirbeliefs.Forthatreason,youshouldrecognizethesebeliefsasmyths:

Moredocumentationisalwaysbetter.(Theywantit,buttheydon'twantyoutospendanytimeonit.)Programmerscanbeequated.(Programmersvarybyanorderofmagnitude.)Resourcescanbeaddedtoalateprojecttospeedit.(Thecostofcommunicationwiththenewpersonsisalmostalwaysmoretaxingthanhelpful.)Itispossibletoestimatesoftwaredevelopmentreliably.(Itisnoteventheoreticallypossible.)Programmers'productivitycanbemeasuredintermsofsomesimplemetric,likelinesofcode.(Ifsuccinctnessispower,linesofcodearebad,notgood.)

Ifyouhaveanopportunity,youcantrytoexplainthesethings,butdon'tfeelbadifyouhavenosuccessanddon'tdamageyourreputationbyconfrontingthesemythsbelligerently.Eachofthesemythsreinforcesthemanager'sideathattheyhavesomeactualcontroloverwhatisgoingon.Thetruthisthatmanagersfacilitateiftheyaregood,andimpedeiftheyarebad.

NextHowtoDealwithOrganizationalChaos

HowtobeaProgrammer

87Advanced

Page 88: How to Be a Programmer En

HowtoDealwithOrganizationalChaosThereareoftenbriefperiodsofgreatorganizationalchaos,suchaslay-offs,buyouts,ipos,firings,newhirings,andsoon.Theseareunsettlingtoeveryone,butperhapsalittlelessunsettlingtotheprogrammerwhosepersonalself-esteemisfoundedincapacityratherthaninposition.Organizationalchaosisagreatopportunityforprogrammerstoexercisetheirmagicpower.I'vesavedthisforlastbecauseitisadeeptribalsecret.Ifyouarenotaprogrammer,pleasestopreadingnow.

Engineershavethepowertocreateandsustain.

Non-engineerscanorderpeoplearoundbut,inatypicalsoftwarecompany,cancreateandsustainnothingwithoutengineers,justasengineerstypicallycannotsellaproductormanageabusinesseffectively.Thispowerisproofagainstalmostalloftheproblemsassociatedwithtemporaryorganizationalmayhem.Whenyouhaveityoushouldignorethechaoscompletelyandcarryonasifnothingishappening.Youmay,ofcourse,getfired,butifthathappensyoucanprobablygetanewjobbecauseofthemagicpower.Morecommonly,somestressed-outpersonwhodoesnothavethemagicpowerwillcomeintoyourcubeandtellyoutodosomethingstupid.Ifyouarereallysurethatitisstupid,itisbesttosmileandnoduntiltheygoawayandthencarryondoingwhatyouknowisbestforthecompany.

Ifyouarealeader,tellyourpeopletodothesamethingandtellthemtoignorewhatanybodyelsetellsthem.Thiscourseofactionisthebestforyoupersonally,andisthebestforyourcompanyorproject.

NextGlossary

HowtobeaProgrammer

88Advanced

Page 89: How to Be a Programmer En

AppendixA-Bibliography/Websiteography

Books[Rules00]GuyKawasaki,MichelleMoreno,andGaryKawasaki.2000.HarperBusiness.RulesforRevolutionaries:TheCapitalistManifestoforCreatingandMarketingNewProductsandServices.

[RDev96]SteveMcConnell.1996.MicrosoftPress.Redmond,Wash.RapidDevelopment:TamingWildSoftwareSchedules.

[CodeC93]SteveMcConnell.1993.MicrosoftPress.Redmond,Wash.CodeComplete.

[XP99]KentBeck.1999.0201616416.Addison-Wesley.ExtremeProgrammingExplained:EmbraceChange.

[PlanXP00]KentBeckandMartinFowler.2000.0201710919.Addison-Wesley.PlanningExtremeProgramming.

[Prag99]AndrewHunt,DavidThomas,andWardCunningham.1999.020161622X.Addison-Wesley.ThePragmaticProgrammer:FromJourneymantoMaster.

[Stronger]FriedrichNietzsche.1889.TwilightoftheIdols,"MaximsandArrows",section8..

WebSites[PGSite]PaulGraham.2002.Articlesonhiswebsite:http://www.paulgraham.com/articles.html.Allofthem,butespecially"BeatingtheAverages".

[Hacker]EricS.Raymond.2003.HowtoBecomeaHacker.http://www.catb.org/~esr/faqs/hacker-howto.html.

[HackDict]EricS.Raymond.2003.TheNewHackerDictionary.http://catb.org/esr/jargon/jargon.html.

[ExpCS]EdsgerW.Dijkstra.1986.HowExperimentalisComputingScience?.http://www.cs.utexas.edu/users/EWD/ewd09xx/EWD988a.PDF.

[Knife]EdsgerW.Dijkstra.1984.OnaCulturalGap.http://www.cs.utexas.edu/users/EWD/ewd09xx/EWD913.PDF.

HowtobeaProgrammer

89AppendixA*Bibliography/Websiteography

Page 90: How to Be a Programmer En

NextHistory

HowtobeaProgrammer

90AppendixA*Bibliography/Websiteography

Page 91: How to Be a Programmer En

AppendixB-History

MovetoGithubThisessayhasbeencreatedasarepositoryonGithubsothatitcanbeeasilyshared,updatedandimproved.Itwascopiedfromhttp://samizdat.mines.edu/howto/HowToBeAProgrammer.htmbyBraydieGrove.ItwasmovedtoGithubinJanuary2016.

RequestforFeedbackorExtensionPleasesendmeanycommentsyoumayhaveonthisessay.Iconsiderallsuggestions,manyofwhichhavealreadyimprovedthisessay.

IhaveplacedthisessayundertheGNUFreeDocumentationLicense.Thislicenseisnotspecificallydesignedforessays.Essaysareusuallyintendedtobecoherentandconvincingargumentsthatarewrittenfromasinglepointofviewinasinglevoice.Ihopethisessayisashortandpleasantread.

Ialsohopethatitisinstructive.Althoughnotatextbook,itisbrokenintomanysmallsectionstowhichnewsectionscanbefreelyadded.Ifsoinclined,youareencouragedtoexpanduponthisessayasyouseefit,subjecttotheprovisionsoftheLicense.

Itmaybearrogancetoimaginethatthisdocumentisworthyofextension;buthopespringseternal.Iwouldbejoyousifitwereextendedinthefollowingways:

Theadditionofacomprehensivereadinglisttoeachsection,

Theadditionofmoreandbettersections,

Translationintootherlanguages,evenifonlyonasubsection-by-subsectionbasis,and/or

Criticismorcommentaryin-linedintothetext.

Theabilitytobuildintodifferentformats,suchaspalmformatsandbetterHTML.

Ifyouinformmeofyourwork,IwillconsideritandmayincludeitinsubsequentversionsthatIproduce,subjecttotheprovisionsoftheLicense.Youmayofcourseproduceyourownversionsofthisdocumentwithoutmyknowledge,asexplainedintheLicense.

Thankyou.

HowtobeaProgrammer

91AppendixB*History(AsofJanuary2016)

Page 92: How to Be a Programmer En

RobertL.Read

OriginalVersionTheoriginalversionofthisdocumentwasbegunbyRobertL.Readintheyear2000andfirstpublishedelectronicallyatSamizdatPress(http://Samizdat.mines.edu)in2002.ItisdedicatedtotheprogrammersofHire.com.

AfterthisarticlewasmentionedonSlashdotin2003,about75peoplesentmeemailwithsuggestionsanderrata.Iappreciatethemall.Therewasalotofduplication,butthefollowingpeopleeithermademajorsuggestionsorwerethefirsttofindabugthatIfixed:MorganMcGuire,DavidMason,TomMoertel,NinjaProgrammer(145252)atSlashdot,BenVierck,RobHafernik,MarkHowe,PieterPareit,BrianGrayson,ZedA.Shaw,SteveBenz,MaksimIoffe,AndrewWu,DavidJeschke,andTomCorcoran.

FinallyIwouldliketothankChristinaVallery,whoseeditingandproofreadinggreatlyimprovedtheseconddraft,andWayneAllen,whoencouragedmetoinitiatethis.

OriginalAuthor'sBioRobertL.ReadlivesinAustin,Texas,withhiswifeandtwochildren.HeiscurrentlyaPrincipalEngineeratHire.com,wherehehasworkedforfouryears.Priortothathefounded4RTechnology,whichmadeascanner-basedimageanalysisqualitycontroltoolforthepaperindustry.

RobreceivedaPhDfromtheUniversityofTexasatAustinin1995inComputerSciencerelatedtodatabasetheory.In1987hereceivedaBAinComputerSciencefromRiceUniversity.Hehasbeenapaidprogrammersincetheageof16.

NextLicense

HowtobeaProgrammer

92AppendixB*History(AsofJanuary2016)

Page 93: How to Be a Programmer En

ContributionsThisrepositoryaimstobeacommunitydrivenproject,andyourinvolvementwillultimatelyhelpimprovethequalityofthisguide.

WhatcanIdotocontribute?Thereareanumberofwaystocontributeto"HowtobeaProgrammer".

IdeasfornewsectionsImprovementstoexistingsectionsIdentifyingtyposorotherissuesinsectionsContributingadditionallinkstoresourcesforsectionsGeneralsuggestionsforimprovingtheproject

ContributorsGithubholdsalistofallcontributorstothisproject.

EditorshipandMovetoGitHubBraydieGrovehasagreedtoserveaseditor-in-chief.

BraydietransposedtheoriginalessayintoMarkDownandcreatedtherepository.

HowtobeaProgrammer

93AppendixC*Contributions(AsofJanuary2016)

Page 94: How to Be a Programmer En

Glossary

bossThepersonorentitythatgivesyoutasks.Insomecasesthismaybethepublicatlarge.

1.1.6.HowtoFixPerformanceProblems 1.2.1.WhyEstimationisImportant1.2.4.HowtoUtilizePeopleasInformationSources1.2.2.HowtoEstimateProgrammingTime2.3.1.HowtoTradeoffQualityAgainstDevelopmentTime2.3.5.HowtoGrowProfessionally 2.1.6.HowtoLearnNewSkills2.2.1.HowtoManageDevelopmentTime 3.2.2.HowtoUnderstandtheUser3.2.3.HowtoGetaPromotion 0.Introduction

bossThepersonwhosetsyourtasks.Insomecases,theuseristheboss.

bottleneckThemostimportantlimitationintheperformanceofasystem.Aconstrictionthatlimitsperformance.

1.1.6.HowtoFixPerformanceProblems 2.1.4.HowtoStressTest

boxesandarrowsAloose,informalstyleofmakingdiagramsconsistingofboxesandarrowsdrawnbetweenthoseboxestoshowtherelationships.Thiscontrastwithformaldiagrammethodologies,suchasUML.

2.1.9.CommunicationLanguages

business

HowtobeaProgrammer

94Glossary

Page 95: How to Be a Programmer En

Agroupofpeopleorganizedformakingmoney.

1.2.3.HowtoFindOutInformation2.3.1.HowtoTradeoffQualityAgainstDevelopmentTime2.3.4.HowtoMakeaBuyvs.BuildDecision 2.3.8.HowtoTalktoNon-Engineers2.1.4.HowtoStressTest 2.1.11.Howtoanalyzedata2.2.2.HowtoManageThird-PartySoftwareRisks 3.3.7.HowtoGrowaSystem3.3.11.HowtoDealwithOrganizationalChaos 0.Introduction

buyvs.buildAnadjectivedescribingachoicebetweenspendingmoneyforsoftwareorwritingityourself.

2.3.4.HowtoMakeaBuyvs.BuildDecision

communicationlanguagesAlanguagedesignedprimarilyforstandardizationratherthanexecution.

2.1.9.CommunicationLanguages

companyAgroupofpeopleorganizedformakingmoney.

1.1.1.LearntoDebug 1.2.2.HowtoEstimateProgrammingTime1.2.10.HowtoRecognizeWhentoGoHome2.3.3.HowtoDecideifSoftwareisTooImmature2.3.4.HowtoMakeaBuyvs.BuildDecision 2.3.6.HowtoEvaluateInterviewees2.1.1.HowtoStayMotivated 2.2.2.HowtoManageThird-PartySoftwareRisks2.2.3.HowtoManageConsultants2.2.5.HowtoDisagreeHonestlyandGetAwaywithIt3.3.5.HowtoHandleBoringTasks 3.3.11.HowtoDealwithOrganizationalChaos3.1.3.ChoosingLanguages 0.Introduction

divideandconquer

HowtobeaProgrammer

95Glossary

Page 96: How to Be a Programmer En

Atechniqueoftop-downdesignand,importantly,ofdebuggingthatisthesubdivisionofaproblemoramysteryintoprogressivelysmallerproblemsormysteries.

1.1.2.HowtoDebugbySplittingtheProblemSpace

EntrepreneurTheinitiatorofprojects.

2.3.3.HowtoDecideifSoftwareisTooImmature3.1.1.HowtoTelltheHardFromtheImpossible

ExtremeProgrammingAstyleofprogrammingemphasizingcommunicationwiththecustomerandautomatedtesting.

1.2.2.HowtoEstimateProgrammingTime 1.2.8.HowtoUnitTest2.3.8.HowtoTalktoNon-Engineers 3.2.1.HowtoFightSchedulePressure4.AppendixA*Bibliography/Websiteography 0.Introduction

garbageObjectsthatarenolongerneededthatholdmemory.

1.1.9.HowtoManageMemory

garbageAllocatedmemorythatnolongerhasanyusefulmeaning.

garbagecollectorAsystemforrecyclinggarbage.

1.1.9.HowtoManageMemory 1.1.10.HowtoDealwithIntermittentBugs

HowtobeaProgrammer

96Glossary

Page 97: How to Be a Programmer En

GlossaryThisisaglossaryoftermsasusedinthisessay.Thesedonotnecessarilyhaveastandardizedmeaningtootherpeople.EricS.Raymondhascompiledamassiveandinformativeglossary[HackerDict]thatrathersurprisinglycanpleasurablybereadcover-to-coveronceyoucanappreciateafractionofit.

heapallocatedMemorycanbesaidtobeheapallocatedwheneverthemechanismforfreeingitiscomplicated.

1.1.9.HowtoManageMemory

hittingthewallTorunoutofaspecificresourcecausingperformancetodegradesharplyratherthangradually.

2.1.4.HowtoStressTest

informationhidingAdesignprinciplethatseekstokeepthingsindependentanddecoupledbyusinginterfacesthatexposeaslittleinformationaspossible.

2.1.5.HowtoBalanceBrevityandAbstraction

linguafrancaAlanguagesopopularastobeadefactostandardforitsfield,asFrenchwasforinternationaldiplomacyatonetime.

2.1.9.CommunicationLanguages

logging

HowtobeaProgrammer

97Glossary

Page 98: How to Be a Programmer En

Thepracticeofwritingaprogramsothatitcanproduceaconfigurableoutputlogdescribingitsexecution.

1.1.1.LearntoDebug 1.1.4.HowtoDebugUsingaLog1.1.5.HowtoUnderstandPerformanceProblems1.1.10.HowtoDealwithIntermittentBugs 2.1.4.HowtoStressTest

low-hangingfruitBigimprovementsthatcostlittle.

1.1.6.HowtoFixPerformanceProblems

masterAuniquepieceofinformationfromwhichallcachedcopiesarederivedthatservesastheofficialdefinitionofthatdata.

1.1.8.HowtoDealwithI/OExpense 3.1.2.HowtoUtilizeEmbeddedLanguages4.AppendixA*Bibliography/Websiteography

memoryleakTheunwantedcollectionofreferencestoobjectsthatpreventsgarbagecollection(orabuginthegarbagecollectorormemorymanagementsystem!)thatcausestheprogramtograduallyincreaseitsmemorydemandsovertime.

1.1.9.HowtoManageMemory

mereworkWorkthatrequireslittlecreativityandentailslittlerisk.Mereworkcanbeestimatedeasily.

3.1.1.HowtoTelltheHardFromtheImpossible

object-orientedprogrammingAnprogrammingstyleemphasizingthethemanagementofstateinsideobjects.

HowtobeaProgrammer

98Glossary

Page 99: How to Be a Programmer En

printliningTheinsertionofstatementsintoaprogramonastrictlytemporarybasisthatoutputinformationabouttheexecutionoftheprogramforthepurposeofdebugging.

1.1.1.LearntoDebug 1.1.4.HowtoDebugUsingaLog

programmingnotationAsynonymforprogramminglanguagethatemphasizesthemathematicalnatureofprogramminglanguageandtheirrelativesimplicitycomparedtonaturallanguages.

scrollblindnessTheeffectofbeingunabletofindinformationyouneedbecauseitisburiedintoomuchother,lessinterestinginformation.

1.1.4.HowtoDebugUsingaLog

speculativeprogrammingProducingafeaturebeforeitisreallyknownifthatfeaturewillbeuseful.

2.1.5.HowtoBalanceBrevityandAbstraction

strawmanAdocumentmeanttobethestartingpointofatechnicaldiscussion.Astrawmanmayleadtoastickman,tinman,woodman,ironman,etc.

3.3.8.HowtoCommunicateWell

tribeThepeoplewithwhomyoushareloyaltytoacommongoal.

1.2.4.HowtoUtilizePeopleasInformationSources2.3.3.HowtoDecideifSoftwareisTooImmature

HowtobeaProgrammer

99Glossary

Page 100: How to Be a Programmer En

2.2.5.HowtoDisagreeHonestlyandGetAwaywithIt 3.3.1.HowtoDevelopTalent0.Introduction

tribeAgroupofpeopleyoushareculturalaffinityandloyaltywith.

unk-unkSlangforunknown-unknown.Problemsthatcannotpresentlyevenbeconceptualizedthatwillstealtimeawayfromtheprojectandwrecktheschedule.

vapourIllusionaryandoftendeceptivepromisesofsoftwarethatisnotyetforsaleand,asoftenasnot,willnevermaterializeintoanythingsolid.

2.3.3.HowtoDecideifSoftwareisTooImmature2.2.2.HowtoManageThird-PartySoftwareRisks

wall-clockActuallytimeasmeasuredbyaclockonawall,asopposedtoCPUtime.

1.1.5.HowtoUnderstandPerformanceProblems 2.1.4.HowtoStressTest

white-paperAninformativedocumentthatisoftenmeanttoexplainorsellaproductorideatoanaudiencedifferentthantheprogrammersofthatproductoridea.

3.3.8.HowtoCommunicateWell

HowtobeaProgrammer

100Glossary