Whats your code style? isBigger(...) contest!
Rules
Hi there! In this blog i want to see and learn from you. Post a), b), c) and so to show us how you code and why. Share your expirience with us. You may type/post your own solution if it isn't here. The goal of this post is to figure out the best code snippet to solve a specific, concrete problem as clean as you can and to share it with the world.
The Task
Tell us how you would resolve spontaneously following current task:
how would you write a method that checks if one value is greater than the other?
how would you write a method that checks if one value is greater than the other?
Solution A)
boolean isBigger( int a, int b){ boolean result=false; if(a>b){ result=true; } return result; }
Solution B)
boolean isBigger( int a, int b){ if(a>b){ return true; } return false; }
Solution C)
boolean isBigger( int a, int b){ return a>b? true: false; }
Solution D)
boolean isBigger( int a, int b){ return a>b; }
Solution E)
boolean isBigger( int a, int b){ return Integer.valueOf(a).compareTo(Integer.valueOf(b)) <0; }
Solution F)
interface compare<T>{ boolean isBigger(T a, T b); }
Solution G)
<T> boolean isBigger( T a, T b){ return a > b; }
Solution H)
boolean isLeftValueBiggerThanRightValue ( int leftValue, int rightValue){ return leftValue > rightValue && leftValue != rightValue; }
Solution I)
<T> boolean isBigger( T value1, T value2){ final int equal = 0; return T.valueOf(value1).compareTo(T.valueOf(value2)) > equal; }