SlideShare a Scribd company logo
eleks.comeleks.com
CODE PRACTICES
HELLO!
I am Victor Matyushevskyy
MEET
BOB
1.
CODE
LAYOUT
75 PERCENTSThat much information we percieve though sight
How your code looks matters
A way to better looking code
• Consistent Code Indentation
• Consistent Members Ordering
• Avoid Deep Nesting
• Use Access Modifiers
• Limit Line Length
BAD
STYLE
BAD
STYLE
GOOD
STYLE
GOOD
STYLE
2.
NAMING
CONVENTIONS
Reasons for using a convention
• Reduce the effort needed to read and understand
source code
• Provide additional information about identifier
usage
• Provide better understanding in case of code reuse
after a long interval of time
• Help avoid "naming collisions"
• Enable code reviews to focus on more important
issues
• Enhance the aesthetic and professional appearance
of work product
Let’s compare this typical code:
float a, b, c; a=9.81; b=5; c=0.5*a*(b^2);
To this self-documenting code:
const float gravitationalForce = 9.81;
float timeInSeconds = 5;
float displacement = (1 / 2) * gravitationalForce * (timeInSeconds ^ 2);
Naming Styles
Pascal Case
DijkstraResult ReconstructShortestPath(Graph graph, Vertex startVertex)
Camel Case
DijkstraResult reconstructShortestPath(Graph& graph, Vertex& startVertex)
Underscore Case
def reconstruct_shortest_path(predecessors, start_vertex, end_vertex)
3.
CODE
DOCUMENTATION
Comments. Use them to…
• Describe code that might be difficult for someone to
follow
• In cases of extreme optimization when using
advanced techniques
• If you take an approach that might not be obvious
to others
• Mark places of code that must be unchanged for a
reason
• Describing why things are done the way they are,
not how they work
Commentaries Conventions
• Splitting long comments into multiple line
comment
• Avoid obvious comments
• Place the comment on a separate line, not at the
end of a line of code.
• Begin comment text with an uppercase letter
• Insert one space between the comment delimiter
and the comment text
Let’s compare this example of a poor commenting style:
const float a = 9.81; //gravitational force
float b = 5; //time in seconds
float c = (1/2)*a*(b^2) //multiply the time and gravity together to get
displacement
And this documented code, which better explains why it
is being done :
// Compute displacement with Newton's equation x = vₒt + ½at².
const float gravitationalForce = 9.81;
float timeInSeconds = 5;
float displacement = (1 / 2) * gravitationalForce * (timeInSeconds ^ 2);
4.
CODE
SMELL
CODE SMELL
• Usually is not a bug
• Does not prevent the program from
functioning
• Indicates weaknesses in design
• Might increase risks of a bug in future
BLOATERS
Long Methods Long Parameter List Large Class
OBJECT-ORIENTATION ABUSERS
Switch Statements Temporary Field Refused Bequest
CHANGE PREVENTERS
Divergent Change Shotgun Surgery Parallel Inheritance
Hierarchies
DISPENSABLES
Speculative Generality Duplicate Code Comments
COUPLERS
Feature Envy Message Chains Middle Man
5.
CODE
REVIEW
NO
REVIEW
WHAT FOR?
• Improves code quality
• Detects code smells
• Checks for styles and conventions
• Knowledge sharing
TWO TYPES OF REVIEW
Design Review
Analysis of design
and architecture of
application.
Code Review
Analysis of written
code, conventions
and styles.
CODE
REVIEW
PROCESS
Request Review
Review Comments
Refactor
Close Review
Repeat
Code Practices
LET’S REVIEW SOME
CONCEPTS
Layout
The way your code is
structured is the way it is
perceived.
Names
Choosing a better name
for variables or type
members is a step
towards readability.
Comments
Less of them makes you
concentrate on code itself.
Use them wisely.
Smell
Like a rotten apple, youre
code can smell, so keep it
fresh and clean.
Review
One head is good, two is
better. Reviewing you code
can detect potential bugs
and gaps.
Conventions
Before writing some code
know what convetions to
use to keep code hygiene
consistent.
THANKS!
Any questions?
eleks.com
Inspired by Technology.
Driven by Value.

