2) java development
Upcoming SlideShare
Loading in...5
×
 

2) java development

on

  • 999 views

 

Statistics

Views

Total Views
999
Views on SlideShare
999
Embed Views
0

Actions

Likes
0
Downloads
7
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Main Point: IBM is continuing to evolve and enhance the value that we bring to companies by building on the SOA announcements we made last fall…today we are going to talk to you about how a Business Centric Perspective to SOA is necessary to drive innovation that matters* As you know, SOA is one of IBM’s long term strategies to enable innovation that matters. IBM will continue to deliver SOA centric offerings. But we also want you to know that IBM’s view of SOA is business centric. and we’ll talk about this important concept. Further, we’ll discuss ways to get started through existing parts of your business (people process, information). Additionally, we’ll show how reuse and connectivity is critical to support the business centric approach. We’ll then give you detail on how the specific entry points are accelerated by SOA Foundation products and the business insight these products provide. Lastly, we’ll discuss an important part of the story called SOA Governance to ensure we’re aligning the business with IT.
  • Notes: The Java perspective provides a set of views to help you develop Java applications, numbered in the previous figure as follows: The Package Explorer view displays the contents of your Java projects, and groups package names into one entry. The Java Editor allows you to develop Java classes. This editor supports syntax highlighting, error indication, and automatic incremental builds. The Java toolbar provides quick access to the wizards and functions associated with Java application development. The Hierarchy view shows the relationship between one class and its superclasses, subclasses and interfaces. The Outline view provides a graphic representation of the current Java class in the editor. 6. The Problems view lists all compilation errors or warnings from any Java class in the workspace. 7. The Javadoc view renders the currently selected Javadoc in the Java editor in HTML format. 8. The Declaration view shows the implementation for a method selected in the Java editor. You can also show the same information by selecting a Java element and pressing F3. Instructor notes: Purpose -- Provide a brief overview about the Java perspective. Details -- Provide a general overview of the different views and editors in the Java perspective. Most students feel slightly overwhelmed when they see the perspective with all of its views in the start. Assure students that you will be covering the different parts of this perspective in more detail in this module. The numbered list in the student notes correspond to the numbered items in the screenshot. The items are arbitrarily numbered; feel free to present the views in the most logical order for you and your students. Additional information -- Remind students how to open up a perspective if they have forgotten, or refer them to the workbench basics lecture. Transition statement -- Let's examine the files that make up a Java application.
  • Notes: JUnit is a unit testing framework for Java applications. A JUnit Test Case is a Java class representation of a single unit test. A Visual Class is a regular Java class that represents a part of a graphical user interface. The visual class wizard allows you to choose from one of three graphical toolkits: the Standard Widget Toolkit (SWT), Java Swing, or the Abstract Window Toolkit (AWT). Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Describe the concept of the Java project. Details -- A Java project contains the source code and binary files for a Java application. The Package Explorer view provides pertinent information about Java applications, grouped by packages and utility classes. The Java project represents the structure of a JAR archive. Additional information -- The Package Explorer view translates the folder structure in a Java project to the proper package name. You can also examine the structure of a Java class or interface within the same view. Transition statement --
  • Notes: Usually, the wizard creates the new Java project as a subfolder within the workspace. However, there are some special circumstances where you might want to place the project outside of the workspace. For example, ClearCase can automatically maintain a repository of files over a network shared drive. To use this feature, you can create the Java project on the network share, instead of a local workspace folder. By default, Java class files are kept in the same directory as the source file. For better maintainability and ease of packaging, you can separate the source files from the binary class files into separate folders. The New Java Project wizard provides additional Java build path and dependency options on the second page of the wizard. You can access this page by clicking Next instead of Finish . Instructor notes: Purpose -- Describe how to create a Java project. Details -- Stress the importance of creating a Java project. In a manner of speaking, projects are first-class citizens in a workspace. Developers must create a project before he or she can add resources to the workspace. Additional information -- There are other methods of accessing the new Java project wizard. For example, you can click the New Java project button on the perspective toolbar, or right-click the Package Explorer view and select New -> Java Package. The slide material focuses on the main menu bar because developers can create any artifact in the workbench through that menu. Students will always be able to create a Java project, irrespective of which perspective is currently open. Transition statement -- How do you add existing classes to the Java project?
  • Notes: Use the exclusion filter to hide files in the Java project from the compiler. To configure the exclusion filter, select the Excluded item under the Java project name and click Edit . The inclusion filter works in the opposite manner, specifying which files are explicitly marked for compilation. The exclusion pattern always takes preference over the inclusion pattern. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: By default, the source files from the current Java project are always visible to any other project that references it. Therefore, you cannot clear the current Java project. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: You must create a Java project before you import a JAR, .zip or TAR file into the workspace. Otherwise, the Import Archive file wizard returns an error stating that the destination folder does not exist. Instructor notes: Purpose -- Describe the steps for importing a Java Resources contained in a Archive file such as a JAR, ZIP, or TAR. Details -- Point out that all J2EE archives (JAR, EAR, WAR and RAR) are essentially Archive files with a specific folder structure. In the workbench, the Archive file import wizard also handles Java JAR, ZIP, TAR files. Additional information -- Make sure that the Into Folder field points to the right folder in the Java project. Transition statement -- Instead of importing new resources, how can you create new Java classes and packages in the project?
  • Notes: By default, Java packages appear directly underneath the Java project folder. If you want more control in logically grouping certain Java packages, you can create a source folder within the Java project. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: If the package does not exist, the wizard creates a new Java package along with the class. Certain combinations of class modifiers are not allowed . For example, you cannot create a final static class. Specifying java.lang.Object as a superclass does not appear in the class signature, since all Java classes implicitly extend the Object class. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: The gray area in the left indicator column highlights the scope of the current Java fragment. For example, if you put the cursor within a Java method, the gray bar starts from the method signature and ends at the ending brace for the method. The purple bar next to the left indicator column highlights lines of code that have been modified since the last save. Instructor notes: Purpose -- Introduce the Java editor interface. Details -- The left and right indicator bars are also known as rulers. This concept is difficult to describe using the slide material alone. It is much easier to demonstrate the editor for the next series of slides. Additional information -- You can customize the text and background colors from the Windows -> Preferences menu. Transition statement -- How are errors indicated in the Java editor?
  • The location of the task (the line and file with which it is associated) is filled in automatically. The description is by default the code that is on that line (you can replace the default with your own text). Priorities are High, Normal, and Low. The Completed box can be checked here to indicate that the task has been resolved (for example, a developer may simply want to indicate to the team that the task discussed during a meeting has been dealt with). Both Priority and Completion are indicated in the leftmost columns of the Tasks view.
  • If there is a problem in a class, the package by definition also has a problem, and the JavaSource folder therefore shows the problem marker as well. There is no indication of how many problems there are in the class. The error is marked to the left by a red circle with a white cross. Hovering over the marker will bring up a pane showing the nature of the error. The warning is marked by a yellow triangle. The light-bulb behind the error marker indicates that Rational Application Developer has a suggested correction (in this case, it suggests adding an argument to match one of the constructors of PrintWriter). The Problems view shows the resource, which contains the problem and a description. If the description is not completely visible, you can select one row and read the description at the bottom of the window. These messages are deleted only by correcting the problem. See the next slide for a description of the filter icon.
  • See the previous slide for the placement of the problem filter icon. It is often convenient to restrict visibility of problems to a subset of resources, rather than a subset of problems. This dialog provides you with several different ways of doing this. You may, for example, only want to see errors and warnings (no informational reports), on the resource that is currently active in an editor.
  • Notes: The indicator bars indicate errors and to-do items in the current Java class. In the example above, there are two TODO items in the comment. The left indicator bar uses a blue checkmark icon to highlight the TODO items. The right indicator bar uses two blue rectangles to show the position of the TODO items, relative to the entire document. Instructor notes: Purpose -- Describe the error indicators in the Java editor. Details -- To hover over an item, place the mouse cursor over an interface element (such as the error indicator in the right ruler.) A tooltip appears displaying the error. Alternatively, open the Problems view to see a list of all errors in the workspace. Additional information -- Transition statement -- Let's explore how the quick fix feature helps you solve errors in the editor.
  • Notes:   Instructor notes: Purpose -- Walk through the steps on using the Quick Fix feature. Details -- Additional information -- The Quick Fix feature appears in views and wizards as well. For example, if you enable the regular expressions feature in the search window, a small quick fix icon appears to the left of the search criteria input field. Clicking on the quick fix icon reveals regular expression templates. Transition statement -- What other help features does the Java editor provide?
  • Notes: Code Assist helps you complete lines of code in the Java editor. The screenshot in the slide is an example of a code assist; the workbench provides a list of suggested method and field names to complete the statement. Content Assist helps you complete a block of code, using a template of code. Using content assist, you can add a for-loop structure and fill in the details. To invoke either the Code Assist or Content Assist feature, press Ctrl+Space in the editor.   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: XDoclet is an open-source project that defines a system for embedding deployment information within the Java source file. The project itself defines a set of Javadoc tags and an XDoclet syntax compiler. Rational Application Developer V7 and later understands the Javadoc annotation tags, but it uses its own incremental builder to compile the tags. Instructor notes: Purpose -- Describe other content assist features available in the Java editor. Details -- Additional information -- The Servlet, Filters and Listeners unit provides a thorough discussion about annotation tags. Leave the discussion about these tags to this unit. Transition statement --
  • Notes:   Instructor notes: Purpose -- Briefly point out the content assist templates feature. Details -- Anonymous inner classes allow you to create a simple Java class for one-time use. public int x = 0; Runnable runnable = new runnable() { public void run () { while ( x < 100 ) { System.out.println ( x += 1 ); } } } There are several interesting points about the code fragment above: The statement creates a new Java class that can only be instantiated at this point. Since runnable is an interface, this statement instantiates a class of type java.lang.Object that implements the Runnable interface. As an inner class, it has access to the fields from the surrounding outer class. The code example is for illustration purposes only. Having a separate thread access a public variable is not a good design. Additional information -- You can add your own custom content assist templates in the Java -> Editor -> Templates section of the workspace preferences. Transition statement -- Let's examine some of the other views that help you use the Java editor.
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: You can also press F2 for Javadoc Help to retrieve the same information as shown in the view. Pressing F2 for Javadoc Help returns a floating tooltip on top of your editor, instead of having to switch to a separate view. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: You can also press F3 to return the same information as shown in the declaration view. Pressing F3 opens a new editor with the declaration for the currently selected class, method, or field. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: The Java Browsing perspective provides a quick way to examine the Java elements that make up your Java application. The components within the Package Explorer view have been split into four separate views: Projects, Packages, Types and Members. Select a source folder within a Java package from the Projects view. With a project selected, the Packages view lists all of the Java packages available from the Java project. Select one package from the list. The Types view lists all of the classes and interfaces that appear in the selected Java package. Select one type from the list. The Members view displays all of the fields, variables, constructors, and methods within the selected type. The Java Editor displays the currently selected type, with the cursor located at the definition for the selected member. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • There are 3 main types of searches: File search looks for text in files or file names (regular expressions can be used). Help Search will find matches in the Rational Application Developer Help. Java Search allows you to quickly find references to and declarations of Java elements. Other search categories will depend on the extra plug-in functionality choices you made during the install of Rational Application Developer. Rational Application Developer for example, whether you choose to install Crystal Reports functionality into Rational Application Developer.
  • Notes: To open the search dialog box, perform one of the following three tasks: Click Search -> Search from the main workbench menu. Use the Ctrl+H hotkey from the workbench. In the Java perspective, press the Search toolbar button. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: The workbench features refactoring tools for reorganizing Java applications. When you refactor a program, you transform your code while preserving its behavior. For example, when you rename an element, the workbench's refactoring support changes both the selected resource's name and all references to it. This feature allows you to make changes to code structures, and to have those changes ripple across the entire project consistently. All the dependencies are analyzed and modified where appropriate. There are several options that allow you to control the process of incorporating the changes. By default, you are prompted to review the changes before committing them. You can choose various other options, such as committing changes if no error occurs. If you need to revert the changes, even after you commit, you can use local history. Pull-up will move the selected method one level up the inheritance tree (to the super class) and ensure that all references are updated appropriately. Self-encapsulation will wrap access to any member fields in getter and setter methods. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement -- [Unconditional]
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: An Extends relationship is also known as an inheritance or is-a relationship. An Implements relationship is also called a has-a relationship. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: The list of properties on this foil describe some of the more commonly used settings for basic Java properties. Other properties, such as Project References and Java JAR Dependencies, affect the operation of Java projects within a J2EE enterprise project. Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes:   Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: To open the Java preferences dialog, select Windows > Preferences . Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes: To open the Java preferences dialog, select Windows > Preferences . Instructor notes: Purpose -- Details -- Additional information -- Transition statement --
  • Notes : Write down your answers here: Instructor notes : Purpose — Details — Additional information — Transition statement —
  • RUP Rational Unified Process, Developer Tab , Designer > Concepts > J2EE to RUP Mapping Rational Unified Process, Developer Tab , Designer > Enterprise JavaBean (EJB) Design > Guideline s > Designing Enterprise JavaBeans (EJBs) Web Resources http://www-130.ibm.com/developerworks/ http://w3.ams1.ibm.com/services/ams/competency/ams/tools_support/rational/learn_about/ams_rational_advanced_learning.html EJB Best Practices: Entity Bean Protection: http://www-106.ibm.com/developerworks/java/library/j-ejb1008.html Literature Enterprise Java Programming with IBM® WebSphere®, Second Edition By Kyle Brown, Gary Craig, Greg Hester, Russell Stinehour, W. David Pitt, Mark Weitzel, Jim Amsden, Peter M. Jakab, Daniel Berg Additional Courses Introduction to Web Services - http://w3-3.ibm.com/education/CourseDescriptionServlet.wss?city=&state=&countrycode=&coursecode=XM371&courseDescrLanguageId=1 WebSphere Training and Technical enablement: http://www-128.ibm.com/developerworks/websphere/education/enablement/curriculum/cur_webtoolside.html Review resources with students and answer questions.
  • Self explanatory

