ÇÔ¼ö°°Àº°Å ¸¸µé¶§
int result = value1 * value2;
return result;
ÀÌ·±½ÄÀ¸·Î ½á¿Ô´Âµ¥
Áö±Ý ÇÁ·ÎÁ§Æ®¿¡¼ ¼Ò³ª¸°Æ® ¾²´Âµ¥
declaring a variable only to immediately return or throw it is a bad practice.
À̶ó°í ¼öÁ¤±Ç°í ¶ß°Åµç¿ä
return value1 * value2; ÀÌ·±½ÄÀ¸·Î ¾²¶ó±¸¿ä
óÀ½ ¹è¿ï¶§ºÎÅÍ À§¿¡ ¹æ½ÄÀ¸·Î Ç϶ó°í ¹è¿ö¼ ±×·±°¡
°¡µ¶¼ºµµ ´õ ÁÁ°í µð¹ö±ëÇϱ⵵ ÆíÇÑ°Å °°Àºµ¥
¿Ö bad practiceÀÎÁö Àß ÀÌÇØ°¡ ¾ÈµÊ´Ï´Ù
2022.05.10 10:36:04 |
return¿ë ·ÎÄú¯¼ö ¼±¾ðÇÏ´Â°Ô ¾ÈÁÁÀº°ÅÀÓ? |
Àâ´ã | 2,582¸íÀÌ Àоú¾î¿ä.
|
2°³ÀÇ ´ñ±Û |
Àúµµ ±Ã±ÝÇؼ ã¾Æº¸´Ï
https://stackoverflow.com/questions/31733811/local-variables-before-return-statements-does-it-matter The method name should be sufficient for callers to know exactly what will be returned. ¶ó°í ½áÀֳ׿ä ÇÔ¼öÀ̸§ ÀÚü°¡ ¹» ¸®ÅÏÇÏ´ÂÁö ´ã°í ÀÖ¾î¾ß ÇѴٴµ¥ ¸Â´Â¸» °°±âµµ ÇÏ°í.. ¾öû Áß¿äÇÑ°Ç ¾Æ´Ñ°Å °°À¸´Ï Á¶Á÷³»¿¡¼ µ¿ÀÇÇÑ ¹æÇâÀ¸·Î ¸¸µé¸é µÉ°Å °°½À´Ï´Ù |
|
2022/05/10 11:19
|
¸ð¹æÀÌ Ã¢Á¶ÀÇ ¾î¸Ó´Ï¶ó´Â ¸»µµ ÀÖÁö¸¸..,
±Û¾´´Ô¹æ½Äµµ ÁÁÀº °Å °°¾Æ¿ä~ ±×·¸Áö¸¸.., ÇÁ·Î±×·¥ ³»¿¡¼´Â ±× ÇÁ·Î±×·¥ÀÇ ·êÀ» µû¶ó¾ß Çϱ⠶§¹®¿¡.. ¤Ð¤Ì Àú´Â ºñÁê¾ó½ºÆ©µð¿À 2022¾²´Â µ¥, C++ À±¼º¿ì(¾âÇ÷°ÀÇ C++)´Ô µ¿¿µ»ó°ÀÇ·Î ¹è¿ï·Á´Ï±ñ, ½±Áø ¾È³×¿ë~ ±Û¾´´Ô ÈÀÌÆà ^ ^bÇÏÀÌ¼Ò |
|
2022/09/05 12:20
|
°Ô½ÃÆÇ ¸ñ·ÏÀ¸·Î µ¹¾Æ°¡±â