style checker for java baile herculane, 28.8. – 3.9.2005 u. sacklowski, dept. of comp. sc.,...

32
Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 1 Style checker for JAVA A style checker for JAVA and its application at HU 25.08.05

Upload: matilda-eaton

Post on 18-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 1

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 2

Style checker for JAVA

1. Introduction

2. How to use AssessStyle

3. Experience at HU in WS 04 /05and related work

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 3

Style checker for JAVA

Humboldt University Berlin1st 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 4

Style checker for JAVA

Students final grading covers correctness and programming

style

Students final grading covers correctness and programming

style

Assessment of Java programs at HU by correctors- assistance for correctors and students final grading -

Java program

compilability correctness programming style

Javacompiler

apply theprogram topreparedtest cases

short manualinspection

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 5

Style checker for JAVA

Tool AssessStyle- assistance for correctors and students -

Java program

compilability correctness programming style

Javacompiler

apply theprogram topreparedtest cases

short manualinspection

ToolAssessStyle(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 6

Style checker for JAVA

• missing empty line• missing white space • wrong indentation• switch without ‘default‘• method too long• missing comment• too short identifiers• . . .

Tool ‘AssessStyle‘: Style guide checks

48 criterias (check types) of good programming style, e. g.

criterias(check types)

criterias(check types)

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 7

Style checker for JAVA

• White spaces and other optical aspects, e.g.missing empty linemissing white spacewrong indentation

• Statements, e. g.switch without ‘default‘

• Size, length, complexity, e. g.method too long

• Comments, e. g.missing comment

• Names and declarations, e. g.too short identifiers

Tool ‘AssessStyle‘: Style guide checks

48 criterias (checks) of good programming style in the fields, e. g.

in additional, you can group criterias

tomistake types

in additional, you can group criterias

tomistake types

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 8

Style checker for JAVA

How to use AssessStyle

1. Introduction

2. How to use AssessStyle1. Load Java program into the tool

2. Tool automatically checks for style guides

3. Some criteria are checked semi-automaticallyand some manually

4. Tool automatically computes a metric and a markaccording to conformance to style guidelines

5. Tool configuration

3. Experience at HU in WS 04 /05and related work

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 9

Style checker for JAVA

User interface of AssessStyle Set of mistake types

bad nameD

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 10

Style checker for JAVA

Example of AssessStyle (1) Set of mistake types

bad nameD

D

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 11

Style checker for JAVA

Example of AssessStyle (2)

bad nameD

D

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 12

Style checker for JAVA

Example of AssessStyle (3)

D

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 13

Style checker for JAVA

How to use AssessStyle

1. Introduction

2. How to use AssessStyle1. Load Java program into the tool

2. Tool automatically checks for style guides

3. Some criteria are checked semi-automaticallyand some manually

4. Tool automatically computes a metric and a markaccording to conformance to style guidelines

5. Tool configuration

3. Experience at HU in WS 04 /05and related work

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 14

Style checker for JAVA

There are tree kinds of checks:

automatic

semi automatic

manual

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

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 15

Style checker for JAVA

Example of AssessStyle - manual (1)

bad name

bad commentK

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 16

Style checker for JAVA

Example of AssessStyle - manual (2)

bad name

bad commentK

K

drag & drop

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 17

Style checker for JAVA

How to use AssessStyle

1. Introduction

2. How to use AssessStyle1. Load Java program into the tool

2. Tool automatically checks for style guides

3. Some criteria are checked semi-automaticallyand some manually

4. Tool automatically computes a metric and a markaccording to conformance to style guidelines

5. Tool configuration

3. Experience at HU in WS 04 /05and related work

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 18

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 4 missing empty line 2 bad indentation 1 file too long 9

2. The relation between the mark and the values of P

P = h(f) * g(f)f F

weight of error f

number of errors fin 100 LOC

Set of all mistake-types

mark total number P

1 0 – 202 20 – 403 41 – 604 61 – 805 81 – 1006 > 100

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 19

Style checker for JAVA

Tool has found these mistakes

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 20

Style checker for JAVA

How to use AssessStyle

1. Introduction

2. How to use AssessStyle1. Load Java program into the tool

2. Tool automatically checks for style guides

3. Some criteria are checked semi-automaticallyand some manually

4. Tool automatically computes a metric and a markaccording to conformance to style guidelines

5. Tool configuration

3. Experience at HU in WS 04 /05and related work

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 21

Style checker for JAVA

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

Tool configuration

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 22

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 23

Style checker for JAVA

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 4 missing empty line 2 bad indentation 1 file too long 9

3. Define the mark depending on the value of P

Tool configuration (2, 3)

total number P mark

0 – 20 120 – 40 241 – 60 361 – 80 481 – 100 5> 100 6

you can configure all these whith the

tool

you can configure all these with the

tool

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 24

Style checker for JAVA

1. Introduction

2. How to use AssessStyle

3. Experience at HU in WS 04 /05and related work

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 25

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 26

Style checker for JAVA

Programming style improved during the semester

Figure 1: first Java exercise

style error points (P)

a significant amount of students has a lot of style error points

den

sity

(~

stud

ents

)

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 27

Style checker for JAVA

Programming style improved during the semester

Figure 2: third Java exercise

style error points (P)

now, almost all students have very

few error points

den

sity

(~

stud

ents

)

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 28

Style checker for JAVA

Related work: style check and style assessment

Program Operating system GUI File Types Aim of application

AssessStyle independent yes Java display of style errors, assessment of style

Checkstyle independent no Java display of style errors

Artistic Style independent no C, C++, new formatting C#, Java

JStyle windows yes Java display of style errors, metrics

Praktomat web-interface web- Java, function tests and display interface C++ u. a. of style errors, manuell assisted assessment

Jalote-Prog. ? ? C assessment of style

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 29

Style checker for JAVA

Related work: style check and style assessment

Program Operating system GUI File Types Aim of application

AssessStyle independent yes Java display of style errors, assessment of style

Checkstyle independent no Java display of style errors

Artistic Style independent no C, C++, new formatting C#, Java

JStyle windows yes Java display of style errors, metrics

Praktomat web-interface web- Java, function tests and display interface C++ u. a. of style errors, manuell assisted assessment

Jalote-Prog. ? ? C assessment of style

Very good, but- commercial (1000 dollar / licence)- no assessment+ metrics (e. g. Halstead, …)

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 30

Style checker for JAVA

Related work: style check and style assessment

Program Operating system GUI File Types Aim of application

AssessStyle independent yes Java display of style errors, assessment of style

Checkstyle independent no Java display of style errors

Artistic Style independent no C, C++, new formatting C#, Java

JStyle windows yes Java display of style errors, metrics

Praktomat web-interface web- Java, function tests and display interface C++ u. a. of style errors, manuell assisted assessment

Jalote-Prog. ? ? C assessment of style

It checks very many programming style criterias and

it is open source, but- no GUI- no assessment

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 31

Style checker for JAVA

Related work: style check and style assessment

Program Operating system GUI File Types Aim of application

AssessStyle independent yes Java display of style errors, assessment of style

Checkstyle independent no Java display of style errors

Artistic Style independent no C, C++, new formatting C#, Java

JStyle windows yes Java display of style errors, metrics

Praktomat web-interface web- Java, function tests and display interface C++ u. a. of style errors, manuell assisted assessment

Jalote-Prog. ? ? C assessment of style

AssessStyle is an enhancement from Checkstyle!+ GUI+ assessment+ manual checks+ statistics, …

Baile Herculane, 28.8. – 3.9.2005 U. Sacklowski, Dept. of Comp. Sc., HU-Berlin 32

Style checker for JAVA

Thank y u f r y ur attenti n!