Style checker for JAVA A style checker for

  • Slides: 32
Download presentation
Style checker for JAVA A style checker for JAVA and its application at HU

Style checker for JAVA A style checker for JAVA and its application at HU 25. 08. 05 Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 1

Style checker for JAVA 1. Introduction 2. How to use Assess. Style 3. Experience

Style checker for JAVA 1. Introduction 2. How to use Assess. Style 3. Experience at HU in WS 04 /05 and related work Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 2

Style checker for JAVA Humboldt University Berlin 1 st Semester Introduction to object-oriented programming

Style checker for JAVA Humboldt University Berlin 1 st Semester Introduction to object-oriented programming with Java: • lectures: 64 hours • exercises on paper: 32 hours • lab work: Java programs about 200 students involved, 3 students work as correctors Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 3

Style checker for JAVA Assessment of Java programs at HU by correctors - assistance

Style checker for JAVA Assessment of Java programs at HU by correctors - assistance for correctors and students final grading - Java program compilability correctness programming style Java compiler apply the program to prepared test cases short manual inspection Students final grading covers correctness and programming style Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 4

Style checker for JAVA Tool Assess. Style - assistance for correctors and students Java

Style checker for JAVA Tool Assess. Style - assistance for correctors and students Java program compilability correctness programming style Java compiler apply the program to prepared test cases short manual inspection Tool Assess. Style (since WS 04/05) Source: N. Rocca Diploma thesis, supervisor: K. Bothe Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 5

Style checker for JAVA Tool ‘Assess. Style‘: Style guide checks 48 criterias (check types)

Style checker for JAVA Tool ‘Assess. Style‘: Style guide checks 48 criterias (check types) of good programming style, e. g. • missing empty line • missing white space • wrong indentation • switch without ‘default‘ • method too long • missing comment • too short identifiers • . . . Baile Herculane, 28. 8. – 3. 9. 2005 criterias (check types) U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 6

Style checker for JAVA Tool ‘Assess. Style‘: Style guide checks 48 criterias (checks) of

Style checker for JAVA Tool ‘Assess. Style‘: Style guide checks 48 criterias (checks) of good programming style in the fields, e. g. • White spaces and other optical aspects, e. g. missing empty line missing white space wrong indentation • Statements, e. g. switch without ‘default‘ • Size, length, complexity, e. g. in additional, you method too long can group criterias to • Comments, e. g. mistake types missing comment • Names and declarations, e. g. too short identifiers Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 7

Style checker for JAVA How to use Assess. Style 1. Introduction 2. How to

Style checker for JAVA How to use Assess. Style 1. Introduction 2. How to use Assess. Style 1. Load Java program into the tool 2. Tool automatically checks for style guides 3. Some criteria are checked semi-automatically and some manually 4. Tool automatically computes a metric and a mark according to conformance to style guidelines 5. Tool configuration 3. Experience at HU in WS 04 /05 and related work Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 8

Style checker for JAVA User interface of Assess. Style Set of mistake types D

Style checker for JAVA User interface of Assess. Style Set of mistake types D bad name Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 9

Style checker for JAVA Example of Assess. Style (1) Set of mistake types D

Style checker for JAVA Example of Assess. Style (1) Set of mistake types D D bad name Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 10

Style checker for JAVA Example of Assess. Style (2) D D bad name Baile

Style checker for JAVA Example of Assess. Style (2) D D bad name Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 11

Style checker for JAVA Example of Assess. Style (3) D Baile Herculane, 28. 8.

Style checker for JAVA Example of Assess. Style (3) D Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 12

Style checker for JAVA How to use Assess. Style 1. Introduction 2. How to

Style checker for JAVA How to use Assess. Style 1. Introduction 2. How to use Assess. Style 1. Load Java program into the tool 2. Tool automatically checks for style guides 3. Some criteria are checked semi-automatically and some manually 4. Tool automatically computes a metric and a mark according to conformance to style guidelines 5. Tool configuration 3. Experience at HU in WS 04 /05 and related work Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 13

Style checker for JAVA There are tree kinds of checks: § automatic § semi

Style checker for JAVA There are tree kinds of checks: § automatic § semi automatic § manual Baile Herculane, 28. 8. – 3. 9. 2005 search algorithms are implemented; they are applied generally search algorithms are implemented; the user decides on their application search algorithms are not implemented; the user can mark mistakes manually U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 14

Style checker for JAVA Example of Assess. Style - manual (1) K bad comment

Style checker for JAVA Example of Assess. Style - manual (1) K bad comment bad name Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 15

Style checker for JAVA Example of Assess. Style - manual (2) K bad comment

Style checker for JAVA Example of Assess. Style - manual (2) K bad comment g dra rop d & bad name K Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 16

Style checker for JAVA How to use Assess. Style 1. Introduction 2. How to

Style checker for JAVA How to use Assess. Style 1. Introduction 2. How to use Assess. Style 1. Load Java program into the tool 2. Tool automatically checks for style guides 3. Some criteria are checked semi-automatically and some manually 4. Tool automatically computes a metric and a mark according to conformance to style guidelines 5. Tool configuration 3. Experience at HU in WS 04 /05 and related work Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 17

Style checker for JAVA Tool computes a metric P and a mark Parameters are:

Style checker for JAVA Tool computes a metric P and a mark Parameters are: 1. The weight of particular mistake-types, e. g. missing comment missing empty line bad indentation file too long 4 2 1 9 2. The relation between the mark and the values of P mark 1 2 3 4 5 6 total number P 0 – 20 20 – 40 41 – 60 61 – 80 81 – 100 > 100 Baile Herculane, 28. 8. – 3. 9. 2005 P= f Set of all mistake-types h(f) * g(f) F weight of error f number of errors f in 100 LOC U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 18

