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...