High-Quality Programming Code Code Correctness, Readability, Maintainability Svetlin Nakov Technical Trainer Software University

Slides:



Advertisements
Similar presentations
Code Correctness, Readability, Maintainability Svetlin Nakov Telerik Corporation
Advertisements

JavaScript Basics Course Introduction SoftUni Team Technical Trainers Software University
Software Quality Assurance QA Engineering, Testing, Bug Tracking, Test Automation Software University Technical Trainers SoftUni Team.
 Dimitar Ivanov Introduction to programming with microcontrollers.
C# Advanced Topics Methods, Classes and Objects SoftUni Team Technical Trainers Software University
AngularJS Routing Routes, Route Parameters, Templates, Location, Navigation SoftUni Team Technical Trainers Software University
AngularJS Services Built-in and Custom Services SoftUni Team Technical Trainers Software University
Methods Writing and using methods, overloads, ref, out SoftUni Team Technical Trainers Software University
Software University Curriculum, Courses, Exams, Jobs SoftUni Team Technical Trainers Software University
Fundamentals SoftUni Welcome to Software University SoftUni Team Technical Trainers Software University
Code Correctness, Readability, Maintainability Telerik Software Academy Telerik School.
Advanced JavaScript Course Introduction SoftUni Team Technical Trainers Software University
Project Tracking Tools Trello, Asana, Basecamp, GitHub Issue Tracker, TRAC SoftUni Team Technical Trainers Software University
AngularJS Directives Defining Custom Directives SoftUni Team Technical Trainers Software University
Software Testing Lifecycle Exit Criteria Evaluation, Continuous Integration Ivan Yonkov Technical Trainer Software University.
Design Patterns: Structural Design Patterns
High-Quality Programming Code Code Correctness, Readability, Maintainability, Testability, Etc. SoftUni Team Technical Trainers Software University
JavaScript Design Patterns Private Fields, Module, Revealing Module, Revealing Prototype, … Software University Technical Trainers SoftUni.
NoSQL Databases NoSQL Concepts SoftUni Team Technical Trainers Software University
Quality Code academy.zariba.com 1. Lecture Content 1.Software Quality 2.Code Formatting 3.Correct Naming 4.Documentation and Comments 5.Variables, Expressions.
Conditional Statements Implementing Control-Flow Logic in C# SoftUni Team Technical Trainers Software University
Composer packages Installing and Using Composer, Packagist, Packaging your code Mario Peshev Technical Trainer Software University
Loops Repeating Code Multiple Times SoftUni Team Technical Trainers Software University
Database APIs and Wrappers
Entity Framework Performance SoftUni Team Technical Trainers Software University
Svetlin Nakov Technical Trainer Software University
Build Processes and Continuous Integration Automating Build Processes Software University Technical Trainers SoftUni Team.
Code Correctness, Readability, Maintainability Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Processing Redis with.NET How to Operate with Redis Databases SoftUni Team Technical Trainers Software University
Project Tracking Tools Trello, Asana, Basecamp, GitHub Issue Tracker, TRAC Angel Georgiev Part-time Trainer Software University
Test-Driven Development Learn the "Test First" Approach to Coding SoftUni Team Technical Trainers Software University
Defining Classes Classes, Fields, Constructors, Methods, Properties SoftUni Team Technical Trainers Software University
Functions Reusable Parts of Code SoftUni Team Technical Trainers Software University
Static Members and Namespaces Static Members, Indexers, Operators, Namespaces SoftUni Team Technical Trainers Software University
JavaScript Basics Course Introduction Svetlin Nakov Technical Trainer Software University
Controllers and Markup Controllers, $scope, Markup, Directives, Expressions, Binding, Filters, Validation SoftUni Team Technical Trainers Software University.
AMD and RequireJS Splitting JavaScript Code into Dependent Modules Software University Technical Trainers SoftUni Team.
Asynchronous Web Services Writing Asynchronous Web Services SoftUni Team Technical Trainers Software University
Defining Classes Classes, Fields, Constructors, Methods, Properties Svetlin Nakov Technical Trainer Software University
Jekyll Static Site Generator Template-Based Site Generation Svetlin Nakov Technical Trainer Software University
Code Formatting Correctly Formatting the Source Code Svetlin Nakov Technical Trainer Software University
JavaScript Modules and Patterns Private Fields, Module, Revealing Module, Revealing Prototype, … Software University Technical Trainers.
Responsive Design Design that Adapts to Different Devices SoftUni Team Technical Trainers Software University
Processing JSON in.NET JSON, JSON.NET LINQ-to-JSON and JSON to XML SoftUni Team Technical Trainers Software University
Tables, Rows, Columns, Cells, Header, Footer, Colspan, Rowspan
High-Quality Code: Course Introduction Course Introduction SoftUni Team Technical Trainers Software University
Design Patterns: Structural Design Patterns General and reusable solutions to common problems in software design Software University
Events Event Handling in JavaScript SoftUni Team Technical Trainers Software University
Object-Oriented Programming Course Introduction Svetlin Nakov Technical Trainer Software University
Reflection Programming under the hood SoftUni Team Technical Trainers Software University
Mocking with Moq Tools for Easier Unit Testing SoftUni Team Technical Trainers Software University
Design Patterns: Behavioral Design Patterns General and reusable solutions to common problems in software design Software University
Code Formatting Formatting the Source Code Correctly SoftUni Team Technical Trainers Software University
Mocking Unit Testing Methods with External Dependencies SoftUni Team Technical Trainers Software University
Mocking with Moq Mocking tools for easier unit testing Svetlin Nakov Technical Trainer Software University
Test-Driven Development Learn the "Test First" Approach to Coding Svetlin Nakov Technical Trainer Software University
Sets, Dictionaries SoftUni Team Technical Trainers Software University
High-Quality Code: Course Introduction Course Introduction SoftUni Team Technical Trainers Software University
Functional Programming Data Aggregation and Nested Queries Ivan Yonkov Technical Trainer Software University
Programming Fundamentals Course Introduction SoftUni Team Technical Trainers Software University
Doctrine The PHP ORM SoftUni Team Technical Trainers Software University
Creating Content Defining Topic, Creating Technical Training Materials SoftUni Team Technical Trainers Software University
First Steps in PHP Creating Very Simple PHP Scripts SoftUni Team Technical Trainers Software University
AngularJS Best Practices High Quality SPA Applications SoftUni Team Technical Trainers Software University
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
Static Members Static Variables & Methods SoftUni Team Technical Trainers Software University
Stacks and Queues Processing Sequences of Elements SoftUni Team Technical Trainers Software University
Generics SoftUni Team Technical Trainers Software University
High-Quality Programming Code Code Correctness, Readability, Maintainability, Testability, Etc. SoftUni Team Technical Trainers Software University
Extending functionality using Collections
Presentation transcript:

