Ec Eclipse Overview
Luca Della Toffola and Thomas R. Gross
252-0027 Einführung in die Programmierung Department Informa:k ETH Zürich
Ec Eclipse Overview Luca Della Toffola and Thomas R. Gross - - PowerPoint PPT Presentation
252-0027 Einfhrung in die Programmierung Ec Eclipse Overview Luca Della Toffola and Thomas R. Gross Department Informa:k ETH Zrich To Today Eclipse overview Simple but effec.ve features you may benefit from while developing a program
Luca Della Toffola and Thomas R. Gross
252-0027 Einführung in die Programmierung Department Informa:k ETH Zürich
1
Simple but effec.ve features you may benefit from while developing a program
Eclipse overview
Catch your bugs using step-by-step explora.on of your program’s execu.on
Eclipse debugger
Usage of the debugger with “complex” programs that you may develop for this course
Debugging I/O + GUI
You ask I (try to) answer
Ques:ons & answer(s)
2
3
4
5
6
7
Types and methods view
8
Files view
9
10
11
12
13
Set your program’s arguments
Select tab and check next slide
14
Write here the program’s arguments
They will be set as the content of the method main parameter String[] args
15
16
Catch your bugs using step-by-step explora7on of your program’s execu7on
Eclipse debugger
17
18
public class Main { public static int maxOf(int[] values) { int res = Integer.MAX_VALUE; for (int i = 0; i < values.length-1; i++) { res = values[i] > res ? values[i] : res; } return res; } public static void main(String[] args) { int[] inputs = readConsole(); System.out.println(maxOf(inputs)); } }
19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
< 1 < 4 < 10 < 3 > 2147483647
public class Main { public static int maxOf(int[] values) { int res = Integer.MIN_VALUE; for (int i = 0; i < values.length-1; i++) { res = values[i] > res ? values[i] : res; } return res; } public static void main(String[] args) { int[] inputs = readConsole(); System.out.println(maxOf(inputs)); } }
20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
< 3 < 1 < 4 < 10 > 4
public class Main { public static int maxOf(int[] values) { int res = Integer.MIN_VALUE; for (int i = 0; i < values.length; i++) { res = values[i] > res ? values[i] : res; } return res; } public static void main(String[] args) { int[] inputs = readConsole(); System.out.println(maxOf(inputs)); } }
21
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
< 3 < 1 < 4 < 10 > 10
public class Main { public static int maxOf(int[] values) { int res = Integer.MAX_VALUE; for (int i = 0; i < values.length-1; i++) { res = values[i] > res ? values[i] : res; } return res; } public static void main(String[] args) { int[] inputs = readConsole(); System.out.println(maxOf(inputs)); } }
22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
maxOf
values res [1, 3, 4, 10] 2147483647
Inspect content of variables and object fields values Pause/resume execu:on
[ Breakpoint]
main
args inputs [] [1, 3, 4, 10]
23
24
Method calls
25
26
Variables inspector
27
Program’s I/O console (as before)
28
29
Not needed for now!
30
Execution stops when field is accessed/modified
Field watchers
Execu1on stops at method boundaries
Method entry/exit
Execu1on stops when breakpoint is reached
Default
31
Write here stopping condition (as a simple program)
32
33
Double-click cell under Value column and write new value
Change primi/ve value
34
When value is modified line turns yellow
Change primi,ve value
35
Write here expression (as of simple program)
36
Rename all usages of a variable at once
Right-click on variable use
37
Extract expression to method
Select expression in code + right-click
38
Generate constructor from fields
Right-click on field
39
Generate constructor from fields
Select fields and then Generate
40
41
Problem 2: y-axis direc/on Problem 1: read data from complex file Problem 3: search the maximum value in linked-list
42
… 2004-12-31 01:00:00 13478.0 2004-12-31 02:00:00 12865.0 2004-12-31 03:00:00 12577.0 2004-12-31 04:00:00 12517.0 2004-12-31 05:00:00 12670.0 2004-12-31 06:00:00 13038.0 2004-12-31 07:00:00 13692.0 2004-12-31 08:00:00 14297.0 2004-12-31 09:00:00 14719.0 2004-12-31 10:00:00 14941.0 2004-12-31 11:00:00 15184.0 2004-12-31 14:00:00 14522.0 …
file.csv
43
44
h#ps://cscircles.cemc.uwaterloo.ca/java_visualize/
45
46