SlideShare a Scribd company logo
1 of 28
Coding Standard & Code
Review
                Milan Vukoje
              www.vukoje.net
Soprex
•   SkfOffice2
•   SkfOffice3
•   Big5
•   Quality oriented
•   We are hiring…
Themes
• Coding Standard
• Code Review
• Tools
Coding Standard
• In a complex program, architectural guidelines give the program
  structural balance and construction guidelines provide low-level
  harmony.
• Without a unifying discipline, your creation will be jumble of sloppy
  variations in style.
• One key to successful programming is avoiding arbitrary variations so
  that your brain can be free to focus on the variations that are really
  needed.
  -- Steve McConell
CS Advantages
•   Unified code
•   Faster code understanding/modifying
•   Easier “code smell” identification
•   Cleaner API
•   Avoiding “genius” solutions (KISS)
•   Reducing chances for bugs
•   Real working framework
The Book
• Framework Design Guidelines:
 Conventions, Idioms, and Patterns for Reusable .NET Libraries
 -- Krzysztof Cwalina and Brad Adams
Soprex Coding Standard
•   Code Commenting
•   Naming
•   Code Layout
•   Type Design Guidelines
•   Member Design
•   Exception Management
•   Stored Procedures
•   .NET types usage
Available Tools
•   VS compiler warnings
•   Code Analysis
•   StyleCop
•   TFS check in policy
•   Performance issues
Coding Standard
1. Code Commenting
• DO comment API.
• DO NOT comment whole methods or method
  bodies. If some code is not used, it should be
  deleted.
• DO comment complex methods, especially
  if/else statements.
Coding Standard
2. Property Design
• DO NOT provide set-only properties.
• DO provide sensible default values for all
  properties.
• DO NOT implement time consuming
  operations in properties.
Coding Standard
3. Collections
• DO NOT use weakly typed collections in public APIs.
• DO use ReadOnlyCollection<T> for properties
  representing read-only collections.
• DO NOT return null values from collection properties
  or from methods returning collections
• DO NOT return snapshots collections from properties
Coding Standard
4. Event Design
•   DO use System.EventHandler<T>
•   DO use a return type of void for event handlers
•   DO NOT pass null as the event data ,pass EventArgs.Empty instead.
•   DO use a protected virtual method to raise each event.

    public event EventHandler<AlarmRaisedEventArgs> AlarmRaised;
    protected virtual void OnAlarmRaised (AlarmRaisedEventArgs e) {
        EventHandler<AlarmRaisedEventArgs> handler = AlarmRaised;
         if (handler ! = null ) {
              handler (this, e);
          }
     }
Coding Standard
5. Exception Management
• DO NOT return error codes.
• DO NOT throw or catch System.Exception.
• DO provide a rich and meaningful message text targeted at
  the developer when throwing an exception.
• DO throw an InvalidOperationException if the object is in an
  inappropriate state.
• DO throw ArgumentException or one of its subtypes if bad
  arguments are passed to a member.
• AVOID catching and wrapping nonspecific exceptions.
• DO specify the inner exception when wrapping exceptions.
Rules origin
•   Standardization (Readability)
•   Common mistakes
•   Future bugs
•   OOP best practices
•   API usability
Big Investment?
•   Well… NO!
•   Only for frameworks?
•   Takes to much time?
•   Reduces bugs?
•   Tools are free
Adopting the standard
• Real challenge
• Needs support in upper management and
  team leader determination
• Should everybody agree?
• Redefine what does “done” mean
Getting clean… code
• Start small
  – Add rules incrementally
  – Divide and conquer
• Use tools
• Intensive code reviews
Code Review
Organizing Code Review
• Formal CR
• Informal CR
  – Coding time reviewing
  – Pair programming
  – Code testing with code inspections


• Keep it integrated
What to review?
•   Newbie's code
•   Challenging tasks
•   Spikes
•   Buggy code
•   Architecture significant tasks
•   Widely reused code
Code Review Checklist
•   Clarity
•   Maintainability
•   Accuracy
•   Security
•   Scalability
•   Reusability
•   OOP principles, encapsulation
Advantages
•   Two heads are smarter
•   Collective code ownership
•   Enhances communication and learning
•   Discovering bugs/problems early
Potential problems
• Consumes time
• Focusing on enhancing code rather than
  criticism
• Avoiding general arguments and theoretical
  discussion
