SlideShare a Scribd company logo
High-Quality Programming Code
Code Correctness, Readability,
Maintainability
Svetlin Nakov
Technical Trainer
www.nakov.com
Software University
http://softuni.bg
2
 Why Quality Is Important?
 Software Quality: External and Internal
 What is High-Quality Code?
 Code Conventions
 Managing Complexity
 Characteristics of Quality Code
Table of Contents
What is High-Quality
Programming Code?
4
 What does this code do? Is it correct?
Why Quality Is Important?
static void Main()
{
int value=010, i=5, w;
switch(value){case 10:w=5;Console.WriteLine(w);break;case
9:i=0;break;
case 8:Console.WriteLine("8 ");break;
default:Console.WriteLine("def ");{
Console.WriteLine("hoho "); }
for (int k = 0; k < i; k++, Console.WriteLine(k - 'f'));break;}
{ Console.WriteLine("loop!"); }
}
5
 Now the code is formatted, but is still unclear.
Why Quality Is Important? (2)
static void Main()
{
int value = 010, i = 5, w;
switch (value)
{
case 10: w = 5; Console.WriteLine(w); break;
case 9: i = 0; break;
case 8: Console.WriteLine("8 "); break;
default:
Console.WriteLine("def ");
Console.WriteLine("hoho ");
for (int k = 0; k < i; k++,
Console.WriteLine(k - 'f')) ;
break;
}
Console.WriteLine("loop!");
}
6
 External quality
 Does the software behave correctly?
 Are the produced results correct?
 Does the software run fast?
 Is the software UI easy-to-use?
 Is the code secure enough?
 Internal quality
 Is the code easy to read and understand?
 Is the code well structured?
 Is the code easy to modify?
Software Quality
7
 High-quality programming code:
 Easy to read and understand
 Easy to modify and maintain
 Correct behavior in all cases
 Well tested
 Well architectured and designed
 Well documented
 Self-documenting code
 Well formatted
What is High-Quality Programming Code?
8
 High-quality programming code:
 Strong cohesion at all levels: modules, classes, methods, etc.
 Single unit is responsible for single task
 Loose coupling between modules, classes, methods, etc.
 Units are independent one of another
 Good formatting
 Good names for classes, methods, variables, etc.
 Self-documenting code style
What is High-Quality Programming Code? (2)
Code Conventions
10
 Code conventions are formal guidelines about the style of the source
code:
 Code formatting conventions
 Indentation, whitespace, etc.
 Naming conventions
 PascalCase or camelCase, prefixes, suffixes, etc.
 Best practices
 Classes, interfaces, enumerations, structures, inheritance,
exceptions, properties, events, constructors, fields, operators, etc.
Code Conventions
11
 Microsoft official C# code conventions
 Design Guidelines for Developing Class Libraries:
http://msdn.microsoft.com/en-us/library/ms229042.aspx
 Java official code conventions
 http://www.oracle.com/technetwork/java/codeconvtoc-136057.html
 Semi-official JavaScript code conventions
 http://javascript.crockford.com/code.html,
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml
 Semi-official PHP conventions
 http://www.php-fig.org/psr/psr-1/
Code Conventions (2)
Managing Complexity
13
 Managing complexity has central role in software construction
 Minimize the amount of complexity that anyone’s brain has to deal with at
certain time
 Architecture and design challenges
 Design modules and classes to reduce complexity
 Code construction challenges
 Apply good software construction practices: classes, methods, variables,
naming, statements, error handling, formatting, comments, etc.
Managing Complexity
14
 Key to being an effective programmer:
 Maximizing the portion of a program that you can safely ignore
 While working on any one section of code
 Most practices discussed later propose ways to achieve this
important goal
Managing Complexity (2)
Code Quality: Characteristics
16
 Correct behavior
 Conforming to the requirements
 Stable, no hangs, no crashes
 Bug free – works as expected
 Correct response to incorrect usage
 Readable – easy to read
 Understandable – self-documenting
 Maintainable – easy to modify when required
