Code Correctness, Readability, Maintainability Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer www.nakov.com.

Slides:



Advertisements
Similar presentations
Revealing the Secrets of Self-Documenting Code Svetlin Nakov Telerik Corporation For C# Developers.
Advertisements

Code Correctness, Readability, Maintainability Svetlin Nakov Telerik Corporation
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Chapter 2: Modularization
1 SOFTWARE DESIGN QUALITY COHESION and COUPLING (Part II)
Software Engineering and Design Principles Chapter 1.
Module: Definition ● A logical collection of related program entities ● Not necessarily a physical concept, e.g., file, function, class, package ● Often.
Introduction to Refactoring Excerpted from ‘What is Refactoring?’ by William C. Wake and Refactoring: Improving the Design of Existing Code by Martin Fowler.
Chapter 1 Principles of Programming and Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Design of SCS Architecture, Control and Fault Handling.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
OOP Course Program, Evaluation, Exams, Resources Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Creating and Running Your First C# Program Telerik Software Academy Telerik School Academy.
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 system design 1 what is systems design? preparation of the system’s specifications with.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 Shawlands Academy Higher Computing Software Development Unit.
Planning and Tracking Software Quality.  What Is Software Quality?  Causes of Software Defects  What is Quality Assurance?  Improving the Software.
Course Introduction Svetlin Nakov Telerik Corporation
Code Correctness, Readability, Maintainability Telerik Software Academy Telerik School.
Computer Science 240 © Ken Rodham 2006 Principles of Software Design.
CSE 219 Computer Science III Testing. Testing vs. Debugging Testing: Create and use scenarios which reveal incorrect behaviors –Design of test cases:
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
High-Quality Programming Code Code Correctness, Readability, Maintainability, Testability, Etc. 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.
1 Software Design Reference: Software Engineering, by Ian Sommerville, Ch. 12 & 13, 5 th edition and Ch. 10, 6 th edition.
Course Program, Evaluation, Examination Telerik Software Academy Apps for Windows Phone & Windows Store.
SE: CHAPTER 7 Writing The Program
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Improving the Quality of Existing Code Svetlin Nakov Telerik Corporation
Svetlin Nakov Technical Trainer Software University
C++ History C++ was designed at AT&T Bell Labs by Bjarne Stroustrup in the early 80's Based on the ‘C’ programming language C++ language standardised in.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
Course Program, Evaluation, Exams, Resources Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
OOP Course Program, Evaluation, Exams, Resources Telerik Software Academy Object-Oriented Programming.
The Software Development Process
Comments in the Program and Self-Documenting Code
SOAP-based Web Services Telerik Software Academy Software Quality Assurance.
Revealing the Secrets of Self-Documenting Code Svetlin Nakov Telerik Corporation
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Code Formatting Correctly Formatting the Source Code Svetlin Nakov Technical Trainer Software University
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Design and Planning Or: What’s the next thing we should do for our project?
1 COS 260 DAY 14 Tony Gauvin. 2 Agenda Questions? 6 th Mini quiz graded  Oct 29 –Chapter 6 Assignment 4 will be posted later Today –First two problems.
High-Quality Programming Code Code Correctness, Readability, Maintainability Svetlin Nakov Technical Trainer Software University
High-Quality Code: Course Introduction Course Introduction SoftUni Team Technical Trainers Software University
Chapter 2 Principles of Programming and Software Engineering.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Chapter 10 Software quality. This chapter discusses n Some important properties we want our system to have, specifically correctness and maintainability.
High-Quality Code: Course Introduction Course Introduction SoftUni Team Technical Trainers Software University
Lecture 1 Page 1 CS 111 Summer 2013 Important OS Properties For real operating systems built and used by real people Differs depending on who you are talking.
AngularJS Best Practices High Quality SPA Applications SoftUni Team Technical Trainers Software University
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
Implementation Topics Describe –Characteristics of good implementations –Best practices to achieve them Understand role of comments Learn debugging techniques.
High-Quality Programming Code Code Correctness, Readability, Maintainability, Testability, Etc. SoftUni Team Technical Trainers Software University
Principles of Programming & Software Engineering
7. Modular and structured design
Code Documentation and Comments in the Program
Chapter - 8 Implementation.
Using ASP.NET Master Pages
Object-Oriented Programming: Course Intro
Coupling and Cohesion 1.
Principles of Programming and Software Engineering
Software Quality Engineering
PROGRAMMING METHODOLOGY
Chapter 9: Implementation
Presentation transcript:

Code Correctness, Readability, Maintainability Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer

2  Why Quality Is Important?  Software Quality: External and Internal  What is High-Quality Code?  Code Conventions  Managing Complexity  Characteristics of Quality Code

What does this code do? Is it correct? 4 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!"); }}

Now the code is formatted, but is still unclear. 5 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!");}

 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? 6

 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 7

 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 8

 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. 10

 Microsoft has official C# code conventions  Design Guidelines for Developing Class Libraries:  Semi-official JavaScript code conventions  styleguide.googlecode.com/svn/trunk/javascriptguide.xml styleguide.googlecode.com/svn/trunk/javascriptguide.xml styleguide.googlecode.com/svn/trunk/javascriptguide.xml  Large organization follow strict conventions  Code conventions can vary in different teams  High-quality code goes beyond code conventions  Software quality is a way of thinking! 11

 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. 13

 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 14

 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 16

 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 17

 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 18

 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. 19

 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 20

 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 21

Questions?

 Write a short essay (1-2 pages) on the topic: "What is a High-Quality Programming Code?“  English / Bulgarian  your choice  Submit a Word / PDF file 23

 C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com