• Encouraging positive critics
Tools
• Code smells
• Code Metrics
• TFS Support
Summary
• Programming is hard
• (Clean) Code is very important
• Coding Standard is essential tool
• Code Review takes time but brings many
  advantages
• Requires firm climate change
• Use tools
Questions?




                   Milan Vukoje
               www.vukoje.net
             vukoje@gmail.com
Molimo vas da popunite ankete!
      Please fill out the evaluations!

Vaše mišljenje čini osnovu    Your opinion forms the next
     sledede Sinergije i       Sinergija conference, and it
    omogudava nam da           provides us with the means
oblikujemo sadržaj u skladu     to shape its content to best
     sa Vašim željama.                   suit you.

Svi posetioci koji popune     All attendees that fill out the
 ankete ulaze u nagradnu        evaluations are taking part
            igru                in drawing of special prizes

More Related Content

What's hot

ATDD Using Robot Framework
ATDD Using Robot FrameworkATDD Using Robot Framework
ATDD Using Robot FrameworkPekka Klärck
 
ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019Rory Graves
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit TestingSøren Lund
 
Android Malware and Machine Learning
Android Malware and Machine LearningAndroid Malware and Machine Learning
Android Malware and Machine Learningcaleb194331
 
Android Deobfuscation: Tools and Techniques
Android Deobfuscation: Tools and TechniquesAndroid Deobfuscation: Tools and Techniques
Android Deobfuscation: Tools and Techniquescaleb194331
 
Rails automatic test driven development
Rails automatic test driven developmentRails automatic test driven development
Rails automatic test driven developmenttyler4long
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Søren Lund
 
Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with XtextGlobalLogic Ukraine
 
Jak aspekty uporządkują twój kod.
Jak aspekty uporządkują twój kod.Jak aspekty uporządkują twój kod.
Jak aspekty uporządkują twój kod.Future Processing
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016Søren Lund
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Ganesh Kondal
 
Weaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP libraryWeaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP libraryAlexander Lisachenko
 
Sonar Tool - JAVA code analysis
Sonar Tool - JAVA code analysisSonar Tool - JAVA code analysis
Sonar Tool - JAVA code analysisPrashant Gupta
 

What's hot (20)

Scripting robot
Scripting robotScripting robot
Scripting robot
 
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan PeshovJavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
JavaCro'14 - Test Automation using RobotFramework Libraries – Stojan Peshov
 
Introduction to Robot Framework
Introduction to Robot FrameworkIntroduction to Robot Framework
Introduction to Robot Framework
 
Can you TDD Rails?
Can you TDD Rails?Can you TDD Rails?
Can you TDD Rails?
 
ATDD Using Robot Framework
ATDD Using Robot FrameworkATDD Using Robot Framework
ATDD Using Robot Framework
 
ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019ScalaClean at ScalaSphere 2019
ScalaClean at ScalaSphere 2019
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
Android Malware and Machine Learning
Android Malware and Machine LearningAndroid Malware and Machine Learning
Android Malware and Machine Learning
 
Android Deobfuscation: Tools and Techniques
Android Deobfuscation: Tools and TechniquesAndroid Deobfuscation: Tools and Techniques
Android Deobfuscation: Tools and Techniques
 
Rails automatic test driven development
Rails automatic test driven developmentRails automatic test driven development
Rails automatic test driven development
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016
 
Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with Xtext
 
Cucumber_Training_ForQA
Cucumber_Training_ForQACucumber_Training_ForQA
Cucumber_Training_ForQA
 
Polyglot
PolyglotPolyglot
Polyglot
 
Jak aspekty uporządkują twój kod.
Jak aspekty uporządkują twój kod.Jak aspekty uporządkują twój kod.
Jak aspekty uporządkują twój kod.
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Weaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP libraryWeaving aspects in PHP with the help of Go! AOP library
Weaving aspects in PHP with the help of Go! AOP library
 
Sonar Tool - JAVA code analysis
Sonar Tool - JAVA code analysisSonar Tool - JAVA code analysis
Sonar Tool - JAVA code analysis
 

Viewers also liked

Back to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferBack to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferSebastian Marek
 
PHP Static Code Review
PHP Static Code ReviewPHP Static Code Review
PHP Static Code ReviewDamien Seguy
 
Web UI performance tuning
Web UI performance tuningWeb UI performance tuning
Web UI performance tuningAndy Pemberton
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Damien Seguy
 
