Home:ALL Converter>How to avoid if

How to avoid if

Ask Time:2019-04-17T22:27:53         Author:user9179966

Json Formatter

I have a Request object with field request_type and number of other fields. request_type can be 'additionRequest' , 'deletionRequest' 'informationRequest'. Based on request_type other fields in Request object are processed differently.

My simple minded approach is

if additionRequest
algorithm1
else if deletionRequest
algorithm2
else if deletionRequest
algorithm3
end

How I can avoid these if statements and still apply proper algorithm?

Author:user9179966,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/55729918/how-to-avoid-if
yy