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 fixing task of an existing application with 1000+ artifacts? Where do you start? How do you get clues? What tools do you use?
A. Key terms are: Setting up the environment, familiarizing with the application, 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.
- 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
- Set up your Java and Maven locally
- Checkout the relevant Java projects from a code repository like Subversion (aka SVN).
- Set up data sources, environment variables, and .properties files.
- 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 file, 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+ left mouse click is very powerful drill down from ClassA to ClassB method invocations.
Step #3.1.2: Once you have worked out which artefacts 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.
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 artefacts from there.
Step #4: If you can’t remember these short-cut keys initially, all you have to remember is
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 –> 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.