1
Code Review CODEsign
Hard coding (also, hard-coding or
hardcoding) refers to the software
development practice of embedding what
may, perhaps only in retrospect, be
regarded as input or configuration data
directly into the source code of a program
or other executable object.
http://en.wikipedia.org/wiki/Anti-pattern
max@kleiner.com
2
Design &
Runtime
Technische
Anforderungen
Fachliche
Anforderungen
Q-Anforderungen
Fachmodell Architekturkonzept
Funktionsmuster
reference,
links
Packages, IAD
configuration
Process, Rules, GUI Settings,
Objects, Options, Profiles
Use Case, Activity
Code Review Topics
Analyse
data/function/object
layer
source code
DB, XML,
properties
literals, res, values
Developer,
Admin,
User
3
Code Layers
Model
4
Report Result
Content
Inhaltsverzeichnis
1 Zweck des Dokuments 4
2 Management-Übersicht 4
3 Ausgangslage 4
4 Befunde 5
4.1 Erläuterung Klassifikationsschema 5
4.2 Clean Code 7
4.3 Code Conventions 10
4.3.1 Übergreifend 10
4.3.2 Delphi 11
4.3.3 C# /Java 12
4.3.4 PL/SQL 16
4.4 Programmierstil 19
4.5 Einsatz von 3rd Party Libraries 21
4.6 Verwendung einer Standard Library 23
4.7 Exception Handling 25
4.8 Rechtschreibung 26
4.9 Dokumentation im Source Code 27
4.10 Testabdeckung 28
4.11 OOP-Prinzipien 29
4.12 Verwendung Frameworks 31
4.13 Verwendung Components 32
4.14 Dokumentation ausserhalb Source Code 34
5 Empfohlene Massnahmen 37
5.1 Etablieren von Continuous Inspection 37
5.2 Bearbeitung von Befunden 38
6 Anhang 39
6.1 Systemtopologie 39
6.2 Pattern und Metrics of Methods 39
6.3 VCL or Composite Application Library (CAL) 40
5
Rules
• CA1303: Do not pass literals as localized
parameters
• public void TimeMethod(int hour, int minute)
{ if (hour < 0 || hour > 23) { MessageBox.Show( "The valid range is 0 -
23."); //CA1303 fires because the parameter for method Show is Text }
• CA1302: Do not hardcode locale specific
strings
• static void Main()
{ string string0 = "C:";
• PMD: Avoid duplicate literals (string or numeric)
6
Found
• new Regex(@"(COM,s*IMAX)s*:s*((?<pub>[ws-/]
+|?),s*(?<istar>[ws-/]+|?))");
• command.CommandText = "select [Name], [EntityNote],
[Package], [Stereotype] from [Tabelle1$]";
• var colmXIstar = dataTable.Columns.Add("IMAXSTAR");
• [DataContract(Namespace="http://CH.MX.maXbox.Demo")]
• public class ServiceFault }
• throws-Declaration: 'DataAccessException‘, catch
(Exception e) {
• 1214: LOGGER.error("Setup Fehler", e);
7
Checks
QS Review Checklist
**********************************************************
1. Standards - are name conventions being followed?
2. Bugs Reports- Are the changes generally correct?
3. Are the Requirements Well Understood (Multilang)?
4. Are all program headers completed?
5. Are code changes commented appropriately?
6. Does documentation use Correct Diagrams or Grammar?
7. Are release notes Clear? Complete?
8. Installation Issues, Licenses, Certs. Are there any?
9. Version and Build Control, Are output products clear?
10.Test Coverage Instructions - Are they any? Complete?
http://www.softwareschule.ch/download/codesign_2015.pdf
8
Metrics
QS Metric Checklist
**********************************************************
Metrics Code Reviews deal with Bad Structure
• General Code Size (in module)
• Cohesion (in classes and inheritance)
• Complexity
• Coupling (between classes or units)
• Cyclic Dependency, Declare+Definition, ACD-Metric
• Interfaces or Packages (design & runtime)
• Static, Public, Private (inheritance or delegate)
• Quantify your code
• Highlight Redesign Needs
• Change Impact Analysis
9
Solution
• Continuous Inspection We had a dream :
mvn sonar:sonar & together

Codereview Topics

  • 1.
    1 Code Review CODEsign Hardcoding (also, hard-coding or hardcoding) refers to the software development practice of embedding what may, perhaps only in retrospect, be regarded as input or configuration data directly into the source code of a program or other executable object. http://en.wikipedia.org/wiki/Anti-pattern max@kleiner.com
  • 2.
    2 Design & Runtime Technische Anforderungen Fachliche Anforderungen Q-Anforderungen Fachmodell Architekturkonzept Funktionsmuster reference, links Packages,IAD configuration Process, Rules, GUI Settings, Objects, Options, Profiles Use Case, Activity Code Review Topics Analyse data/function/object layer source code DB, XML, properties literals, res, values Developer, Admin, User
  • 3.
  • 4.
    4 Report Result Content Inhaltsverzeichnis 1 Zweckdes Dokuments 4 2 Management-Übersicht 4 3 Ausgangslage 4 4 Befunde 5 4.1 Erläuterung Klassifikationsschema 5 4.2 Clean Code 7 4.3 Code Conventions 10 4.3.1 Übergreifend 10 4.3.2 Delphi 11 4.3.3 C# /Java 12 4.3.4 PL/SQL 16 4.4 Programmierstil 19 4.5 Einsatz von 3rd Party Libraries 21 4.6 Verwendung einer Standard Library 23 4.7 Exception Handling 25 4.8 Rechtschreibung 26 4.9 Dokumentation im Source Code 27 4.10 Testabdeckung 28 4.11 OOP-Prinzipien 29 4.12 Verwendung Frameworks 31 4.13 Verwendung Components 32 4.14 Dokumentation ausserhalb Source Code 34 5 Empfohlene Massnahmen 37 5.1 Etablieren von Continuous Inspection 37 5.2 Bearbeitung von Befunden 38 6 Anhang 39 6.1 Systemtopologie 39 6.2 Pattern und Metrics of Methods 39 6.3 VCL or Composite Application Library (CAL) 40
  • 5.
    5 Rules • CA1303: Donot pass literals as localized parameters • public void TimeMethod(int hour, int minute) { if (hour < 0 || hour > 23) { MessageBox.Show( "The valid range is 0 - 23."); //CA1303 fires because the parameter for method Show is Text } • CA1302: Do not hardcode locale specific strings • static void Main() { string string0 = "C:"; • PMD: Avoid duplicate literals (string or numeric)
  • 6.
    6 Found • new Regex(@"(COM,s*IMAX)s*:s*((?<pub>[ws-/] +|?),s*(?<istar>[ws-/]+|?))"); •command.CommandText = "select [Name], [EntityNote], [Package], [Stereotype] from [Tabelle1$]"; • var colmXIstar = dataTable.Columns.Add("IMAXSTAR"); • [DataContract(Namespace="http://CH.MX.maXbox.Demo")] • public class ServiceFault } • throws-Declaration: 'DataAccessException‘, catch (Exception e) { • 1214: LOGGER.error("Setup Fehler", e);
  • 7.
    7 Checks QS Review Checklist ********************************************************** 1.Standards - are name conventions being followed? 2. Bugs Reports- Are the changes generally correct? 3. Are the Requirements Well Understood (Multilang)? 4. Are all program headers completed? 5. Are code changes commented appropriately? 6. Does documentation use Correct Diagrams or Grammar? 7. Are release notes Clear? Complete? 8. Installation Issues, Licenses, Certs. Are there any? 9. Version and Build Control, Are output products clear? 10.Test Coverage Instructions - Are they any? Complete? http://www.softwareschule.ch/download/codesign_2015.pdf
  • 8.
    8 Metrics QS Metric Checklist ********************************************************** MetricsCode Reviews deal with Bad Structure • General Code Size (in module) • Cohesion (in classes and inheritance) • Complexity • Coupling (between classes or units) • Cyclic Dependency, Declare+Definition, ACD-Metric • Interfaces or Packages (design & runtime) • Static, Public, Private (inheritance or delegate) • Quantify your code • Highlight Redesign Needs • Change Impact Analysis
  • 9.
    9 Solution • Continuous InspectionWe had a dream : mvn sonar:sonar & together