Key Characteristics of High-Quality Code
17
 Good identifiers names
 Good names for variables, constants, methods, parameters,
classes, structures, fields, properties, interfaces, structures,
enumerations, namespaces,
 High-quality classes, interfaces and class hierarchies
 Good abstraction and encapsulation
 Simplicity, reusability, minimal complexity
 Strong cohesion, loose coupling
Key Characteristics of High-Quality Code (2)
18
 High-quality methods
 Reduced complexity, improved readability
 Good method names and parameter names
 Strong cohesion, loose coupling
 Variables, data, expressions and constants
 Minimal variable scope, span, live time
 Simple expressions
 Correctly used constants
 Correctly organized data
Key Characteristics of High-Quality Code (3)
19
 Correctly used control structures
 Simple statements
 Simple conditional statements and simple conditions
 Well organized loops without deep nesting
 Good code formatting
 Reflecting the logical structure of the program
 Good formatting of classes, methods, blocks, whitespace, long
lines, alignment, etc.
Key Characteristics of High-Quality Code (4)
20
 High-quality documentation and comments
 Effective comments
 Self-documenting code
 Defensive programming and exceptions
 Ubiquitous use of defensive programming
 Well organized exception handling
 Code tuning and optimization
 Quality code instead of good performance
 Code performance when required
Key Characteristics of High-Quality Code (5)
21
 Following the corporate code conventions
 Formatting and style, naming, etc.
 Domain-specific best practices
 Well tested and reviewed
 Testable code
 Well designed unit tests
 Tests for all scenarios
 High code coverage
 Passed code reviews and inspections
Key Characteristics of High-Quality Code (6)
22
1. Classes define specific structure for objects
 Objects are particular instances of a class
2. Classes define fields, methods, constructors,
3. properties and other members
 Access modifiers limit the access to class members
4. Constructors are invoked when creating new class instances and
initialize the object's internal state
5. Properties expose the class data in safe, controlled way
Summary
?
https://softuni.bg/courses/high-quality-code/
High-Quality Programming Code
License
 This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
24
 Attribution: this work may contain portions from
 "High Quality Code" course by Telerik Academy under CC-BY-NC-SA license
Free Trainings @ Software University
 Software University Foundation – softuni.org
 Software University – High-Quality Education,
Profession and Job for Software Developers
 softuni.bg
 Software University @ Facebook
 facebook.com/SoftwareUniversity
 Software University @ YouTube
 youtube.com/SoftwareUniversity
 Software University Forums – forum.softuni.bg

More Related Content

PPTX
21. Java High Quality Programming Code
PPT
0. Course Introduction
PDF
Object oriented-programming-in-c-sharp
PPT
Introduction to c_sharp
PPTX
Introduction To C#
PDF
C# c# for beginners crash course master c# programming fast and easy today
PPTX
Selenium online training
PPT
C#.NET
21. Java High Quality Programming Code
0. Course Introduction
Object oriented-programming-in-c-sharp
Introduction to c_sharp
Introduction To C#
C# c# for beginners crash course master c# programming fast and easy today
Selenium online training
C#.NET

What's hot (17)

PPTX
.NET and C# introduction
PPTX
Java vs python
PPTX
Introduction to c#
PPT
Programming in c#
PPT
c#.Net Windows application
PPT
Nakov - .NET Framework Overview - English
PPTX
Introduction to vb.net
PPTX
01 intro to programming in .net
PPTX
C# programming language
PPTX
.Net language support
PPTX
Introduction of .net framework
PPTX
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
PPTX
Java v/s .NET - Which is Better?
PPT
Lecture 10 software development
PPT
Java for C++ programers
PDF
Delphi developer certification study guide
PPTX
Introduction to .NET Framework and C# (English)
.NET and C# introduction
Java vs python
Introduction to c#
Programming in c#
c#.Net Windows application
Nakov - .NET Framework Overview - English
Introduction to vb.net
01 intro to programming in .net
C# programming language
.Net language support
Introduction of .net framework
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
Java v/s .NET - Which is Better?
Lecture 10 software development
Java for C++ programers
Delphi developer certification study guide
Introduction to .NET Framework and C# (English)
Ad

