Posts

Showing posts from July, 2013

Dead Code

Hi Everyone, in this post I will be describing about dead code. I have heard about dead code only recently and thought of putting it in blog. 'Dead code' as it name suggests is a piece of code which is dead or has got no chance of it being executed. In other words dead code is a type of code which is unreachable. I will provide an example which will helps in understanding more about dead code. Consider a piece of code in Java. String fullName = employee.getFirstName() +  " "  + employee.getLastName(); if (fullName!= null ) { fullName =  "Sujith" ; } In the above example the code in the 'if' loop would never be executed. The reason is string 'fullName' cannot be empty because of the space (" ") we are adding between employee.getFirstName() and employee.getLastName().  It doesn't matter even if both employee.getFirstName() and employee.getLastName() be null, "fullName" would not be null. Some IDE's li

Maven project which adds another project as a dependency.

Image
Hi Everyone, in this post, I will be discussing about how to add another project as a dependency in maven. Maven is a build automation tool primarily used for java projects. Currently, maven is the most common build tool used in the software market. Please check the wiki page for maven to know more topics. I will be demonstrating this example by creating 2 projects named 'MavenProject' and 'MavenProject2'. The first project 'MavenProject' is added as a dependency to the second project 'MavenProject2'. To add a project as a dependency in Maven, the project is added as a dependency to pom.xml of the project which refers the latter project. pom.xml is the xml representation of maven project. It stands for project object model. Click here to read more about pom.xml. The structure of the first project is as follows: The class file MavenProject.java is as follows: package  com.techjourney.maven; public   class  MavenProjec