Style checker for JAVA Tool has found these mistakes Baile Herculane, 28. 8. –

Style checker for JAVA Tool has found these mistakes Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 19

Style checker for JAVA How to use Assess. Style 1. Introduction 2. How to

Style checker for JAVA How to use Assess. Style 1. Introduction 2. How to use Assess. Style 1. Load Java program into the tool 2. Tool automatically checks for style guides 3. Some criteria are checked semi-automatically and some manually 4. Tool automatically computes a metric and a mark according to conformance to style guidelines 5. Tool configuration 3. Experience at HU in WS 04 /05 and related work Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 20

Style checker for JAVA Tool configuration 1. Selection and configuration of a proper set

Style checker for JAVA Tool configuration 1. Selection and configuration of a proper set of style errors for the lab (mistake types and detailed checks) 2. Weight of particular mistake types 3. Define the mark depending on the value of P Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 21

Style checker for JAVA Tool configuration (1) Set of mistake types you can configure

Style checker for JAVA Tool configuration (1) Set of mistake types you can configure all these with the tool Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 22

Style checker for JAVA Tool configuration (2, 3) 1. Selection and configuration of a

Style checker for JAVA Tool configuration (2, 3) 1. Selection and configuration of a proper set of style errors for the lab (mistake types and detail checks) 2. Weight of particular mistake types, e. g. missing commend missing empty line bad indentation file too long 4 2 1 9 3. Define the mark depending on the value of P total number P 0 – 20 20 – 40 41 – 60 61 – 80 81 – 100 > 100 Baile Herculane, 28. 8. – 3. 9. 2005 mark 1 2 3 4 5 6 you can configure all these whith with the tool U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 23

Style checker for JAVA 1. Introduction 2. How to use Assess. Style 3. Experience

Style checker for JAVA 1. Introduction 2. How to use Assess. Style 3. Experience at HU in WS 04 /05 and related work Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 24

Style checker for JAVA Experience at HU in WS 04 / 05 § §

Style checker for JAVA Experience at HU in WS 04 / 05 § § used by correctors without too much effort used by students as a pre-check of their solutions accepted by correctors and students programming style improved during the semester Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 25

Style checker for JAVA Programming style improved during the semester density (~students) a significant

Style checker for JAVA Programming style improved during the semester density (~students) a significant amount of students has a lot of style error points (P) Figure 1: first Java exercise Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 26

Style checker for JAVA Programming style improved during the semester density (~students) now, almost

Style checker for JAVA Programming style improved during the semester density (~students) now, almost all students have very few error points style error points (P) Figure 2: third Java exercise Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 27

Style checker for JAVA Related work: style check and style assessment Program Operating system

Style checker for JAVA Related work: style check and style assessment Program Operating system GUI File Types Aim of application Assess. Style independent yes Java display of style errors, assessment of style Checkstyle independent no Java display of style errors Artistic Style independent no C, C++, C#, Java yes Java JStyle Praktomat Jalote-Prog. windows web-interface ? Baile Herculane, 28. 8. – 3. 9. 2005 webinterface ? Java, C++ u. a. new formatting display of style errors, metrics function tests and display of style errors, manuell assisted assessment C U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin assessment of style 28

Style checker for JAVA Related work: style check and style assessment Program Operating system

Style checker for JAVA Related work: style check and style assessment Program Operating system GUI File Types Aim of application Assess. Style independent yes Java display of style errors, assessment of style Checkstyle independent no Java display of style errors Artistic Style independent no C, C++, C#, Java yes Java JStyle Praktomat Jalote-Prog. windows web-interface ? Baile Herculane, 28. 8. – 3. 9. 2005 new formatting display of style errors, metrics web- Very good, Java, but function tests and display interface (1000 C++ u. a. / licence) of style errors, manuell - commercial dollar assisted assessment - no assessment + metrics (e. g. Halstead, …) ? C U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin assessment of style 29

Style checker for JAVA Related work: style check and style assessment Program Operating system

Style checker for JAVA Related work: style check and style assessment Program Operating system GUI File Types Aim of application Assess. Style independent yes Java display of style errors, assessment of style Checkstyle independent no Java display of style errors Artistic Style independent no JStyle Praktomat Jalote-Prog. C, C++, C#, Java new formatting windows yes Java display of style errors, It checks very many programming metrics style criterias and it is open source, but web-interface web. Java, function tests and display - no GUI interface C++ u. a. of style errors, manuell - no assessment assisted assessment ? Baile Herculane, 28. 8. – 3. 9. 2005 ? C U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin assessment of style 30

Style checker for JAVA Related work: style check and style assessment Program Operating system

Style checker for JAVA Related work: style check and style assessment Program Operating system GUI File Types Aim of application Assess. Style independent yes Java display of style errors, assessment of style Checkstyle independent no Java display of style errors Artistic Style independent no JStyle Praktomat Jalote-Prog. C, C++, C#, Java new formatting Assess. Style is an windows yes Java display of style errors, enhancement from Checkstyle! metrics + GUI + assessment web-interface web. Java, function tests and display + manual checks interface C++ u. a. of style errors, manuell + statistics, … assisted assessment ? Baile Herculane, 28. 8. – 3. 9. 2005 ? C U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin assessment of style 31

Style checker for JAVA Thank y u f r y ur attenti n! Baile

Style checker for JAVA Thank y u f r y ur attenti n! Baile Herculane, 28. 8. – 3. 9. 2005 U. Sacklowski, Dept. of Comp. Sc. , HU-Berlin 32