Functions - complex first class citizen
Functions - complex first class citizenFunctions - complex first class citizen
Functions - complex first class citizenVytautas Butkus
 
Coding Best practices (PHP)
Coding Best practices (PHP)Coding Best practices (PHP)
Coding Best practices (PHP)Christian Baune
 
Modular & Event driven UI Architecture
Modular & Event driven UI ArchitectureModular & Event driven UI Architecture
Modular & Event driven UI ArchitectureVytautas Butkus
 
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...Rouven Weßling
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesSiarhei Barysiuk
 
Modern Static Code Analysis in PHP
Modern Static Code Analysis in PHPModern Static Code Analysis in PHP
Modern Static Code Analysis in PHPVladimir Reznichenko
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy CodeAdam Culp
 
Component Based UI Architecture - Alex Moldovan
Component Based UI Architecture - Alex MoldovanComponent Based UI Architecture - Alex Moldovan
Component Based UI Architecture - Alex MoldovanITCamp
 
Modern UI Architecture_ Trends and Technologies in Web Development
Modern UI Architecture_ Trends and Technologies in Web DevelopmentModern UI Architecture_ Trends and Technologies in Web Development
Modern UI Architecture_ Trends and Technologies in Web DevelopmentSuresh Patidar
 
UI Architecture & Web Performance
UI Architecture & Web PerformanceUI Architecture & Web Performance
UI Architecture & Web PerformanceKyle Simpson
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelinesLalit Kale
 
Selenium Architecture
Selenium ArchitectureSelenium Architecture
Selenium Architecturerohitnayak
 
Content Design, UI Architecture and Content-UI-Mapping
Content Design, UI Architecture and Content-UI-MappingContent Design, UI Architecture and Content-UI-Mapping
Content Design, UI Architecture and Content-UI-MappingWolfram Nagel
 

Viewers also liked (20)

PHP CODING STANDARDS
PHP CODING STANDARDSPHP CODING STANDARDS
PHP CODING STANDARDS
 
Back to basics - PHP_Codesniffer
Back to basics - PHP_CodesnifferBack to basics - PHP_Codesniffer
Back to basics - PHP_Codesniffer
 
Juniori/Seniori
Juniori/SenioriJuniori/Seniori
Juniori/Seniori
 
PHP Static Code Review
PHP Static Code ReviewPHP Static Code Review
PHP Static Code Review
 
Coding standards php
Coding standards phpCoding standards php
Coding standards php
 
Web UI performance tuning
Web UI performance tuningWeb UI performance tuning
Web UI performance tuning
 
Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)Php Code Audits (PHP UK 2010)
Php Code Audits (PHP UK 2010)
 
Functions - complex first class citizen
Functions - complex first class citizenFunctions - complex first class citizen
Functions - complex first class citizen
 
Coding Best practices (PHP)
Coding Best practices (PHP)Coding Best practices (PHP)
Coding Best practices (PHP)
 
Modular & Event driven UI Architecture
Modular & Event driven UI ArchitectureModular & Event driven UI Architecture
Modular & Event driven UI Architecture
 
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
PHPcon Poland - Static Analysis of PHP Code – How the Heck did I write so man...
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
Modern Static Code Analysis in PHP
Modern Static Code Analysis in PHPModern Static Code Analysis in PHP
Modern Static Code Analysis in PHP
 
Refactoring Legacy Code
Refactoring Legacy CodeRefactoring Legacy Code
Refactoring Legacy Code
 
Component Based UI Architecture - Alex Moldovan
Component Based UI Architecture - Alex MoldovanComponent Based UI Architecture - Alex Moldovan
Component Based UI Architecture - Alex Moldovan
 
Modern UI Architecture_ Trends and Technologies in Web Development
Modern UI Architecture_ Trends and Technologies in Web DevelopmentModern UI Architecture_ Trends and Technologies in Web Development
Modern UI Architecture_ Trends and Technologies in Web Development
 
UI Architecture & Web Performance
UI Architecture & Web PerformanceUI Architecture & Web Performance
UI Architecture & Web Performance
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 
Selenium Architecture
Selenium ArchitectureSelenium Architecture
Selenium Architecture
 
Content Design, UI Architecture and Content-UI-Mapping
Content Design, UI Architecture and Content-UI-MappingContent Design, UI Architecture and Content-UI-Mapping
Content Design, UI Architecture and Content-UI-Mapping
 