High-Quality Programming Code Code Correctness, Readability, Maintainability Svetlin Nakov Technical Trainer Software University

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; int value=010, i=5, w; switch(value){case 10:w=5;Console.WriteLine(w);break;case 9:i=0;break; switch(value){case 10:w=5;Console.WriteLine(w);break;case 9:i=0;break; case 8:Console.WriteLine("8 ");break; case 8:Console.WriteLine("8 ");break; default:Console.WriteLine("def ");{ default:Console.WriteLine("def ");{ Console.WriteLine("hoho ");} Console.WriteLine("hoho ");} for (int k = 0; k < i; k++, Console.WriteLine(k - 'f'));break;} { Console.WriteLine("loop!"); } 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; int value = 010, i = 5, w; switch (value) switch (value) { case 10: w = 5; Console.WriteLine(w); break; case 10: w = 5; Console.WriteLine(w); break; case 9: i = 0; break; case 9: i = 0; break; case 8: Console.WriteLine("8 "); break; case 8: Console.WriteLine("8 "); break; default: default: Console.WriteLine("def "); Console.WriteLine("def "); Console.WriteLine("hoho "); Console.WriteLine("hoho "); for (int k = 0; k < i; k++, for (int k = 0; k < i; k++, Console.WriteLine(k - 'f')) ; Console.WriteLine(k - 'f')) ; break; break; } Console.WriteLine("loop!"); 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:  Java official code conventions  http :// http ://  Semi-official JavaScript code conventions   Semi-official PHP conventions  http :// http :// 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

? ? ? ? ? ? ? ? ? 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" licenseCreative Commons Attribution- NonCommercial-ShareAlike 4.0 International 24  Attribution: this work may contain portions from  "High Quality Code" course by Telerik Academy under CC-BY-NC-SA licenseHigh Quality CodeCC-BY-NC-SA

Free Software University  Software University Foundation – softuni.orgsoftuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg softuni.bg  Software Facebook  facebook.com/SoftwareUniversity facebook.com/SoftwareUniversity  Software YouTube  youtube.com/SoftwareUniversity youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bgforum.softuni.bg