Method Returns the Same Value  

 

Method Returns the Same Value °Ë»ç´Â ±×µéÀÌ ºÒ·ÁÁú ¶§¸¶´Ù °°Àº °ªÀ» ¹ÝȯÇÏ´Â ¸Þ¼Òµå¸¦ °Ë»öÇÕ´Ï´Ù.

¸¸ÀÏ Method returns the same value   üũ ¹Ú½º°¡ ¼±Åõǰí Inspection ÀÌ ¾î¶² ¹®Á¦¸¦ ãÀ¸¸é, Inspection Åø À©µµ¿ì´Â Ç×»ó °°Àº °ªÀ» ¹ÝȯÇÏ´Â ¸Þ¼Òµå¸¦ º¸¿©ÁÖ´Â Same return value  ÅÇÀ» Ç¥½ÃÇÕ´Ï´Ù.

ÀÌ °Ë»ç¿¡ ÀÇÇØ ¹ß°ßµÈ ¹®Á¦¿¡ ´ëÇÑ ¾î¶² »çÀü Á¤ÀÇÀÇ ¼Ö·ç¼Çµµ ¾ø½À´Ï´Ù.


ÀÌ °Ë»ç´Â ¾î¶² ¿É¼Çµµ °¡ÁöÁö ¾Ê½À´Ï´Ù.


 

»ç¿ë ¿¹



´ÙÀ½ Äڵ带 º¸½Ê½Ã¿À:

 
public interface AnInterface {
    boolean methodA(int myInt);
}
 
public class AClass implements AnInterface {
    public boolean methodA(int myInt) {
        if(myInt > 0){
        return true;
    } else {
        return true;
    }
}
 
public void methodB() {
    if(methodA(1) == true){
        //some code here
        }
    }
}
 
public class AClassTwo implements AnInterface {
 
    public boolean methodA(int myInt) {
        //some code here
        return true;
    }
 
    boolean methodB(int i) {
        if (i > 0) {
            return true;
        } else {
            return false;
        }
    }
}

 

Inspection ÀÌ ÁÖ¾îÁø ÀÎÅÍÆäÀ̽º¿Í Ŭ·¡½º¸¦ Æ÷ÇÔÇϰí ÀÖ´Â ÆÐŰÁö¿¡ Àû¿ëµÇ°í ³­ ÈÄ¿¡´ÙÀ½ÀÇ Åø À©µµ¿ì°¡ ³ªÅ¸³¯ °ÍÀÔ´Ï´Ù.



methodA ´Â ÁöÀûµÇ¾ú½À´Ï´Ù¸ðµç ¸Þ¼Òµå ±¸ÇöÀÇ ±× ¹Ýȯ°ªÀº Ç×»ó °°Àº °ÍÀÔ´Ï´Ù.