ec eclipse overview
play

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


  1. 252-0027 Einführung in die Programmierung Ec Eclipse Overview Luca Della Toffola and Thomas R. Gross Department Informa:k ETH Zürich

  2. To Today Eclipse overview Simple but effec.ve features you may benefit from while developing a program Eclipse debugger Catch your bugs using step-by-step explora.on of your program’s execu.on Debugging I/O + GUI Usage of the debugger with “complex” programs that you may develop for this course Ques:ons & answer(s) You ask I (try to) answer 1

  3. Dem emo 2

  4. Se Select ct w work orkspace ce 3

  5. Ma Main w window 4

  6. Ma Main w window Code editor 5

  7. Ma Main w window Program’s I/O console 6

  8. Ma Main w window Types and methods view 7

  9. Ma Main w window Files view 8

  10. Ec Eclipse light/dark 9

  11. Ec Eclipse light/dark 10

  12. Or Organize “Run Confi figu gura0ons” s” 11

  13. Or Organize “Run Confi figu gura0ons” s” 12

  14. Or Organize “Run Confi figu gura0ons” s” Set your program’s arguments Select tab and check next slide 13

  15. Or Organize “Run Confi figu gura0ons” s” Write here the program’s arguments They will be set as the content of the method main parameter String[] args 14

  16. Dem emo (do done) ne) 15

  17. Eclipse debugger Catch your bugs using step-by-step explora7on of your program’s execu7on 16

  18. Wha What is s a de debug bugger? A debugger is a program that allows a developer to inspect another program’s execu8on 17

  19. Whe Where is s my y de debug bugger? 18

  20. Wh Why y I ne need d a de debug bugger? 1 public class Main { 2 3 public static int maxOf(int[] values) { 4 int res = Integer.MAX_VALUE; 5 for ( int i = 0; i < values.length-1; i++) { 6 res = values[i] > res ? values[i] : res; 7 } 8 return res; 9 } 10 11 public static void main(String[] args) { 12 int[] inputs = readConsole(); 13 System.out.println(maxOf(inputs)); 14 } 15 < 1 16 } < 4 < 10 < 3 > 2147483647 19

  21. Wh Why y I ne need d a de debug bugger? 1 public class Main { 2 3 public static int maxOf(int[] values) { 4 int res = Integer.MIN_VALUE; 5 for ( int i = 0; i < values.length-1; i++) { 6 res = values[i] > res ? values[i] : res; 7 } 8 return res; 9 } 10 11 public static void main(String[] args) { 12 int[] inputs = readConsole(); 13 System.out.println(maxOf(inputs)); 14 } 15 < 3 16 } < 1 < 4 < 10 > 4 20

  22. Wh Why y I ne need d a de debug bugger? 1 public class Main { 2 3 public static int maxOf(int[] values) { 4 int res = Integer.MIN_VALUE; 5 for ( int i = 0; i < values.length; i++) { 6 res = values[i] > res ? values[i] : res; 7 } 8 return res; 9 } 10 11 public static void main(String[] args) { 12 int[] inputs = readConsole(); 13 System.out.println(maxOf(inputs)); 14 } 15 < 3 16 } < 1 < 4 < 10 > 10 21

  23. What I can Wha n do do wi with h a de debug bugger? Pause/resume execu:on of the program at each line 1 public class Main { [ Breakpoint] 2 3 public static int maxOf(int[] values) { 4 int res = Integer.MAX_VALUE; 5 for ( int i = 0; i < values.length-1; i++) { 6 res = values[i] > res ? values[i] : res; 7 } 8 return res; 9 } 10 11 public static void main(String[] args) { 12 int[] inputs = readConsole(); 13 System.out.println(maxOf(inputs)); 14 } maxOf 15 16 } values [1, 3, 4, 10] Inspect content of variables res 2147483647 and object fields values main [] args [1, 3, 4, 10] inputs 22

  24. Dem emo 23

  25. Debug ebugger er vi view Method calls 24

  26. Debug ebugger er vi view Code editor (as before) 25

  27. Debug ebugger er vi view Variables inspector 26

  28. Debug ebugger er vi view Program’s I/O console (as before) 27

  29. Pa Pause/resume the debugger 28

  30. St Step-in into/Step ep-over er/Step ep-re return Not needed for now! 29

  31. Br Breakpoi oint types Field watchers Execution stops when field is accessed/modified Method entry/exit Execu1on stops at method boundaries Default Execu1on stops when breakpoint is reached 30

  32. Br Breakpoi oint prop oper, r,es Write here stopping condition (as a simple program) 31

  33. Br Breakpoi oint prop oper, r,es 32

  34. Mod Modify l loc ocal v vari riables ( (pri rimi mi3ve) Change primi/ve value Double-click cell under Value column and write new value 33

  35. Mod Modify l loc ocal v vari riables ( (pri rimi mi3ve) Change primi,ve value When value is modified line turns yellow 34

  36. Mod Modify l loc ocal v vari riables ( (ob objects) Write here expression (as of simple program) 35

  37. Re Refactor: rename variable Rename all usages of a variable at once Right-click on variable use 36

  38. Re Refactor: extract method Extract expression to method Select expression in code + right-click 37

  39. Re Refactor: generate constructor Generate constructor from fields Right-click on field 38

  40. Re Refactor: generate constructor Generate constructor from fields Select fields and then Generate 39

  41. Dem emo (do done) ne) 40

  42. Debug ebuggi ging ng I/ I/O & & GUI UI Problem 3 : search the maximum value in linked-list Problem 2 : y-axis direc/on Problem 1 : read data from complex file 41

  43. Debug ebuggi ging ng I/ I/O & & GUI UI file.csv … 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 … 42

  44. Dem emo 43

  45. Vi Visualize a program’s execu2on h#ps://cscircles.cemc.uwaterloo.ca/java_visualize/ 44

  46. Us Useful l code e ed edit itor colo lor schem eme https://ethanschoonover.com/solarized/ 45

  47. Dem emo (do done) ne) 46

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend