Very easy question for these who spend some time on analyzing code written by co-workers.
When I write my code, I do my best to write it in a very, extremely readable way. But sometimes I have an impression, that I write it too easy... Simple example:
When I see such a code:
public Category getCategoryType(Component components){ if(component.hasSensor() && component.hasInputUnit && component.isValid() && !component.isSuspended()){ return Category.TYPE_A; } } the first thing I do is changing it into:
public Category getCategoryType(Component components){ boolean hasSensor = component.hasSensor(); boolean hasInput = component.hasInputUnit(); boolean isValid = component.isValid(); boolean isNotSuspended = !component.isSuspended(); if(hasSensor && hasInput && isValid && isNotSuspended){ return Category.TYPE_A; } } One of my collegue told me politely, that it is not necessary, because people can read a little more complicated code. But I think, that someone who will read this ode after me, will have a easier task (despite the fact, that I make this function a little bit longer)
Question for you: Do you think, that such changes in code are senseless?
Maybe only formatting stuff is sufficient:
public Category getCategoryType(Component components){ if(component.hasSensor() && component.hasInputUnit && component.isValid() && !component.isSuspended()){ return Category.TYPE_A; } }
final. \$\endgroup\$