Similar to Coding Standard And Code Review

Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersSPC Adriatics
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applicationsnadeembtech
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware ProgrammingPostSharp Technologies
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)Peter Kofler
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET Dmytro Mindra
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Maven Logix
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Hannes Lowette
 
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Theo Jungeblut
 
Ten Advices for Architects
Ten Advices for ArchitectsTen Advices for Architects
Ten Advices for ArchitectsEberhard Wolff
 
10 Hinweise für Architekten
10 Hinweise für Architekten10 Hinweise für Architekten
10 Hinweise für Architektenadesso AG
 
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015Vimal Suba
 
Agile, DevOps & Test
Agile, DevOps & TestAgile, DevOps & Test
Agile, DevOps & TestQualitest
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous IntegrationXPDays
 
Microservices; A Quick Introduction
Microservices; A Quick IntroductionMicroservices; A Quick Introduction
Microservices; A Quick IntroductionAbouzar Noori
 
Lean-Agile SharePoint Development
Lean-Agile SharePoint DevelopmentLean-Agile SharePoint Development
Lean-Agile SharePoint DevelopmentBill Ayers
 
Static Analysis Primer
Static Analysis PrimerStatic Analysis Primer
Static Analysis PrimerCoverity
 

Similar to Coding Standard And Code Review (20)

Lean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill AyersLean-Agile Development with SharePoint - Bill Ayers
Lean-Agile Development with SharePoint - Bill Ayers
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
 
10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming10 Reasons You MUST Consider Pattern-Aware Programming
10 Reasons You MUST Consider Pattern-Aware Programming
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
 
Eurosport's Kodakademi #2
Eurosport's Kodakademi #2Eurosport's Kodakademi #2
Eurosport's Kodakademi #2
 