More Related Content

PDF
Advanced Debugging in XCode
PPTX
#4 code quality
PPTX
Advanced c sharp part 3
PPTX
SQL Grouping, Joins
PPTX
PPTX
tsql
PPTX
If unit2 summary
PPTX
#2 integration + ui tests
Advanced Debugging in XCode
#4 code quality
Advanced c sharp part 3
SQL Grouping, Joins
tsql
If unit2 summary
#2 integration + ui tests

Viewers also liked (20)

PPTX
Unit1 summary
PPTX
Improving rpc bkp
PPTX
SDLC. PM Role
PPTX
Version control
PPTX
Web service lecture
PPTX
Mvvw patterns
PPTX
Advanced styles
PPTX
SDLC. QA Role
PPTX
Design patterns
PPTX
Sql 04n edited
PPTX
SQL: Indexes, Select operator
PPTX
Windows service
PPTX
Frontend basics
PPTX
PPTX
Css animation, html5 api
PPTX
Angular. presentation
PPTX
Communication in android
PPTX
NoSQL basics
PPTX
Lecture android best practices
PPTX
Solid and ioc principles
Unit1 summary
Improving rpc bkp
SDLC. PM Role
Version control
Web service lecture
Mvvw patterns
Advanced styles
SDLC. QA Role
Design patterns
Sql 04n edited
SQL: Indexes, Select operator
Windows service
Frontend basics
Css animation, html5 api
Angular. presentation
Communication in android
NoSQL basics
Lecture android best practices
Solid and ioc principles
Ad

Similar to Code Practices (20)

PDF
Uvm cookbook-systemverilog-guidelines-verification-academy
PPTX
Python Programming Essentials - M6 - Code Blocks and Indentation
PPTX
No Programmer Is an Island
PPTX
[2012 02 03]clean_code 4장
PPTX
Improving Code Quality Through Effective Review Process
PPTX
gdscWorkShopJavascriptintroductions.pptx
PPTX
Pragmatic Architecture in .NET
PPT
Linq 1224887336792847 9
PPTX
Code quality
PPTX
Code Quality
PPTX
Software development best practices & coding guidelines
PPT
Linq To The Enterprise
PPT
C# features
PDF
Automated scaling of microservice stacks for JavaEE applications - JEEConf 2017
PDF
JEEconf 2017
PPTX
Code Metrics
PDF
Lab3 testbench tutorial (1)
PDF
[Gophercon 2019] Analysing code quality with linters and static analysis
PDF
Clean Infrastructure as Code
PPS
Commenting Best Practices
Uvm cookbook-systemverilog-guidelines-verification-academy
Python Programming Essentials - M6 - Code Blocks and Indentation
No Programmer Is an Island
[2012 02 03]clean_code 4장
Improving Code Quality Through Effective Review Process
gdscWorkShopJavascriptintroductions.pptx
Pragmatic Architecture in .NET
Linq 1224887336792847 9
Code quality
Code Quality
Software development best practices & coding guidelines
Linq To The Enterprise
C# features
Automated scaling of microservice stacks for JavaEE applications - JEEConf 2017
JEEconf 2017
Code Metrics
Lab3 testbench tutorial (1)
[Gophercon 2019] Analysing code quality with linters and static analysis
Clean Infrastructure as Code
Commenting Best Practices
Ad

More from eleksdev (10)

PPTX
Hello android world
PPTX
Android location and sensors API
PPTX
Lecture java basics
PPTX
G rpc lection1_theory_bkp2
PPTX
G rpc lection1
PPTX
Aspnet core
PPTX
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
PPTX
SDLC. UX Role
PPTX
SDLC. BA Role
PPTX
sql introduction
Hello android world
Android location and sensors API
Lecture java basics
G rpc lection1_theory_bkp2
G rpc lection1
Aspnet core
Continuous Delivery concept overview. Continuous Integration Systems. DevOps ...
SDLC. UX Role
SDLC. BA Role
sql introduction

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
cuic standard and advanced reporting.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Spectroscopy.pptx food analysis technology
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation theory and applications.pdf
Cloud computing and distributed systems.
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Encapsulation_ Review paper, used for researhc scholars
cuic standard and advanced reporting.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Understanding_Digital_Forensics_Presentation.pptx
Electronic commerce courselecture one. Pdf
Review of recent advances in non-invasive hemoglobin estimation
Network Security Unit 5.pdf for BCA BBA.
Mobile App Security Testing_ A Comprehensive Guide.pdf
Empathic Computing: Creating Shared Understanding
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectroscopy.pptx food analysis technology
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Approach and Philosophy of On baking technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation theory and applications.pdf

