[program-java] Java Tutorial 3.2

  • From: "Corbett, James" <James.Corbett@xxxxxxxxxxxxx>
  • To: <program-java@xxxxxxxxxxxxx>
  • Date: Thu, 27 Nov 2008 11:09:45 -0500

So hopefully we have made are way through example one and the inherent
stress hasn't strained too many relationships.

In Tutorial 3.2 we are going to have another example but also throw a
few generic IDE features at you. The first one will be Refactoring.
Let's say we don't like the name of package "example_one". How do we
change it. Well we could unrealistically go to the Windows Explorer,
burrow down and locate the package and rename it at that level.... Trust
me that won't work.

The reason why that won't work is that through out our "first_time"
project we have made numerous references to the original package name
via our imports or package reference line at the top of your class. So
as I mentioned previously one class / package is not aware of others and
that tag becomes extremely important to a full project. Even the class
isn't aware of its parent package.

So we are going to refactor the package:

1.0     Open your package explorer alt + W + P + enter and locate the
"example_one" package.
2.0     Right click the package and scroll the pop up menu until you
locate the Refactor option.
3.0     Select from with in the Refactor sub menu "Rename"
4.0     Enter the following text "ex1".... Note the use of lower case.

Unless you have tonnes of errors, you have affectively changed the
package name and all of its reference through out the project.

So keeping with the theme, let's next refactor the HelloWorld.java file.

5.0     Just as before, right click the file; scroll down to
Refactor/Rename, and let's call the class "Ex1"... note the
capitalization of the first letter.

...and just as before all references to the HelloWorld class have been
changed. 

6.0     Now comment out all of the code we added to class Main in
package main.

So far this has been a rather straight forward example, even though it
might not seem so right now but a couple of weeks down the road and
you'll be able to write similar examples with out much effort.



James M. Corbett

A / Technical Specialist
GST / HST Micro Development
875 Heron Rd / Ottawa / Ontario

(613) 941-1338

Other related posts:

  • » [program-java] Java Tutorial 3.2 - Corbett, James