Upload
trinhxuyen
View
226
Download
0
Embed Size (px)
Citation preview
EclipseSoftware Engineering with an Integrated Development Environment (IDE)
Markus Scheidgen
Agenda
‣ What is eclipse and why bother? - An introduction to eclipse.
‣ eclipse fundamentals
‣ (Java) development with eclipse★ reading code★ writing code★ build and run code★ debugging★ testing★ version control
‣ beyond Java programming
‣ extending eclipse★ plug-ins and equinox★ Java Development Toolkit APIs★ eclipse modeling framework
‣ further reading
2
introduction
What is eclipse?
‣ Eclipse started as a proprietary IBM product (IBM Visual age for Smalltalk/Java).
‣ Eclipse is open source - it is a general purpose open platform that facilitates and encourages the development of third party plug-ins.
‣ Eclipse is best known as an Integrated Development Environment (IDE).
‣ Eclipse was originally designed for Java, now supports many other languages.★ C, C++, Python, PHP, Ruby★ XML, HTML, CSS★ ant, maven, and many more
4
What is eclipse not?
‣Eclipse is not a programming language.
‣Eclipse is not a software modeling tool; but it can be used as one.
5
Integrated Development Environments (IDEs)
In this lecture we manly see eclipse as an IDE.
‣ Programming requires the use of many tools:★ editors (vim, emacs)★ compilers (gcc, javac)★ code analyzers (lyn)★ debuggers (gdb, jdb)★ build-tools (make, ant, maven)★ version control (cvs, svn, git, ClearCase)
‣ IDEs integrate those tools into a single coherent environment.★ one rich graphical user interface★ one configuration scheme★ The different tools are connected with each other.
6
Why bother?
‣ IDEs are omnipresent.
‣Many software engineering tools only have rudimentary interfaces.
‣ IDEs can automate many processes in software engineering:★building, testing★generation of boiler-plate code
7
fundamentals
Installation (I)
‣download: http://www.eclipse.org/downloads/★Eclipse 3.x releases are: Callisto, Europa, Ganymede,
Galileo, Helios, Indigo (3.7, current)★There is a 32- and 64-bit version for Windows, MacOS,
and Linux/Unix.★Eclipse is java-based but uses SWT, a GUI-toolkit with
platform specific versions.★There are different packages (different collections of
plug-ins) for different use-case. Download Eclipse IDE for Java Developers when in doubt.
9
Installation (II)
‣after download:★You have a .zip- or .tar.gz-file.★unzip ★The unzipped folder contains an executable eclipse(.exe)
‣start eclipse:★You will have to choose a workspace. The workspace is
the place were eclipse will store all your work and configurations. Workspaces can be switched later. Choose a new directory somewhere in your home folder.
★You leave the welcome screen with the right-hand-side arrow.
10
The Workspace
‣ ... shows your current work.
‣ ... is fully configurable, (via Window menu).★ Views can be moved, removed, added.★ You can switch between perspectives (specific arrangement of
views).
‣ Views can be very general (e.g. Problems, Outline) or specific (e.g. Package Explorer (java), Task List (mylyn))
‣ The workspace has a menu bar (top) and status bar (bottom)
‣ The workspace and views have action bars
‣ The space in the “middle” contains open editors. Editors may change the menu bar.
11
Eclipse Vocabulary
‣ Workbench, Perspective, Editor, View
‣ Project★ organizational unit for your work★ corresponds to a folder on your hard-drive, by default in the workspace directory★ is a resource
‣ Resource★ generic term for folders, files, and sometimes file-like (virtual resources) entities
‣ Preferences★ eclipse wide configuration★ organized by plug-ins
‣ Properties★ project specific configuration★ allows to create project specific settings for large parts of the preferences
12
Java Development Tools (JDT)
Java Development Tools (JDT)
‣ ... is a set of plug-ins that turn eclipse into a Java-IDE
‣ JDT comprises of:★ Java editor with syntax highlighting, code-completion,
templates, refactorings, navigation, ...★Package explorer★ Java specific views for
★ documentation★ debugging★ type-hierarchies★ outline
★ Java search★ Java builder
14
Java Projects
‣ A Java project is a special project.
‣ A Java project contains:★ source folders with your sources★ other folders and files you add (e.g. jars, ant-scripts, etc.)★ the compiled .class-files (hidden)★ references to used libraries
‣ Projects can be configured through a property editor★ Most configurations are projects specific changes to the global
eclipse wide configuration.★ Most important for java projects is the Java Build Path:
★ source folders and class folder★ dependencies (other Java projects you need resources from, e.g. classes)★ libraries (internal and external jars and system libraries)
15
Anagrams, a Simple Programming Exercise
‣Dave Thomas (aka pragmatic Dave) defines Code Katas as fundamental training exercises for programming: http://codekata.pragprog.com
‣Anagrams are sets of words that are made up from the same letters.
‣Problem: Find all anagrams in a list of words.
‣We use a small word list from Kevin's Word List Page(http://wordlist.sourceforge.net) as example.
16
Write Java
‣Create Classes, Interfaces, and Package from the Project Explorer.
‣Use code-completion and templates with crtl-space.
‣Use refactorings from the refactor context-menu.
‣Use quick-fixes to deal with errors (crtl-1).
‣Generate code (e.g. getter and setter) from the source context-menu.
‣Organize imports from the source context-menu.
‣ Extract interface from the refactor context-menu.17
Read Java
‣Navigate with F3
‣Search for references and declarations
‣View type-hierarchies and call-hierachies with the context-menu
‣Use the outline-view
‣Use the Java search
‣Lookup Java-Doc with hovers
‣Mark Occurrences from the action bar18
Build and Run Java
‣Builds automatically for simple project configurations.
‣Run from the context-menu.
‣Look at run-configurations from the action bar and change the arguments.
‣Add an external .jar library to your project.
19
Debug Java
‣ Use debug instead of run.
‣ Add breakpoints.
‣ Switch to the debug-perspective as offered.
‣ Step-in, step-over, step-return, and resume (F5-F8)
‣ Look at variables in the variable view.
‣ Inspect expressions from the context-menu.
‣ Use the expressions view (show view first from the Window menu).
‣ Add exception break points.
‣ Switch frames in the debug view.
‣ Use “hot-deploy” (i.e. change the code and save it while running).
20
Testing with JUnit
‣Create a test-case from the Package Explorer.
‣Run the test-case from the context menu.
‣Navigate through failing test from the JUnit view.
‣Debug a test-case from the context menu.
‣ Inspect run-/debug-configurations for JUnit.
‣Run all test-cases in a project from the Package Explorer.
21
Version Control (with SVN)
‣ Install subversive, using the eclipse Marketplace★ use the latest “pure Java” svn connector
‣ Open the repositories view and create a new repository.
‣ Share a project via the Package Explorer. Notices the differences in the Package Explorer’s resource presentation.
‣ Change a file and compare it with the latest version from the repository via the Package Explorer.
‣ Use the comparison editor to revert changes.
‣ Commit your changes via the Package Explorer.
‣ Explore the history view.22
beyond Java programming
Popular Official Eclipse Projects
http://www.eclipse.org/projects/listofprojects.php
‣ Eclipse Platform, JDT, PDE
‣ Eclipse Modeling Project★ Eclipse Modeling Framework (EMF)
★ EMF★ EMF compare★ relational database mappings
★ Graphical Modeling Framework★ Xtext★ Model-2-Model and Model-2-Text★ UML/OCL tools
‣ Mylyn task management
‣ Service Oriented Architecture (SOA)
‣ Languages: C/C++, Python, Scala
‣ Eclipse Web Tools Platform★ J2EE★ Javascript★ XML★ Web Services
24
Popular Non-Eclipse Products
‣diverse UML and other modeling plug-ins (just search the Marketplace)
‣Google Plug-in (http://code.google.com/eclipse/):★Google Web Toolkit★Google App Engine★Android programming
‣Spring’s Source Tool Suite (http://www.springsource.com/developer/sts)★ J2EE★Grails
25
Install new plug-ins.
‣ the eclipse Marketplace
‣ the traditional way★Update sites (identified by URLs) provide plug-ins via
HTTP.★Eclipse update site provides all plug-ins of the various
official eclipse projects.★Update-sites of third party vendors can be added and their
plug-ins installed.
‣ install plug-ins manually★Eclipse manages plugins (typically as .jars and .zips) in its
internal folder structure.26
extending eclipse
Eclipse is ...
‣ ... not a monolithic piece of software
‣ ... an extendable platform
‣ ... a collection of plug-ins★ all functionally we saw is deployed in a plug-in
‣ ... a hierarchy of plugins★ plug-ins use each other (plug-in dependencies)★ eclipse has “abstract” plug-in (e.g. the team plug-ins) therefore
all specific plug-ins (e.g. JDT/CDT, CVS/subclipse) have the same look and feel
‣ ... is a Rich Client Platform (RCP) for developing non-eclipse rich clients
28
29
Bundles and Plug-ins
two mechanisms:
‣Equinox(OSGi)-based bundles
‣eclipse plug-ins
30
Equinox Bundles
‣What happens when different vendors program code running in the same JVM?★ different classes with same package and name collide★ same classes in different versions with same package name collide★ when one vendor wants to use classes of another it is not clear
which class one intends to use
‣What is the solution?★ classes are organized in bundles★ each bundle gets its own class loader that only sees the classes in
that bundle★ bundles can use other bundles and user their classes: class loaders
of dependent bundles are used when the own class loader does not find a used class
31
Eclipse plug-ins
‣Plug-ins define extension points and use extension points creating extensions.
‣Popular extension points are:★commands★editor★popup-menu additions★property pages★views★project builders★additions to the help system
32
Writing your own plug-ins
‣Steep learning curve due to numerous techniques and existing plug-ins:★plug-in and bundle mechanisms★SWT★ JFace★views, editors, property views
‣How to succeed?★Use how-tos and tutorials.★Apply “monkey sees, monkey does”.★Use similar, existing plug-ins as starting points.
33
Writing RCPs
‣RCPs are build from features, features are build from plug-ins
‣Typically a mix of existing eclipse plug-ins and your own plug-ins.
‣Of course you finally define splash screen and about box.
‣Eclipse can build binaries for all platforms (cross platform development).
34
Popular Frameworks for Writing Plug-ins
‣Eclipse Modeling Framework (EMF)
‣Graphical Editing Framework (GEF)
‣Graphiti
‣based on EMF★GMF★Xtext
35
Write a Plug-in
‣ install the Platform Development Environment (PDE)
‣create a plug-in and use an extension wizzard
‣ inspect the generated code
‣ run the plug-in
‣modify and re-run the plug-in
‣ learn more about plug-in writing and deployment:★http://www.vogella.de/articles/EclipsePlugIn/article.html
36
further reading
Books
‣ “Eclipse”, Steve Holzner, O’Reilly
‣ “Programmieren mit Eclipse 3: Universelle Entwicklungsplattform für Java, PHP, C/C++, SQL, XML, XSLT, XSL-FO, JSP, Servlets, JEE, UML, HTML, CSS, JavaScript”, Michael Seeboerger-Weichselbaumm, mitp
‣ “Eclipse Plug-ins”, Eric Clayberg and Dan Rubel, Addison-Wesley
‣ “EMF - Eclipse Modeling Framework”, Dave Steinberg et al., Addison-Wesley
38
Internet Resources
‣http://help.eclipse.org/indigo/index.jsp
‣http://www.eclipse.org/articles/
‣http://wiki.eclipse.org
‣http://eclipse.org/projects/
‣http://www.planeteclipse.org/planet/
39