I'm doing a code review at the moment on Java Android code. I am looking at a function where a programmer has decided to use a switch statement to wrap a single condition.
I am considering making a comment that this should be an if block instead. What are your thoughts, what would you do if you saw this in code?
It looks like a case where the switch will always be the one case and never expand beyond that ( because of the codes surrounding context ). Would the correct words be that this is the wrong construct for this use case?
pseudo code of function:
trackAnalyticsEvent()
switch
case is device not supported
analytics->trackEvent(device type not supported)
// No break or return
note: The core analytics code is actually handled elsewhere in the project. This a very specific single case inside a class with a specific focused usage.
if
.