Documente Academic
Documente Profesional
Documente Cultură
DesktopAlerts
Login
CreateAccount
July17,2015
HOTONTHEBLOG
Featuringfreshtakesandrealtimeanalysisfrom
HuffPost'ssignaturelineupofcontributors
Quora
GaryHart
MarkRuffalo
BernardHenriLvy
KirkDouglas
Becomeafan
Thebestanswertoanyquestion
39BestKeptSecretsofGreatProgrammers
Posted:07/16/20153:33pmEDT
Updated:07/16/20154:59pmEDT
Whatarethebestkeptsecretsofgreatprogrammers?:originallyappearedonQuora:Thebestanswertoanyquestion.Askaquestion,
getagreatanswer.Learnfromexpertsandaccessinsiderknowledge.YoucanfollowQuoraonTwitter,Facebook,andGoogle+.
AnswerbyJensRantil,Developer
1. Most of the time, using inheritance is a bad object oriented design in the long run. It reduces reusability and testability of code.
Considerusinginterfacesinstead.SeeNo,inheritanceisnotthewaytoachievecodereuse!.Related
2.Avoidintroducinganinterfaceuntilyouarecomfortableinyourdomain."Prematureinterfacing"canalsoleadtodesignissuesdown
theroad.
3.Deepnestedcode(bothintrafunctionandinterfunction)is1)hardertomaintainand2)morepronetobugs.
4.Estimatingtimeishard.OnereasonwhyScrumandsprintsareusedinmanyplaces.
5.Properencryptionishard.Don'tinventityourselfunlessyouhaveagoodreasonto.
6.Sideeffectfreelogicisnice.Itmakesiteasiertoreasonaboutstate(seebelow)andgenerallysimplifiesautomatedtesting.
7.Learntoreasonaroundstateandlifecycles.SeeJensRantil'sHideout.
8.Concurrencycanbehardwithouttherightprimitives.Threadpools,Queues,Observables,andactorscansometimeshelpalot.
9.Prematureoptimizationistherootofallevil.Agoodgeneraldevelopmentprocessis:1)Getittowork.2)Makethecodebeautiful.3)
Optimize.
10. Know your basic data structures and understand time complexity. It's an effective way of making your code much faster without
addingcomplexity.
11.Practicebackoftheenvelopecalculations.Howmanyitemswillapieceofcodegenerallyholdinmemory?
12.Writecodeasyouwanttoreadit.Addcommentswhereyouthinkyouwillnotunderstandyourcodeinayear'stime.Youwillneed
thecommentinamonth.Somewhatrelated
13.Setupyoubuildtoolingaroundaprojectsothatit'seasytogetstarted.Documentthe(few)commandsneededtobuild,run,testand
packageinaREADMEfile.
14.Makingsureyourprojectscanbuildfromcommandlinemakesthingssomucheasierdowntheroad.
15. Handling 3rd party dependencies in many languages can be a real mess (looking at you Java and Python). Specifically when two
differentlibrariesdependondifferentversions.Somekeythingstotakeawayfromthis:1)Constantlyquestionyourdependencies.2)
Automatedtestscanhelpagainstthis.3)Alwaysfixatewhichversionofa3rdpartydependencyyoushoulduse.
16.PopularOpenSourceprojectsareagreatwaytolearnaboutgoodmaintainablecodeandsoftwaredevelopmentprocess.
17.Everysinglelineyouaddtoanapplicationaddscomplexityandmakesitmorelikelytohavebugs.Removingcodeisagreatwayto
removebugs.
18.Codepathsthathandlesfailuresarerarelytested/executed(forareason).Thismakesthemagoodcandidateforbugs.
19.Inputvalidationisnotjustusefulforsecurityreasons.Ithelpsyoucatchbugsearly.
20. Somewhat related to above: State validation and output validation can be equally useful as input validation, both in terms of
discoveringinherentbugs,butalsoforsecuritysensitivecode.
21.Codereviewsareagreatwaytoimproveasaprogrammer.Youwillgetcritiqueonyourcode,andyouwilllearntodescribeinwords
whysomeoneelse'scodeisgoodorbad.Italsotrainsyoutodiscovercommonmistakes.
22.Learninganewprogramminglanguageisagreatwaytolearnaboutnewparadigmsandquestionoldhabits.
23. Always specify encoding when converting text to and from bytes be it when reading/writing to network, file or for encryption
purposes. If you rely on your locale's character set you are bound to run into data corruption eventually. Use a UTF character set if
youcangettochooseyourself.
24.KnowyourtoolsThatincludesyoureditor,theterminal,versioncontrolsystem(suchasgit)andbuildtooling.
25. Learn to use your tools without a mouse. Learn as many keyboard shortcuts as possible. It will make you more efficient and is
generallymoreergonomic.
26.Reusingcodeisnotanendgoalandwillnotmakeyourcodemoremaintainableperse.Reusecomplicatedcodeandbeawarethat
reusingcodebetweentwodifferentdomainsmightmakethemdependoneachothermorethannecessary.
27.Sittingforlongtimebythecomputercanbreakyourbody.1)Listentowhatyourbodyhastosay.Thinkextraaboutyourback,neck
andwrists.Takebreaksifyourbodystartstohurt.Creatingapausehabit(makingtea,grabingcoffee)cansurprisinglybegoodfor
yourbodyandmind.2)Restyoureyesfromtimetotimebylookingawayfromyourscreen.3)Getagoodkeyboardwithoutawkward
wristmovements.
28.Automatedtesting,andinparticularunittests,arenotjusttestingthatyourcodedoeswasitshould.Theyalso1)documenthowthe
codeissupposedtobeusedand2)alsohelpsyouputyourselfintheshoesofsomeonewhowillbeusingthecode.Thelatteriswhy
someclaimtestfirstapproachtodevelopmentcanyieldcleanerAPIs.
29.Testwhatneedstobetested.Undertestingcanslowyoudownbecauseofbughunting.Overtestingcanslowyoudownbecauseevery
changerequiresupdatingtoomanytests.
30. Dynamic languages generally need more testing to assert they work properly than compiled languages. (Offline code analysis tools
canalsohelp.)
31.Raceconditionsaresurprisinglymorecommonthanonegenerallythinks.ThisisbecauseacomputergenerallyhasmoreTPSthanwe
areusedto.
32.Understandingtherelationshipbetweenthroughputandlatencycanbeveryusefulwhenyoursystemsarebeingoptimized.Related
33.Manytimeshighthroughputcanbeachievedbyintroducingsmartbatching.
34.Commityourcodeinsmall,working,chunks.
35. Keep your version control system's branches shortlived. My experience is that risk of failures increases exponentially the longer a
branchlives.Avoidworkingonabranchformorethantwoweeks.Forlargefeatures,breakthemintomultiplerefactoringbranchesto
makethefeatureeasiertoimplementinafewcommits.
36.Knowyourproductionenvironmentandthinkaboutdeploymentstrategiesforyourchangeasearlyaspossible.
37.Surprisingly,shippingcodemorefrequentlytendstoreducerisk,notincreaseit.
38. Learning an object oriented language is easy. Mastering good object oriented design is hard. Knowing about SOLID and object
orientedDesignPatternswillimproveyourunderstandingofOOdesign.
39.It'spossibletowritecrappycodeinawellarchitectedsystem.However,inawellarchitectedsystemyouknowthatthecrapisisolated
andeasilyreplaceable.Focusingonasanedecoupledarchitecturefirst.Therestcanbecleaneduplaterifonatightschedule.
MorequestionsonQuora:
ComputerScience:Whatisacoder'sworstnightmare?
ComputerScience:Whatdifferentiatesa"senior"programmerfroma"regular"programmer?
ComputerProgrammers:Howdoesonebecomeagreatcoder?
FollowQuoraonTwitter:www.twitter.com/Quora
MORE: ComputerProgramming Careers Careers CareerAdvice ComputerScience ComputerProgrammers
Conversations
0Comments
Sortby Top
Addacomment...
FacebookCommentsPlugin
HuffingtonPostSearch
Advertise
UserAgreement
LogIn
MakeHuffPostYourHomePage
Privacy
Copyright2015TheHuffingtonPost.com,Inc.
CommentPolicy
AboutUs
RSS
Careers
AboutOurAds
FAQ
ContactUs
"TheHuffingtonPost"isaregisteredtrademarkofTheHuffingtonPost.com,Inc.Allrightsreserved.
PartofAOLTech