42
Best coding practices Programming workshop

Best coding practices

Embed Size (px)

Citation preview

Page 1: Best coding practices

Best coding practices

Programmingworkshop

Page 2: Best coding practices

NO best language out thereBestProgrammingLanguageFor.me

Page 3: Best coding practices

NO best language out thereBestProgrammingLanguageFor.me

Page 4: Best coding practices
Page 5: Best coding practices
Page 6: Best coding practices

Where to write

TextEditor

Page 7: Best coding practices

Where to write

TextEditorIDE

Page 8: Best coding practices

Java / Android -- Intellij IDEAPython -- PyCharmC / C++ -- ClionObj. C / Swift -- App CodeC# -- ReSharper / RiderPhp -- PhpStormRuby -- RubyMineJavascript -- WebStormDBA -- DataGrip

JetBrains studentprogramjetbrains.com/student

Page 9: Best coding practices

How to manage :: VCS

Page 10: Best coding practices

How to manage :: VCS

Page 11: Best coding practices

Themostimportantrule

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.

Page 12: Best coding practices
Page 13: Best coding practices
Page 14: Best coding practices

Remember the second law of thermodynamics? It implies that disorder in a system will always increase unless you spend energy and work to

keep it from increasing.

It is hard to write clean code

Page 15: Best coding practices
Page 16: Best coding practices
Page 17: Best coding practices

Reinventing the wheel

Page 18: Best coding practices

Software design patternsDesign patterns can speed up the development process by providing tested, proven development paradigms.

Effective software design requires considering issues that may not become visible until later in the implementation.

Reusing design patterns helps to prevent subtle issues that can cause major problems and improves code readability for coders and architects familiar with the patterns.

Page 19: Best coding practices

Creational

Creationaldesignpatternsaredesignpatternsthatdealwithobjectcreationmechanisms,tryingtocreateobjectsinamannersuitabletothesituation.Thebasicformofobjectcreationcouldresultindesignproblemsoraddedcomplexitytothedesign.Creationaldesignpatternssolvethisproblembysomehowcontrollingthisobjectcreation.

Software design patterns

Page 20: Best coding practices

Software design patterns

CreationalStructural

StructuralDesignPatternsareDesignPatternsthateasethedesignbyidentifyingasimplewaytorealizerelationshipsbetweenentities.

Page 21: Best coding practices

Software design patterns

CreationalStructuralBehavioral

Behavioraldesignpatternsaredesignpatternsthatidentifycommoncommunicationpatternsbetweenobjectsandrealizethesepatterns.Bydoingso,thesepatternsincreaseflexibilityincarryingoutthiscommunication.

Page 22: Best coding practices

Variableandmethodnaming

1. Useintention-revealingname

Page 23: Best coding practices

Variableandmethodnaming

1. Useintention-revealingname2. Usepronounceablename

Page 24: Best coding practices

Variableandmethodnaming

1. Useintention-revealingname2. Usepronounceablename3. Don'tbecute

Page 25: Best coding practices

Variableandmethodnaming

1. Useintention-revealingname2. Usepronounceablename3. Don'tbecute4. Useonewordperconcept

Page 26: Best coding practices

Variableandmethodnaming

1. Useintention-revealingname2. Usepronounceablename3. Don'tbecute4. Useonewordperconcept5. Useverbsforfunctionnamesandnounsforclassesandattributes

Page 27: Best coding practices

Variableandmethodnaming

1. Useintention-revealingname2. Usepronounceablename3. Don'tbecute4. Useonewordperconcept5. Useverbsforfunctionnamesandnounsforclassesandattributes

Page 28: Best coding practices

Functions

1. Thesmaller,thebetter(butdon’tbecrazy)

Page 29: Best coding practices

Functions

1. Thesmaller,thebetter2. Thefunctionshalldoonlyonething

Page 30: Best coding practices

Functions

1. Thesmaller,thebetter2. Thefunctionshalldoonlyonething3. Lessargumentsarebetter

Page 31: Best coding practices

Functions

1. Thesmaller,thebetter2. Thefunctionshalldoonlyonething3. Lessargumentsarebetter4. Nosideeffects

Page 32: Best coding practices

Functions

1. Thesmaller,thebetter2. Thefunctionshalldoonlyonething3. Lessargumentsarebetter4. Nosideeffects5. Avoidoutputarguments

Page 33: Best coding practices

Functions

1. Thesmaller,thebetter2. Thefunctionshalldoonlyonething3. Lessargumentsarebetter4. Nosideeffects5. Avoidoutputarguments6. Don’trepeatyourself

Page 34: Best coding practices

Commets

Page 35: Best coding practices

Commets

1. Don’tcommentbadcode,rewriteit

Page 36: Best coding practices

Commets

1. Don’tcommentbadcode,rewriteit2. Ifcodeisreadableyoudon’tneedcomments

Page 37: Best coding practices

Commets

1. Don’tcommentbadcode,rewriteit2. Ifcodeisreadableyoudon’tneedcomments3. Explainyourintentionincomments

Page 38: Best coding practices

Commets

1. Don’tcommentbadcode,rewriteit2. Ifcodeisreadableyoudon’tneedcomments3. Explainyourintentionincomments4. Warnofconsequencesincomments

Page 39: Best coding practices

Commets

1. Don’tcommentbadcode,rewriteit2. Ifcodeisreadableyoudon’tneedcomments3. Explainyourintentionincomments4. Warnofconsequencesincomments5. Emphasizeimportantpointsincomments

Page 40: Best coding practices

Commets

1. Don’tcommentbadcode,rewriteit2. Ifcodeisreadableyoudon’tneedcomments3. Explainyourintentionincomments4. Warnofconsequencesincomments5. Emphasizeimportantpointsincomments6. Noisecommentsarebad

Page 41: Best coding practices

DEMOTIME!github.com/aganezov/python-samples

Page 42: Best coding practices

NextmeetingofJetBrains GWUMarch24th,2016

LehmanAuditorium(B1270)5:00– 7:00pm

“MasteringPython”

Facebookhttps://www.facebook.com/groups/jetbrains.gwu/

[email protected]

[email protected]