Similar to 21. High-Quality Programming Code (20)

PDF
高品質軟體的基本動作 101 + 102 for NUU
PDF
高品質軟體的基本動作 101 for NTHU
PPTX
Writing High Quality Code in C#
PPTX
Improving Code Quality Through Effective Review Process
PDF
caring_about_code_quality
PDF
Clean Code. An Agile Guide to Software Craft Kameron H.
PPTX
Importance of the quality of code
PDF
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
PDF
Software Quality without Testing
PDF
Writing High Quality Code
PPTX
Coding standards
PPT
Writing Quality Code
PDF
Caring about Code Quality
PPTX
Best-Practices-in-Writing-Clean-Maintainable-Code
PDF
Clean Code. An Agile Guide to Software Craft Kameron H.
PDF
Clean Code. An Agile Guide to Software Craft Kameron H.
PDF
Source Code Quality
PPT
Clean Code summary
PPT
Producing Quality Software
PPTX
Best-Practices-for-Writing-Clean-Code.Presentation
高品質軟體的基本動作 101 + 102 for NUU
高品質軟體的基本動作 101 for NTHU
Writing High Quality Code in C#
Improving Code Quality Through Effective Review Process
caring_about_code_quality
Clean Code. An Agile Guide to Software Craft Kameron H.
Importance of the quality of code
[DevDay2018] Let’s all get along. Clean Code please! - By: Christophe K. Ngo,...
Software Quality without Testing
Writing High Quality Code
Coding standards
Writing Quality Code
Caring about Code Quality
Best-Practices-in-Writing-Clean-Maintainable-Code
Clean Code. An Agile Guide to Software Craft Kameron H.
Clean Code. An Agile Guide to Software Craft Kameron H.
Source Code Quality
Clean Code summary
Producing Quality Software
Best-Practices-for-Writing-Clean-Code.Presentation
Ad

More from Intro C# Book (20)

PPTX
17. Java data structures trees representation and traversal
PPTX
Java Problem solving
PPTX
20.5 Java polymorphism
PPTX
20.4 Java interfaces and abstraction
PPTX
20.3 Java encapsulation
PPTX
20.2 Java inheritance
PPTX
20.1 Java working with abstraction
PPTX
19. Java data structures algorithms and complexity
PPTX
18. Java associative arrays
PPTX
16. Java stacks and queues
PPTX
14. Java defining classes
PPTX
13. Java text processing
PPTX
12. Java Exceptions and error handling
PPTX
11. Java Objects and classes
PPTX
09. Java Methods
PPTX
05. Java Loops Methods and Classes
PPTX
07. Java Array, Set and Maps
PPTX
03 and 04 .Operators, Expressions, working with the console and conditional s...
PPTX
02. Data Types and variables
PPTX
01. Introduction to programming with java
17. Java data structures trees representation and traversal
Java Problem solving
20.5 Java polymorphism
20.4 Java interfaces and abstraction
20.3 Java encapsulation
20.2 Java inheritance
20.1 Java working with abstraction
19. Java data structures algorithms and complexity
18. Java associative arrays
16. Java stacks and queues
14. Java defining classes
13. Java text processing
12. Java Exceptions and error handling
11. Java Objects and classes
09. Java Methods
05. Java Loops Methods and Classes
07. Java Array, Set and Maps
03 and 04 .Operators, Expressions, working with the console and conditional s...
02. Data Types and variables
01. Introduction to programming with java

Recently uploaded (20)

PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PPT
256065457-Anaesthesia-in-Liver-Disease-Patient.ppt
PPTX
SEO Trends in 2025 | B3AITS - Bow & 3 Arrows IT Solutions
PDF
Behind the Smile Unmasking Ken Childs and the Quiet Trail of Deceit Left in H...
PPTX
innovation process that make everything different.pptx
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPTX
Introduction to Information and Communication Technology
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
www-codemechsolutions-com-whatwedo-cloud-application-migration-services.pdf
PDF
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
PPTX
ENCOR_Chapter_10 - OSPFv3 Attribution.pptx
PDF
Dantes Peak Lessons English About Dantes Peak Lessons English About
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
PPTX
CSharp_Syntax_Basics.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPTX
nagasai stick diagrams in very large scale integratiom.pptx
introduction about ICD -10 & ICD-11 ppt.pptx
Decoding a Decade: 10 Years of Applied CTI Discipline
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
256065457-Anaesthesia-in-Liver-Disease-Patient.ppt
SEO Trends in 2025 | B3AITS - Bow & 3 Arrows IT Solutions
Behind the Smile Unmasking Ken Childs and the Quiet Trail of Deceit Left in H...
innovation process that make everything different.pptx
RPKI Status Update, presented by Makito Lay at IDNOG 10
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Introduction to Information and Communication Technology
Slides PDF The World Game (s) Eco Economic Epochs.pdf
www-codemechsolutions-com-whatwedo-cloud-application-migration-services.pdf
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
ENCOR_Chapter_10 - OSPFv3 Attribution.pptx
Dantes Peak Lessons English About Dantes Peak Lessons English About
Job_Card_System_Styled_lorem_ipsum_.pptx
LABUAN4D EXCLUSIVE SERVER STAR GAMING ASIA NO.1
CSharp_Syntax_Basics.pptxxxxxxxxxxxxxxxxxxxxxxxxxxxx
522797556-Unit-2-Temperature-measurement-1-1.pptx
nagasai stick diagrams in very large scale integratiom.pptx

