Development is no longer a chore to simplify development with eclipse

Source: Internet
Author: User
Tags add interface return stack trace version versions window access

Each IDE allows you to manage files and build projects. Eclipse is not limited to this, because it can process the code you write at a more intimate level than the typical file center views owned by most Ides. As a developer, you can only write a small amount of code, and let eclipse get the benefit of finding, changing, switching, moving, waiting for these miscellaneous tasks.

With the Eclipse tool, you can focus on the real task at hand: writing code that completes the predefined functionality.

from UI Start

First, note that this article is about the new Eclipse3, which in some ways differs from earlier versions of 2.1, as well as Wsad and Rad.

Eclipse looks similar to most other Ides because the basic user interface (UI) is familiar to developers everywhere-except those who still use Emacs or VI, but they can find something appealing in eclipse, Eclipse is supported for both key bindings.

The basic Eclipse user interface is shown in Figure 1. On the left side of the screen, you can see a list of development resources: source Code, jars, and other components that make up your latest development project. In fact, the list is divided into the different projects you are currently developing, which can be interdependent or completely independent.

Eclipse saves project data in two files, which are. project files and. classpath files. The. project file holds information about which files are included in the project, how to use them, how to build the project, and more details. Any Java project has a. classpath file that tells Eclipse what to use as a CLASSPATH variable during the build process.

All current projects exist in the current workspace. The workspace in eclipse is a directory that contains a number of files and may also contain the resources required for the project. Eclipse starts with a default workspace, but you can easily set it to open multiple workspace. To open a different workspace, just use the-DATA flag when you start the executable file, for example:

Eclipse.exe-data E:/shared/workspaces/artemis

The middle part is a source viewer that displays the source code for the currently open file. Note that it is a multiple-label (tabbed), so you can open more than one file at a time. To the right is the summary of the currently open file. Eclipse lists the other parts of classes, methods, and files. Double-clicking an entry jumps to the appropriate location. Finally, at the bottom, there is another area of multiple labels that transmits information about what Eclipse has done, discovered, or has problems. Note that all of the following tabs are views, you can drag any of them, and you can stack them up to form a stack. Information views are independent, and if you want to see them at the same time and your screen is large enough, you can roll them out.

Views are grouped into pivot charts, which are usually environment-oriented. Here's a Java perspective for working with Java projects, a debug perspective for tracking run-time problems, a CVS perspective for managing CVS connections, and so on. In fact, the number of perspectives and views is extensible, and almost every part of eclipse is extensible. The IDE provides a variety of ways to add and expand existing features that are used by many people in the eclipse community.

All of the resources and projects of Eclipse have attributes. You can see more detailed information by right-clicking on any item in the list on the left and then selecting Properties. For files, you can see some basic information about the file itself, such as modification date, location, and permissions. For projects, there are more advanced options that allow you to set the way eclipse builds projects.

If you click Java Build Path, you will see four tags that control the construction behavior, the first is "Source", which allows you to set where eclipse will look for source files, and to specify which source files are to be used and which are negligible. The next label is "Projects", which allows you to set the project on which the current project depends, so that you can set up some library or common code in one project and simply include the project from other projects.

The next label is "libraries", which allows you to add jar files, libraries, and class folders to the Classpath. Finally, you can specify which resources the project will export, so that the properties of the project can be applied to other projects that import the project.

Eclipse is built in the middle of a large source view, where all of the edits are made. But there's something to be aware of, and Eclipse provides more than just a simple text view. First, there is a small slot on the left side of the text that Eclipse uses to hide the icons that deliver useful information. A red "X" appears next to a line that eclipse cannot compile, and the code that eclipse thinks might be wrong has a yellow "warning" flag, such as an unused import statement (see Figure 1).

Second, the problematic code is underlined with the appropriate color. Similarly, a red underline represents a compilation error, and yellow represents a warning. Finally, there is another small slot on the right side of the scroll bar. The color is once again used to convey information: the red block identifies the code area with the error, and the yellow block identifies the warning code area. Clicking a color block moves the cursor directly to the problem code. Hover over the three colored entries (icons, underscores, or blocks-shown in Figure 1) to open a description of the related issue. Right-clicking will appear in the context menu.

Dynamic Build

The first thing you notice about Java development with Eclipse is how smart it is to compile. Enter Preferences (Windowmenu > Preferences) and enable dynamic builds (Workbench > build automatically). Now, whenever you save a file, eclipse will automatically compile the file and the files that depend on it. Therefore, when you want to run your application, it is basically saved and is the latest version. This can save a lot of time when you're working with large code bases. If you have to use a different IDE, the first thing you lose is the simplicity of the feature.

When you use Eclipse, you will experience the underlying principle again and again: theIDE understands the code . Eclipse is more than just a compiler that can handle code and other things on a file-centric basis, and it can look at the source code and intelligently handle it. Its intelligent compiling capability is proved by its ability to understand the dependence of expression in the import statement.

Smart Search

Eclipse has a very intelligent search feature (search Menu > Search) that allows you to search for any string that appears in a file, in an entire project, or in a filegroup. That's a good feature, but it's getting better. The Java Search (search Menu > Java) allows you to limit your search to finding classes, methods, types, or other Java-aware categories. Eclipse can find all the method implementations that begin with "set", and you can easily find all of your write-access methods. Better yet, you can enter the implementation of a control by calling it in any way by clicking (Control-click). Or the control clicks a class name into its implementation. Alternatively, you can right-click on the method to find all the places it is used (References > Project). Eclipse's understanding of the code helps it navigate a large code base, and you'll benefit from it.

" TODO the task link creation

Eclipse can also remind you of the tasks you still need to perform. Many developers add todo comments to their code to remind them that they have a specific task to complete, or that a specific situation is to be handled. Once again, Eclipse uses its knowledge of the Java architecture to find any comment that starts with Todo and adds it to a special Tasks view (open Window Menu > Show view > Other > Basic > Tasks can be seen). In this way, Eclipse can provide a comprehensive list of tasks to be completed.

In addition, you can configure Eclipse to identify additional tags that you define. Open Preferences (Window Menu > Preferences) and browse to the Task tags page (Java > Task tags). You can add new labels, delete existing tags, set properties for different labels, and specify the default values that eclipse provides for your code.

Code writing

You'll find that eclipse can actually write code for you. Right-clicking the source file, under the "Source" submenu, provides some ways in which eclipse can modify or extend the code, which will do some tedious work to free you. One of the most useful coding capabilities is the "Generate Getters and setters" option, which scans a class to look up domains and generate appropriate access methods for those domains.

If you select it, a window will pop up that lets you specify the domain for which you want to generate access, and what access methods (Get,set, or both) are generated. You can also specify the permissions (Public,private, and so on) of the resulting method. Similarly, eclipse can generate constructors based on superclass and methods to overwrite or encapsulate superclass methods.

Refactoring

One of the most powerful features of Eclipse is its robust support for refactoring. Select a method and right-click the mouse, and you will see the "Refactor" submenu. If you use this method to change a method name, eclipse will find all the calls to the method and change those calls to use the new method name. You can also change the method signature by adding parameters and making eclipse change all existing switches to add that parameter, using the value you specify. Of course, you can also delete parameters that you think are no longer useful, or rearrange the parameters to make the interface more consistent. Refactoring can also work at the hierarchy of classes, where you can drag internal classes into their own files or move classes to other packages.

Robust undo Support

Another very good feature is called "Local History", which is a very simple native CVS repository. Each time you save a file, Eclipse remembers this save and allows you to return to the save when you need it. In the default state, it records the last 7 days of saving (you can modify this default setting in Window menu > Preferences > Workbench > Local History).

When you use a new feature that destroys irrelevant features, the revocation mechanism can undo the situation. You can quickly make a difference between two versions, see what changes you have made, and return the changes to the previous version or even yesterday's version. Better yet, you can simply rollback a specific method and leave the modifications in other methods.

JUnit Integrated

Eclipse can be easily used with the JUnit framework. If you have a class written by JUnit standard, you can select the class in the resources view on the left and run the test (run Menu > Run as > JUnit test). Eclipse will automatically find the defined test suite and run all of its tests, using its own custom UI to display the test run and the errors found. The common JUnit Green Line turns red when the test fails, and eclipse will show you the stack trace information that caused the error.

Let Eclipse Let 's do it.

You see, Eclipse offers so many features to automate some tedious work and make life easier for developers. Because of the platform architecture, it gives you a great opportunity to find a plugin to help you accomplish a specific task. If you can't find it, you can use eclipse to write it!



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.