Google

Oct 23, 2014

Debugging and working like a pro with a Java application tutorial with eclipse IDE

Often you get to work on a fully functional Java application that is already in production to fix production issues or to enhance its existing functionality. As a new Java developer in the team, it is not easy to get started and contributing. The approach would be slightly different from working on a brand new project. Here are a few tips that will help you hit the road running as quickly as possible.

This post will also help you answer a common developer interview question --

Q. How will you hit the road running fast on an enhancement or a bug fix task of a large  existing application with 1000+ artifacts?
A. Key terms are: Setting up the environment, familiarizing with the app, reverse engineering, impact analysis, monitoring the logs, and collaborating  with the team members and knowledge transferring.

Step #1: Firstly, you need to get the application running locally in your development environment. So, with the help of your existing team members and online documentation provided via the internal wiki or confluence page you need to set up your development environment to run the application.
  1. Get all the Java tools required like Java, Maven, eclipse IDE, Tomcat/JBoss Server, tex editor like Notepad++, ssh emulator like putty/cygwin/mobaXterm/MSYS, tortoise SVN, etc
  2. Set up your Java and Maven locally
  3. Checkout the relevant Java projects from a code repository like Subversion (aka SVN).
  4. Set up data sources, environment variables, and .properties files.
  5. Build and deploy the Java application locally in your machine.

Step #2: Run the application locally, and get a basic familiarity as to how to navigate through the application.  Focus on the functionality you will be working with.


Step #3: A level of reverse engineering will be required to navigate through the actual user interface and then drill down into the code that is responsible for the functionality you are focusing on foxing on enhancing. Here are the tips to do that.


Step #3.1: Run the application in debug mode by modifying the log4j config file. This will print more log info like class names, method names, and stored procedure names being executed while you perform the UI navigation. You can then check the log file to get a list of relevant class names, methods, stored procedures, etc.

Step #3.1.1: Once you have the relevant class and method details, you can

Start to work like an eclipse pro to navigate through code:

You can use CTRL+SHIFT+T to search for Java class files



You can use CTRL+SHIFT+R to search for any resource files like .properties, .xml (Spring context file), .sql files, etc



Once you are within a Java class files, you can search for a particular method with CTRL+O.



You can drill down into other classes with F3 and Ctrl + left mouse click. The CTRL+ mouse click is very powerful drill down from ClassA to ClassB method invocations.



Step #3.1.2: Once you have worked out which artifacts to be modified, it is essential to perform impact analysis as to who is using these artifacts and if your fixes or enhancements going to impact any other existing functionality.

Start to work like an eclipse pro to perform impact analysis:

Highlight either a class name or a method name and press CTRL+SHIFT+G to find out from which classes and methods it is used or referenced from.


You can also highlight the class and press CTRL+H to search both Java classes and non Java type files like Spring context files, properties files, etc. This will cast a wider search where you have a number of tabs like file, Java, JavaScript, etc to search from.



Step #3.2: As an alternative to running the application in debug mode, you can also pick some labels key text on the GUI, and then use CTRL+H and then select the "File Search" tab to search for the web resources like .jsp, ,html, .xml, etc that have that search text. You can then drill down the other artifacts from there.

Step #4: When you are ready to make the code changes you can use code assist short cut keys described in  top 10 eclipse short-cut keys every Java eclipse developer must know.


Step #5: If you can't remember these short-cut keys initially, all you have to remember is

CTRL+SHIFT+L once
CTRL+SHIFT+L twice  


While unscrambling the relationship between the software functionality and code, maintain a documentation and produce high level diagrams. For example:

CashUI.jsp --> CashController.java --> CashService.java --> CashDao.java --&gt  getAvailbleCash.sql

Obviously you need to collaborate with a number of different team members to pick their knowledge, but most often team members can;t spoon feed you, and you need to hit the road running fast. This requires both good technical know how and great soft skills to get the job done.

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home