Code Practices

  • 2. HELLO! I am Victor Matyushevskyy
  • 5. 75 PERCENTSThat much information we percieve though sight How your code looks matters
  • 6. A way to better looking code • Consistent Code Indentation • Consistent Members Ordering • Avoid Deep Nesting • Use Access Modifiers • Limit Line Length
  • 12. Reasons for using a convention • Reduce the effort needed to read and understand source code • Provide additional information about identifier usage • Provide better understanding in case of code reuse after a long interval of time • Help avoid "naming collisions" • Enable code reviews to focus on more important issues • Enhance the aesthetic and professional appearance of work product
  • 13. Let’s compare this typical code: float a, b, c; a=9.81; b=5; c=0.5*a*(b^2); To this self-documenting code: const float gravitationalForce = 9.81; float timeInSeconds = 5; float displacement = (1 / 2) * gravitationalForce * (timeInSeconds ^ 2);
  • 14. Naming Styles Pascal Case DijkstraResult ReconstructShortestPath(Graph graph, Vertex startVertex) Camel Case DijkstraResult reconstructShortestPath(Graph& graph, Vertex& startVertex) Underscore Case def reconstruct_shortest_path(predecessors, start_vertex, end_vertex)
  • 16. Comments. Use them to… • Describe code that might be difficult for someone to follow • In cases of extreme optimization when using advanced techniques • If you take an approach that might not be obvious to others • Mark places of code that must be unchanged for a reason • Describing why things are done the way they are, not how they work
  • 17. Commentaries Conventions • Splitting long comments into multiple line comment • Avoid obvious comments • Place the comment on a separate line, not at the end of a line of code. • Begin comment text with an uppercase letter • Insert one space between the comment delimiter and the comment text
  • 18. Let’s compare this example of a poor commenting style: const float a = 9.81; //gravitational force float b = 5; //time in seconds float c = (1/2)*a*(b^2) //multiply the time and gravity together to get displacement And this documented code, which better explains why it is being done : // Compute displacement with Newton's equation x = vₒt + ½at². const float gravitationalForce = 9.81; float timeInSeconds = 5; float displacement = (1 / 2) * gravitationalForce * (timeInSeconds ^ 2);
  • 20. CODE SMELL • Usually is not a bug • Does not prevent the program from functioning • Indicates weaknesses in design • Might increase risks of a bug in future
  • 21. BLOATERS Long Methods Long Parameter List Large Class
  • 22. OBJECT-ORIENTATION ABUSERS Switch Statements Temporary Field Refused Bequest
  • 23. CHANGE PREVENTERS Divergent Change Shotgun Surgery Parallel Inheritance Hierarchies
  • 25. COUPLERS Feature Envy Message Chains Middle Man
  • 28. WHAT FOR? • Improves code quality • Detects code smells • Checks for styles and conventions • Knowledge sharing
  • 29. TWO TYPES OF REVIEW Design Review Analysis of design and architecture of application. Code Review Analysis of written code, conventions and styles.
  • 32. LET’S REVIEW SOME CONCEPTS Layout The way your code is structured is the way it is perceived. Names Choosing a better name for variables or type members is a step towards readability. Comments Less of them makes you concentrate on code itself. Use them wisely. Smell Like a rotten apple, youre code can smell, so keep it fresh and clean. Review One head is good, two is better. Reviewing you code can detect potential bugs and gaps. Conventions Before writing some code know what convetions to use to keep code hygiene consistent.