21. High-Quality Programming Code

  • 1. High-Quality Programming Code Code Correctness, Readability, Maintainability Svetlin Nakov Technical Trainer www.nakov.com Software University http://softuni.bg
  • 2. 2  Why Quality Is Important?  Software Quality: External and Internal  What is High-Quality Code?  Code Conventions  Managing Complexity  Characteristics of Quality Code Table of Contents
  • 4. 4  What does this code do? Is it correct? Why Quality Is Important? static void Main() { int value=010, i=5, w; switch(value){case 10:w=5;Console.WriteLine(w);break;case 9:i=0;break; case 8:Console.WriteLine("8 ");break; default:Console.WriteLine("def ");{ Console.WriteLine("hoho "); } for (int k = 0; k < i; k++, Console.WriteLine(k - 'f'));break;} { Console.WriteLine("loop!"); } }
  • 5. 5  Now the code is formatted, but is still unclear. Why Quality Is Important? (2) static void Main() { int value = 010, i = 5, w; switch (value) { case 10: w = 5; Console.WriteLine(w); break; case 9: i = 0; break; case 8: Console.WriteLine("8 "); break; default: Console.WriteLine("def "); Console.WriteLine("hoho "); for (int k = 0; k < i; k++, Console.WriteLine(k - 'f')) ; break; } Console.WriteLine("loop!"); }
  • 6. 6  External quality  Does the software behave correctly?  Are the produced results correct?  Does the software run fast?  Is the software UI easy-to-use?  Is the code secure enough?  Internal quality  Is the code easy to read and understand?  Is the code well structured?  Is the code easy to modify? Software Quality
  • 7. 7  High-quality programming code:  Easy to read and understand  Easy to modify and maintain  Correct behavior in all cases  Well tested  Well architectured and designed  Well documented  Self-documenting code  Well formatted What is High-Quality Programming Code?
  • 8. 8  High-quality programming code:  Strong cohesion at all levels: modules, classes, methods, etc.  Single unit is responsible for single task  Loose coupling between modules, classes, methods, etc.  Units are independent one of another  Good formatting  Good names for classes, methods, variables, etc.  Self-documenting code style What is High-Quality Programming Code? (2)
  • 10. 10  Code conventions are formal guidelines about the style of the source code:  Code formatting conventions  Indentation, whitespace, etc.  Naming conventions  PascalCase or camelCase, prefixes, suffixes, etc.  Best practices  Classes, interfaces, enumerations, structures, inheritance, exceptions, properties, events, constructors, fields, operators, etc. Code Conventions
  • 11. 11  Microsoft official C# code conventions  Design Guidelines for Developing Class Libraries: http://msdn.microsoft.com/en-us/library/ms229042.aspx  Java official code conventions  http://www.oracle.com/technetwork/java/codeconvtoc-136057.html  Semi-official JavaScript code conventions  http://javascript.crockford.com/code.html, http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml  Semi-official PHP conventions  http://www.php-fig.org/psr/psr-1/ Code Conventions (2)
  • 13. 13  Managing complexity has central role in software construction  Minimize the amount of complexity that anyone’s brain has to deal with at certain time  Architecture and design challenges  Design modules and classes to reduce complexity  Code construction challenges  Apply good software construction practices: classes, methods, variables, naming, statements, error handling, formatting, comments, etc. Managing Complexity
  • 14. 14  Key to being an effective programmer:  Maximizing the portion of a program that you can safely ignore  While working on any one section of code  Most practices discussed later propose ways to achieve this important goal Managing Complexity (2)
  • 16. 16  Correct behavior  Conforming to the requirements  Stable, no hangs, no crashes  Bug free – works as expected  Correct response to incorrect usage  Readable – easy to read  Understandable – self-documenting  Maintainable – easy to modify when required Key Characteristics of High-Quality Code
  • 17. 17  Good identifiers names  Good names for variables, constants, methods, parameters, classes, structures, fields, properties, interfaces, structures, enumerations, namespaces,  High-quality classes, interfaces and class hierarchies  Good abstraction and encapsulation  Simplicity, reusability, minimal complexity  Strong cohesion, loose coupling Key Characteristics of High-Quality Code (2)
  • 18. 18  High-quality methods  Reduced complexity, improved readability  Good method names and parameter names  Strong cohesion, loose coupling  Variables, data, expressions and constants  Minimal variable scope, span, live time  Simple expressions  Correctly used constants  Correctly organized data Key Characteristics of High-Quality Code (3)
  • 19. 19  Correctly used control structures  Simple statements  Simple conditional statements and simple conditions  Well organized loops without deep nesting  Good code formatting  Reflecting the logical structure of the program  Good formatting of classes, methods, blocks, whitespace, long lines, alignment, etc. Key Characteristics of High-Quality Code (4)
  • 20. 20  High-quality documentation and comments  Effective comments  Self-documenting code  Defensive programming and exceptions  Ubiquitous use of defensive programming  Well organized exception handling  Code tuning and optimization  Quality code instead of good performance  Code performance when required Key Characteristics of High-Quality Code (5)
  • 21. 21  Following the corporate code conventions  Formatting and style, naming, etc.  Domain-specific best practices  Well tested and reviewed  Testable code  Well designed unit tests  Tests for all scenarios  High code coverage  Passed code reviews and inspections Key Characteristics of High-Quality Code (6)
  • 22. 22 1. Classes define specific structure for objects  Objects are particular instances of a class 2. Classes define fields, methods, constructors, 3. properties and other members  Access modifiers limit the access to class members 4. Constructors are invoked when creating new class instances and initialize the object's internal state 5. Properties expose the class data in safe, controlled way Summary
  • 24. License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" license 24  Attribution: this work may contain portions from  "High Quality Code" course by Telerik Academy under CC-BY-NC-SA license
  • 25. Free Trainings @ Software University  Software University Foundation – softuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg  Software University @ Facebook  facebook.com/SoftwareUniversity  Software University @ YouTube  youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bg