Eclipse workshop presentation
-
Upload
miguel-pardal -
Category
Technology
-
view
927 -
download
0
description
Transcript of Eclipse workshop presentation
![Page 1: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/1.jpg)
Eclipse workshop
Jan. 2014
![Page 2: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/2.jpg)
• Miguel Pardal
– LEIC 2000
– Lecturer at Técnico Lisboa
– PhD Student
– http://web.tecnico.ulisboa.pt/miguel.pardal
– Eclipse user since 2005
– Conditional fan
![Page 3: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/3.jpg)
Goal
• Learn the good
• Avoid the bad
• Become a better developer
• Enjoy life!
![Page 4: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/4.jpg)
Outline
• Introduction
– Concepts
– Techniques
• Hands-on
![Page 5: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/5.jpg)
History
• Eclipse started out as proprietary technology
– Object Technology International (OTI)
– IBM’s goals:
• Reduce incompatible environments
• Increase reuse of common components
• Evolved from IBM VisualAge for
Smalltalk™ and for Java™
– Monolithic
http://wiki.eclipse.org/FAQ_Where_did_Eclipse_come_from%3F
![Page 6: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/6.jpg)
History
• The Eclipse open source project was announced in November 2001 by a group of companies that formed the initial Eclipse Consortium– Eclipse Foundation since 2004
• Commercial-friendly open source license– Wider audience and ecosystem
• Eclipse was designed from the ground up as an integration platform for development tools– Everything in Eclipse is a plug-in
– Uses SWT to bind to local platform GUI
– OSGi component model since 3.0
– Annual Simultaneous Release (…, Indigo, Juno, Kepler, …)
![Page 7: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/7.jpg)
Install
• Download
• Unzip
• Run
• All configurations are file-based– workspace folder
• Settings
• Projects
– Project metadata files• .project
• .classpath
![Page 8: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/8.jpg)
CONCEPTS
![Page 9: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/9.jpg)
Workbench
• Eclipse’s main window
– Menus and toolbars
– Views, editors, perspectives
![Page 10: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/10.jpg)
View
• A view is a window that lets you examine
something
– Navigate a list or hierarchy of information
– Display properties for the active editor
• Modifications made in a view are saved
immediately.
![Page 11: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/11.jpg)
Editor
• Editors are used to edit or browse a resource
– Rectangular area in the Workbench window
– Visual presentation might be text or a diagram.
– Editors are launched by clicking on a resource in a view
– Modifications made in an editor follow an open-save-close lifecycle model
• * indicates unsaved data
![Page 12: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/12.jpg)
![Page 13: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/13.jpg)
Perspective
• A perspective is a set of views, editors, and toolbars, along with their arrangement within the Workbench window.
• As you perform a task, you may rearrange windows, new views, and so on.
– Saved under the current perspective.
– Next time, switch to perspective
– Within a window, each perspective may have a different set of views but all perspectives share the same set of editors.
• Built-in Java or Debug perspectives
![Page 14: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/14.jpg)
![Page 15: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/15.jpg)
![Page 16: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/16.jpg)
Java Project
![Page 17: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/17.jpg)
Project properties
![Page 18: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/18.jpg)
Project properties
![Page 19: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/19.jpg)
Auto-complete
• From the current context – project, class,
method, etc – what could complete this?
– CTRL+space
![Page 20: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/20.jpg)
Auto-build
• Compilation is automatic in Eclipse
• Blessing
– Sting s = “Eclipse”;
• Curse
– String s = “Ecli
![Page 21: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/21.jpg)
TECHNIQUES
![Page 22: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/22.jpg)
Factoring
• Create the application domain
• Create class
– Members
– Methods
• Generate methods
– Getters Setters
– toString
![Page 23: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/23.jpg)
Create
![Page 24: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/24.jpg)
Create class
![Page 25: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/25.jpg)
Source menu
![Page 26: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/26.jpg)
Testing
• JUnit Class
• JUnit View
![Page 27: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/27.jpg)
Refactoring
• Refactoring is a process of software source code transformation
– Should be performed when the code is working and all of its tests are passing
– Does not involve rewriting or replacing large chunks of code.
– Gradual, evolutionary process, intended to “preserve the knowledge embedded in the existing code.”
• Examples
– Rename
– Extract method
![Page 28: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/28.jpg)
Refactor menu
![Page 29: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/29.jpg)
Quick fix errors
![Page 30: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/30.jpg)
Quick fix warnings
![Page 31: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/31.jpg)
Implicit class
– Write code as if the class already exists
• Write code referring to non-existing classes
– Use quick-fix to generate class
![Page 32: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/32.jpg)
But beware…
• Quick-fix can become “quick-bug”
• Example
– Try-catch and ignore
• Worst solution
– Try-catch, print and continue
• As if nothing has happened… but it did!
– Think it through:
• Handle exception (try-catch)
• Or let someone else do it (throws)
![Page 33: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/33.jpg)
Conclusions
• Very useful tool
• Can increase productivity
– Code formatting
– Especially in refactoring
• But…
– Does NOT replace critical thought and design
– Can increase the production… of bugs!
![Page 35: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/35.jpg)
Shortcuts
Top 10
![Page 36: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/36.jpg)
10. Shortcut to shortcuts
• Ctrl+Shift+L to see a full list of the
currently available key bindings
![Page 37: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/37.jpg)
9. Open file / type
• Open file quickly without browsing:
Ctrl + Shift + R
• Open a type (class / interface):
Ctrl + Shift + T
![Page 38: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/38.jpg)
8. Show properties
• Select project
Alt+Enter
• Select type/resource
Alt+Enter
![Page 39: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/39.jpg)
7. Maximize editor
• Maximizes current editor
Ctrl + M
• You can also double-click editor tab
![Page 40: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/40.jpg)
6. Editor navigation
• Jump to beginning / end of indention. Twice to jump to beginning of line– Home/End
• Jump to beginning / jump to end of source– Ctrl+Home/End
• Jump one word to the left / one word to the right– Ctrl+Arrow Right/Arrow Left
• Jump to previous / jump to next method– Ctrl+Shift+Arrow Down/Arrow Up
• Jump to next / jump to previous compiler syntax warning or error– Ctrl+./Ctrl+,
• Jump to last location edited– Ctrl+q
• Jump to Line Number– Ctrl+l
• Hide/show line numbers– Ctrl+F10 and select 'Show Line Numbers'
![Page 41: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/41.jpg)
5. Outline view
• Quickly go to class member
Ctrl + O
![Page 42: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/42.jpg)
4. Code formatting
• Ctrl + Shift + F for code formatting
• Ctrl + / for commenting, un commenting
lines and blocks
![Page 43: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/43.jpg)
3. Organize imports
• Organize imports
Ctrl+Shift+O
• Go from:
– import java.util.*
• To:
– import java.util.Map;
– import java.util.Iterator;
![Page 44: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/44.jpg)
2. Print line
• syso Ctrl+space
• syse Ctrl+space
![Page 45: Eclipse workshop presentation](https://reader033.fdocuments.net/reader033/viewer/2022060107/5549f1e3b4c9050d488b54a5/html5/thumbnails/45.jpg)
1. Guess Exception
• throw new NPE Ctrl+space
– NullPointerException
• throw new IAE Ctrl+space
– IllegalArgumentException