2) java development 2) java development Presentation Transcript

  • Vikas Manoria IT Specialist – IBM Academic Initiative [email_address] Section -2) Java Development
  • Section 2 - Java Development (24%)
    • Create Java projects, packages, classes, and methods
    • Manage the Java Build Path
    • Use the Outline view
    • Use the refactoring features
    • Use the Java editor features such as content assist and code formatting
    • Add and organize import declarations
    • Use the Java search function
    • Use the Task and Problems views
    • Use the Hierarchy view
    • Use the resource and project property dialogues
  • The Java Perspective 1 2 3 4 5 6 7 8
  • Java Perspective Toolbar Commands
    • As an alternative to the New main menu command, you can create Java artifacts using the Java perspective toolbar.
    1. Create Java Project 2. Create Java Package 3. Create Java Class a. Create Visual class b. Create Java class c. Create Java interface d. Create Java Enum e. Create Annotation f. Create JUnit Test Case 4. Launch New_configuration (for Code Analysis) 5. Debug Java Application 6. Run Java Application 7. Profile Java Application 8. Run External Tools 9. Open Type 10. Open Search Dialog 1 2 3 4 5 6 7 8 9 10 a b c d e f
  • Overview of Java Projects
    • Java projects contain source code and related files needed to create a Java application.
      • The workbench associates Java projects with an incremental builder that compiles Java code as it is edited.
    • Java projects also maintain models of their contents.
      • The model includes information about the type hierarchy, declarations, and references of Java elements.
    • After creating a new Java project, you can import a JAR file into the project.
  • Create a New Java Project
    • Start the Create Java Project wizard.
      • In the Java perspective, select File > New > Project .
      • Select Java Project .
      • Click Next .
    • Provide a name and location for the new Java project.
      • Specify a unique project name.
      • Set the location of the project within the workspace, or in any directory.
      • Decide to use the default JRE, or use a project-specific JRE.
      • Decide whether to keep source and class files together or separate.
      • Click Finish .
  • Java Build Path: Source and Projects
    • The Source tab specifies where to store the Java source files and output class files.
    • The Projects tab adds other projects from the workspace to the build path.
      • Add a project if the current Java application depends on classes in another project in the workspace.
  • Java Build Path: Libraries
    • The Libraries tab adds JAR files and class folders to the build path.
      • Add a JAR file located in the workspace with the Add JARs button.
      • Add a JAR file located outside of the workspace with the Add External JARs button.
      • Add classpath variables with the Add Variable button.
      • Add a library of Java resources using Add Library button.
        • Libraries are arbitrarily organized sets of JAR files.
      • Click the Add Class Folder button to add a directory with class files residing outside of your workspace.
  • Java Build Path: Order and Export
    • The Order and Export tab sets the order of JAR files and class folders in the Java build path.
      • Use the Up and Down buttons to arrange the order within the Java build path.
      • Select the check box next to an entry to make the source files visible to other projects dependent on the current Java project.
        • For example, TransferJava has a project reference to AccountJava.
        • In the Order and Export tab, the AccountJava project is selected.
        • If a third project, CustomerJava, references TransferJava, it has access to the classes in AccountJava as well.
  • Import Archived Resources into a Java Project
    • Start the Import Archived file wizard.
      • In the Java perspective, select File > Import .
      • From the Import wizard, select General > Archive file.
      • Click Next .
    • Select the source JAR, .zip, or TAR file and destination.
      • Enter the path filename of the Archive file.
      • Select one or more files for importing from the Archived file.
      • Import files by extension using the Filter Types feature.
      • Use the Into folder to select a
      • destination Java project.
  • Create a New Java Package
    • Start the New Java Package wizard.
      • In the Java perspective, select File > New > Package .
    • Enter the source folder and name of the new Java package.
      • Select a source folder as the root of the Java package structure.
        • If you do not have any source folders defined in the Java project, the Java project folder itself is the source folder.
      • Enter the full package name for the Java package.
  • Create a New Java Class
    • Start the New Java Class wizard.
      • Select File > New > Class .
    • Specify the source folder and package name for the Java class.
    • Set the name of the new Java class and class modifiers.
    • Specify a single superclass to extend, and zero or more interfaces to implement.
    • Set the wizard to generate:
      • Main method stub
      • Constructors from superclass
      • Abstract methods from abstract classes or interfaces
    • Click Finish .
  • The Java Editor
    • Syntax type categorized by color:
      • Java comments are green; Javadoc comments are cyan.
      • Keywords and built-in types are magenta.
      • Strings are navy blue.
    • Two indicator bars are placed on each side of the editor.
      • The left indicator bar is proportional to each line of code.
      • The right indicator bar is proportional to the scale of the entire Java class.
    • Changes since your last save are denoted by a light purple bar.
  • Tasks
    • A task is a user-defined statement that can be either associated or unassociated.
      • Associated: Referencing a line in a resource
      • Unassociated: not related to any resource
    • A task is associated by opening the resource in an editor, right-clicking the left grey border and selecting Task.
  • Problems
    • If problems are detected, a message is logged
    • The message cannot be removed manually.
    • There are three types of problems:
      • Errors, Warning, and Information
    1 2 3 4
  • Filtering the Problem View
    • Use the Filter Tasks wizard to temporarily hide messages in the Problems view.
      • You must fix the problem to remove it permanently
    • Since problems are reported by validators, disabling a validator in the project's Properties page will remove the messages it reports.
  • Examine Errors in the Java Code Editor
    • Icons on the left indicator column mark special locations.
      • Blue checkmarks indicate a task item.
      • Red circles with an ‘x’ indicate a syntax error.
      • Light bulb icons indicate that a quick fix is available.
    • Rectangles on the right indicator column display the same locations, in scale with the whole document.
      • Blue rectangles indicate the relative position of a to-do item.
      • Red rectangles indicate the relative position of a syntax error.
    • Hovering over errors
    • provides you with additional information.
  • Correct Errors with the Quick Fix Feature
    • The Quick Fix feature suggests solutions to the highlighted error.
      • Click the light bulb icon to show a list of suggested fixes.
      • Click one of the suggestions to preview the applied fix to your Java class.
      • Double-click the suggestions to add the particular fix to your application.
    1 2 3
  • Code Assist / Content Assist
    • These features provide suggestions to complete code or script
      • Available for Java, HTML, JSP, XML and others
      • Type Ctrl+Space to invoke Code or Content Assist
      • Automatically triggered when you type a period (.) in a Java code fragment
    • Depends on Project container context and file type
  • Additional Content Assist Features
    • Comment code assist provides a list of:
      • XDoclet-style annotation tags
      • Javadoc tags
    • Variable name assist suggests a name for a variable based on the type name.
  • Content Assist Templates
    • Templates provide a skeleton of common code constructs:
      • Try/Catch blocks for exceptions
      • Loop constructs
      • Anonymous inner classes
  • Hierarchy View
    • Displays the relationship between superclasses, subclasses, and implemented interfaces of the current type.
      • Show the Type Hierarchy displays all superclasses and subclasses of the current type.
      • Show the Supertype Hierarchy lists all supertypes and implemented interfaces.
      • Show the Subtype Hierarchy lists all
      • subtypes of the selected type.
        • If the current type is an interface, the list
        • shows all types that implement the interface.
  • Javadoc View
    • The Javadoc view returns an HTML rendered Javadoc Help for the currently selected resource.
      • Previews Javadoc comments in your class in HTML format
      • This view also displays the Javadoc for a class or interface from the J2SE API
  • Declaration View
    • The Declaration view reveals the implementation for the currently selected class, method, or field in the Java editor.
      • This view allows you to quickly browse the underlying implementation for a method call or an object definition.
      • Bring up the pop-up menu within the Declaration view and select Open to view the referenced class in a new Java editor.
  • The Java Browsing Perspective 1 2 3 4 5
  • Search
    • Start a search by selecting Search from the main menu.
    • The results of a search can be seen in the Search view.
    • Previous search results are stored, and can be retrieved in the Search view or Classic Search view.
  • Java Search
    • Java Search performs a search of declarations, references, and other Java elements.
      • This search type understands the structure of a Java class and a Java interface.
      • For example, search for all classes that reference the verifyLogon method within the workspace.
  • Refactoring Java Code
    • Refactoring code allows you to make application-wide improvements while preserving the behavior of the program.
      • Developers often perform refactoring to make an application more manageable.
    • Rational Application Developer V7 and later has built-in support for common refactoring tasks.
      • The Java development tools will examine your entire application and update any references to your change.
      • You can choose to preview any changes from refactoring before committing the operation.
  • Move Java Class to Another Package
    • Start the Refactor Move wizard.
      • In the Java perspective, right-click a Java class and choose Refactor > Move .
      • Click Next .
    • Specify the new destination for the Java class.
      • Select a different package, or use the New button to create a new package.
      • Click Preview to examine the
      • changes before committing
      • the move.
  • Refactoring Functions (1 of 4) Function Description Shortcut Undo Reverses the last refactoring operation Alt+Shift+Z Redo Performs a refactoring operation that was previously reversed Alt+Shift+Y Rename Changes the name of a Java element, and updates all references to that element Alt+Shift+R Move Moves a Java element from between classes, interfaces, packages, or projects Alt+Shift+V Change Method Signature Changes the name or parameters of a method, and updates all references to the method Alt+Shift+C Convert Anonymous Class to Nested Provides a name for an anonymous class, thus changing the class into a nested class
  • Refactoring Functions (2 of 4) Function Description Move Member Type into New File Extracts a nested class and saves it as a separate class Push Down Moves a set of methods and fields from a class to its subclasses Pull Up Moves a set of methods and fields from a class to its superclass Extract Interface Creates a new interface based on a class. Optionally, you can make the source class implement the new interface Generalize Type Replaces a type in a variable, parameter, or field or on a method return type with one of its supertypes Use Supertype Where Possible Replaces all occurrences of a type with one of its supertypes
  • Refactoring Functions (3 of 4) Function Description Shortcut Inline Replace a method invocation with the implementation of the method itself. For static final fields, replace a reference to the field with the actual value Alt+Shift+I Extract Method Takes a section of code within a method and places it in a new method Alt+Shift+M Extract Local Variable Creates a local variable from an expression. Replaces an expression with a reference to the local variable Alt+Shift+L Extract Constant Creates a static final field from an expression. Replaces the expression with a reference to the static final field Introduce Parameter Within a method, extracts an expression and replaces it with a new method parameter
  • Refactoring Functions (4 of 4) Function Description Shortcut Introduce Factory Replaces a constructor with a factory method that invokes the constructor Convert Local Variable to Field Replaces a local variable with a field. If the local variable is initialized when it is created, this operation moves the initialization code to the method’s constructor. Alt+Shift+F Encapsulate Field Replaces all references to a field with getter and setter methods
  • Source Functions (1 of 4) Function Description Shortcut Toggle Comment Adds single line comments ( // ) to each line in the selection Ctrl+/ Add Block Comment Adds block comment tags ( /* */ ) around the selection Ctrl+Shift+/ Remove Block Comment Removes block comment tags ( /* */ ) around the selection Ctrl+Shift+ Shift Right Adds a tab character to the start of each line in the selection Tab Shift Left Removes a tab character from the start of each line in the selection Shift+Tab Format Changes the indentation, line spacing, and braces in the entire Java class according to the code formatter settings Ctrl+Shift+F
  • Source Functions (2 of 4) Function Description Shortcut Format Element Apply code formatting only to the first Java element in the selection Correct Indentation Adjust the indentation to every line in the current selection Ctrl+I Sort Members Arrange the member order according to the Member Sort Order in Java preferences Organize Imports Adds any missing import statements, and removes any unused import statements Ctrl+Shift+O Add Imports Adds an import statement for the currently selected type. Removes the package name for a qualified type, if possible. Ctrl+Shift+M Override/ Implement Methods Creates one or more methods defined in a superclass or interface
  • Source Functions (3 of 4) Function Description Shortcut Generate Getters and Setters Creates a get Field and set Field method for one or more fields in the current class Generate Delegate Methods For a field in the current class, creates a wrapper around methods from the field’s class Generate Constructor using Fields Creates a new constructor that initializes one or more fields in the class Add Constructor from Superclass Overrides one or more constructors defined in a superclass Add Javadoc Comment Adds a Javadoc comment and appropriate Javadoc tags for the selection Alt+Shift+J
  • Source Functions (4 of 4) Function Description Shortcut Surround with try/catch Block Adds a try/catch block around the selection to catch exceptions Externalize Strings Takes all static string declarations and saves them into a separate properties file. Also creates a method to retrieve strings in the properties file. Find Strings to Externalize Given a project, source folder, or package, searches for any strings that have not been externalized Convert Line Delimiters To
    • Changes the end-of-line indicator in the current document to one of the three formats:
    • Windows (Carriage return , line feed )
    • Unix, MacOS (Line feed )
    • Classic MacOS (Carriage return )
  • Preview and Commit the Move Operation
    • Preview the changes before committing the move operation.
      • Select one of the items in the Changes to be performed list.
      • To override a change made by the move operation, clear the check box next to the change list.
      • Examine the difference in the affected Java artifact using the Original Source and Refactored Source windows.
      • Click OK to commit all of the selected changes from the move operation.
  • UML Visualization Overview
    • The Unified Modeling Language (UML) provides a visual representation of the structures and relationships of elements in applications.
    • The UML visualization tools in Rational Application Developer V7 and later provides two main functions:
      • Code Visualization describes a Java application in a graphical format using UML notation.
      • Visual Editing applies changes in the UML diagram to the actual application code.
    • To start visualizing your Java application, create a UML diagram and document your application using UML notation.
  • Create a New Class Diagram File
    • Start the New Class Diagram wizard.
      • In the Java perspective, select File > New > Other .
      • Expand the Modeling folder and select Class Diagram.
      • Click Next .
    • Specify the name and location for the new Class Diagram file.
      • Specify a location for the class diagram file.
      • Choose a name for the class diagram file.
      • Click Finish .
  • Visualize Existing Java Resources
    • Open the new class diagram file.
      • Bring up the pop-up menu right-click in the class diagram and select Visualize Existing > Java Type .
      • Enter the name of the Java types that you want to visualize in the diagram.
    • Explore relationships between different Java types in the diagram.
      • Use the incoming and outgoing relationship arrows to create relationships between types.
    • Relationships created in the diagram affect Java types in your workspace.
  • Relationships between Java Types
    • There are four different types of relationships between Java types:
      • An Extends relationship exists when a class inherits the behavior of another class.
      • An Implements relationship exists when a class realizes the behavior of an interface.
      • An Association relationship exists when the objects of one classifier (class or interface) are connected to, and can navigate the objects of another classifier.
        • For example, the TransferBean class has a field of type AccountBean.
      • A Dependency relationship exists when a change in one class might cause a change in another class.
        • For example, the TransferBean class has a method that takes an AccountBean object as a parameter.
    «use» +1 AccountBean
  • Java Project Properties
    • The Java project properties define how the workbench maintains files within the project:
      • Builders specify which incremental builds should run in the Java project.
        • For example, the Java Builder compiles source code into Java applications.
      • Java Build Path defines where the compiler should search for classes referenced in the Java application.
      • Java Compiler defines how the workbench compiles classes in the project.
      • Javadoc Location sets where the workbench should publish Javadoc files.
      • Validators automatically check the structure and syntax of certain file types, such as XML files.
    • To open the Java project properties, right-click the Java project and select Properties.
  • Java Build Path Settings
    • You can set Java Build Path settings within the New Java project wizard or the Java project properties.
      • The compiler searches the locations listed in the Java Build Path for the classes referenced by your application.
      • The Java Build Path properties also allow you to specify the location for the compiled classes and default output .
  • Workspace Settings in Java Preferences (1 of 2)
    • Modify the Java preferences to change settings for all of the Java resources in the workspace.
      • Appearance controls the appearance of Java elements in workbench views.
        • Type Filters removes Java packages from the Open Type command, code assist, and quick fix.
      • Build Path sets the default class build path for all Java projects.
      • Code Style sets conventions for Java element names, spacing, and sort order.
      • Compiler sets the JDK compliance level, and the severity of compilation problems.
        • Task Tags set task indicators in Java comments, such as the TODO tag.
  • Workspace Settings in Java Preferences (2 of 2)
      • Editor customizes the appearance and behavior of the Java editor.
      • Installed JREs list the Java run times on which you can run your application.
  • Checkpoint
    • Which view in the Java perspective allows you to see the relationship between a type, its supertypes, and its subtypes?
    • What is the advantage of using the Refactor Move feature, as opposed to moving a Java source file manually outside of Rational Application Developer?
    • In the Java Editor, what information is shown by the left and right status rulers (bars)?
    • Name two features that add the correct import statement in the Java Editor.
    • What are the types of problems and the associated icons in the Problems view?
  • Checkpoint answers
    • The Type Hierarchy view allows you to view the relationship between a type and its super and subtypes. The UML visualization tools can also diagram the relationship between types.
    • The Refactor Move command verifies every reference to the resource within the workspace and updates all references. Moving the file outside of the workbench will not update these references.
    • In the Java editor, the left indicator bar displays the tasks and errors in the same scale as the lines within the editor. The right indicator bar displays the tasks and errors as well, but in scale with the entire file.
    • The Organize Imports command scans the current Java class and suggests an import statement to fix any classes. The Quick Fix feature also suggests an import statement for a class that the compiler cannot resolve.
    • Error (red circle, white cross), warning (yellow triangle, exclamation mark), Information (blue exclamation mark)
  • Lab
    • Create Java Project, package and 2 classes
    • Problems & Tasks
    • Quick fix & Run
    • Other Java views
    • Code/content assist
    • Java Browsing perspective
    • Create Class diagram
    • Source and Refactor options
    • Java search
    • Project properties
    • Java preferences
  • Japanese Hebrew Thank You English Merci French Russian Danke German Grazie Italian Gracias Spanish Obrigado Portuguese Arabic Simplified Chinese Traditional Chinese Thai Korean