lundi 7 mai 2018

Should I put if(variable < 10) in own method? [on hold]

I have a check in a loop where I have to check if the number of occurrence is less than 10 which could be written as either

 if(occ < 10){

 }

or

 if(checkIfOccurencyIsLessThan10(occ)){
         values.add(current+"0"+occ);
    }
     else{
          values.add(current+occ);
    }

I'm reading Clean Code a handbook of agile software craftsmanship, where they say a method should do the least amount, and code should be hacked up into more pieces. Is this necessary right here? I'm trying to get a better grasp on how long a method should be, and how much it should be doing.

Aucun commentaire:

Enregistrer un commentaire