Friday, December 9, 2011

Whats your code style? isBigger contest!

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? 

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;
}


😱👇 PROMOTIONAL DISCOUNT: BOOKS AND IPODS PRO ðŸ˜±ðŸ‘‡

Be sure to read, it will change your life!
Show your work by Austin Kleonhttps://amzn.to/34NVmwx

This book is a must read - it will put you in another level! (Expert)
Agile Software Development, Principles, Patterns, and Practiceshttps://amzn.to/30WQSm2

Write cleaner code and stand out!
Clean Code - A Handbook of Agile Software Craftsmanship: https://amzn.to/33RvaSv

This book is very practical, straightforward and to the point! Worth every penny!
Kotlin for Android App Development (Developer's Library): https://amzn.to/33VZ6gp

Needless to say, these are top right?
Apple AirPods Pro: https://amzn.to/2GOICxy

😱👆 PROMOTIONAL DISCOUNT: BOOKS AND IPODS PRO ðŸ˜±ðŸ‘†