Agile engineering practices
Agile engineering practicesAgile engineering practices
Agile engineering practices
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
Kku2011
Kku2011Kku2011
Kku2011
 
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
Clean Code III - Software Craftsmanship at SoCal Code Camp San Diego (07/27/2...
 
Ten Advices for Architects
Ten Advices for ArchitectsTen Advices for Architects
Ten Advices for Architects
 
10 Hinweise für Architekten
10 Hinweise für Architekten10 Hinweise für Architekten
10 Hinweise für Architekten
 
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
Cloud and Network Transformation using DevOps methodology : Cisco Live 2015
 
Agile, DevOps & Test
Agile, DevOps & TestAgile, DevOps & Test
Agile, DevOps & Test
 
Code Inspection
Code InspectionCode Inspection
Code Inspection
 
Continuous Integration
Continuous IntegrationContinuous Integration
Continuous Integration
 
Microservices; A Quick Introduction
Microservices; A Quick IntroductionMicroservices; A Quick Introduction
Microservices; A Quick Introduction
 
Lean-Agile SharePoint Development
Lean-Agile SharePoint DevelopmentLean-Agile SharePoint Development
Lean-Agile SharePoint Development
 
Static Analysis Primer
Static Analysis PrimerStatic Analysis Primer
Static Analysis Primer
 

Coding Standard And Code Review

  • 1. Coding Standard & Code Review Milan Vukoje www.vukoje.net
  • 2. Soprex • SkfOffice2 • SkfOffice3 • Big5 • Quality oriented • We are hiring…
  • 3. Themes • Coding Standard • Code Review • Tools
  • 4. Coding Standard • In a complex program, architectural guidelines give the program structural balance and construction guidelines provide low-level harmony. • Without a unifying discipline, your creation will be jumble of sloppy variations in style. • One key to successful programming is avoiding arbitrary variations so that your brain can be free to focus on the variations that are really needed. -- Steve McConell
  • 5. CS Advantages • Unified code • Faster code understanding/modifying • Easier “code smell” identification • Cleaner API • Avoiding “genius” solutions (KISS) • Reducing chances for bugs • Real working framework
  • 6. The Book • Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries -- Krzysztof Cwalina and Brad Adams
  • 7. Soprex Coding Standard • Code Commenting • Naming • Code Layout • Type Design Guidelines • Member Design • Exception Management • Stored Procedures • .NET types usage
  • 8. Available Tools • VS compiler warnings • Code Analysis • StyleCop • TFS check in policy • Performance issues
  • 9. Coding Standard 1. Code Commenting • DO comment API. • DO NOT comment whole methods or method bodies. If some code is not used, it should be deleted. • DO comment complex methods, especially if/else statements.
  • 10. Coding Standard 2. Property Design • DO NOT provide set-only properties. • DO provide sensible default values for all properties. • DO NOT implement time consuming operations in properties.
  • 11. Coding Standard 3. Collections • DO NOT use weakly typed collections in public APIs. • DO use ReadOnlyCollection<T> for properties representing read-only collections. • DO NOT return null values from collection properties or from methods returning collections • DO NOT return snapshots collections from properties
  • 12. Coding Standard 4. Event Design • DO use System.EventHandler<T> • DO use a return type of void for event handlers • DO NOT pass null as the event data ,pass EventArgs.Empty instead. • DO use a protected virtual method to raise each event. public event EventHandler<AlarmRaisedEventArgs> AlarmRaised; protected virtual void OnAlarmRaised (AlarmRaisedEventArgs e) { EventHandler<AlarmRaisedEventArgs> handler = AlarmRaised; if (handler ! = null ) { handler (this, e); } }
  • 13. Coding Standard 5. Exception Management • DO NOT return error codes. • DO NOT throw or catch System.Exception. • DO provide a rich and meaningful message text targeted at the developer when throwing an exception. • DO throw an InvalidOperationException if the object is in an inappropriate state. • DO throw ArgumentException or one of its subtypes if bad arguments are passed to a member. • AVOID catching and wrapping nonspecific exceptions. • DO specify the inner exception when wrapping exceptions.
  • 14. Rules origin • Standardization (Readability) • Common mistakes • Future bugs • OOP best practices • API usability
  • 15. Big Investment? • Well… NO! • Only for frameworks? • Takes to much time? • Reduces bugs? • Tools are free
  • 16. Adopting the standard • Real challenge • Needs support in upper management and team leader determination • Should everybody agree? • Redefine what does “done” mean
  • 17. Getting clean… code • Start small – Add rules incrementally – Divide and conquer • Use tools • Intensive code reviews
  • 19. Organizing Code Review • Formal CR • Informal CR – Coding time reviewing – Pair programming – Code testing with code inspections • Keep it integrated
  • 20. What to review? • Newbie's code • Challenging tasks • Spikes • Buggy code • Architecture significant tasks • Widely reused code
  • 21. Code Review Checklist • Clarity • Maintainability • Accuracy • Security • Scalability • Reusability • OOP principles, encapsulation
  • 22. Advantages • Two heads are smarter • Collective code ownership • Enhances communication and learning • Discovering bugs/problems early
  • 23. Potential problems • Consumes time • Focusing on enhancing code rather than criticism • Avoiding general arguments and theoretical discussion • Encouraging positive critics
  • 24.
  • 25. Tools • Code smells • Code Metrics • TFS Support
  • 26. Summary • Programming is hard • (Clean) Code is very important • Coding Standard is essential tool • Code Review takes time but brings many advantages • Requires firm climate change • Use tools
  • 27. Questions? Milan Vukoje www.vukoje.net vukoje@gmail.com
  • 28. Molimo vas da popunite ankete! Please fill out the evaluations! Vaše mišljenje čini osnovu Your opinion forms the next sledede Sinergije i Sinergija conference, and it omogudava nam da provides us with the means oblikujemo sadržaj u skladu to shape its content to best sa Vašim željama. suit you. Svi posetioci koji popune All attendees that fill out the ankete ulaze u nagradnu evaluations are taking part igru in drawing of special prizes

Editor's Notes

  1. Galvni ralog zasto je Outsourcing u Indiju propao
  2. Rezultat visegodisnjih analizaMS primenjuje za svoje timoveMS generisan kod nije po standardu
  3. Postavku smo izvukli iz knjige, pa smo dodavali pravila kako in nadjemo.
  4. Odlican help za CASuppressionsGreat way to learn .NETU buducnosti automatska modifikacija koda (od strane alata)
  5. Lesevi u kodu
  6. B5 bugDateTime.Now treba da bude metod
  7. . If there is no items for collections return empty c. Properties should return live collections.ollection. This rule implies to DataTable type also.
  8. Objasni lokalnu varijabluDelegati su spori i uzrokuju mnoge probleme (memory leaks)
  9. Da li validirate ulazne argumente?Exceptioni su deo ugovora
  10. Refactoring i code review su vremenske investicije
  11. Problemi formalnog CR-a