Consider I have some codes that use different logic for some special case, e.g.:bool compareRatio(unsigned int a,unsigned int b,unsigned int x,unsigned int y){    if(x==0){        return false;    }else if(y==0){        return true;    }else{        return (float)a/x<(float)b/y;    }}and to eliminate special case, I can rewrite it:bool compareRatio(unsigned int a,unsigned int b,unsigned int x,unsigned int y){    return a*y<b*x;}and for other similar situations such as searching in arrays with special case array size=0:int[] a={1,4,2,7,5,1};if(a.length == 0 ){}else{    for(int i=0;i<a.length;i++){    }}I can also rewrite it as:int[] a={1,4,2,7,5,1};for(int i=1;i<a.length;i++){}But my question is, should we tend to eliminate special case, or just leave it in the code? Or depend on cases? I think eliminate special case can reduce number of codes, but the codes become less straight forward. Alternatively, leaving special cases may make the code become ugly, but I think it is easier to maintain and can remind other programmers this business logic has some special conditions. Which style is preferred?
Should we embed special cases into business logic/algorithm or leave it separate?
coding style