ϓϩηεϝτϦΫεΛ༻͍ͨϝιουநग़ϦϑΝΫλϦϯάͷਪનʹ޲͚ͯాத େथ1

ቐ Ըಬ1٢ా ଇ༟2౻‫ݡ ݪ‬ೋ3൧ా ‫ݩ‬1֓ཁɿ։ൃऀ͸ιϑτ΢ΣΞอक࡞‫ۀ‬Λߦ͏ࡍɼιʔείʔυͷอकੑ΍ՄಡੑΛ޲্ͤ͞ΔͨΊʹɼϦϑΝΫλϦϯάΛ࣮ࢪ͢Δඞཁ͕͋Δɽຊߘ͸ɼϓϩηεϝτϦΫεΛ༻͍ͨϝιουநग़ϦϑΝΫλϦϯάͷਪનΛߦ͏ͨΊʹɼզʑͷ‫ط‬ଘͷ‫ڀݚ‬Λ঺հ͠ɼຊϫʔΫγϣοϓͰͱࠓ‫ޙ‬ͷ՝୊Λٞ࿦͢Δɽ

Toward Recommendation of Extract Method Refactoring
Using Process Metrics

1. ͸͡Ίʹ࣮ࢪ͞ΕΔͨΊɼιʔείʔυͷ඼࣭ʹӨ‫ڹ‬Λ༩͑Δ։ൃϓϩηε͔Β‫ܭ‬ଌ͞ΕΔϓϩηεϝτϦΫεͱɼϦϑΝΫϦϑΝΫλϦϯάͱ͸ɼ֎෦͔Β‫͖ͱͨݟ‬ͷৼΔ෣͍ΛλϦϯάͷ࣮ࢪʹ͸૬͕ؔ͋Δͱߟ͑ΒΕΔɽ͔͠͠ɼϓอͪͭͭɼอकੑ΍ՄಡੑΛ޲্ͤ͞ΔͨΊʹɼιϑτϩηεϝτϦΫεͱϦϑΝΫλϦϯάͷؔ܎ʹ͍ͭͯɼఆ΢ΣΞͷ಺෦ߏ଄Λ੔ཧ͢Δ͜ͱͰ͋Δ [1]ɽFowler ͸ࣗྔతͳௐࠪ͸࣮ࢪ͞Ε͍ͯͳ͍ɽ෼ͷຊͰϦϑΝΫλϦϯάύλʔϯΛఆ্ٛͨ͠ʹɼͲͷͦ͜Ͱɼզʑͷ‫ط‬ଘ‫Ͱڀݚ‬͸ɼϝιουநग़ͷର৅ͱΑ͏ͳίʔυยʹରͯ͠ͲͷϦϑΝΫλϦϯάύλʔϯΛͳͬͨϝιουͷಛ௃Λௐࠪ͠ɼϝιουநग़ͷର৅ͱͳ࣮ࢪ͢΂͖͔͕ࣔ͞Ε͍ͯΔɽΔϝιουΛਪન͢Δ‫ػ‬ցֶशϞσϧΛߏங͠ɼͦͷ༗ޮ։ൃऀ͸ιϑτ΢ΣΞอक࡞‫ۀ‬Λߦ͏ࡍɼιʔείʔυͷอकੑ΍ՄಡੑΛ޲্ͤ͞ΔͨΊʹɼϦϑΝΫλϦϯάΛ࣮ࢪ͢Δඞཁ͕͋Δɽ͔͠͠ɼେ‫ن‬໛ͳιʔείʔυ͔ΒϦϑΝΫλϦϯάީิΛ‫͚ͭݟ‬Δ͜ͱ͸ࠔ೉Ͱ͋ΔͨੑΛධՁͨ͠ [6]ɽࠓ‫ޙ‬ɼզΕͷ‫ط‬ଘ‫͓ڀݚ‬ΑͼຊϫʔΫγϣοϓͰͱٞ࿦͍ͨ͜͠ͱΛ঺հ͢Δɽ

2. ‫ط‬ଘ‫ڀݚ‬ͷ঺հΊɼ։ൃऀͷϦϑΝΫλϦϯά࡞‫ۀ‬Λࢧԉ͢ΔͨΊͷٕज़զʑͷ‫ط‬ଘ‫Ͱڀݚ‬͸ϓϩηεϝτϦΫεΛ༻͍ͯɼϝ΍πʔϧ͕ଟ͘ఏҊ͞Ε͍ͯΔ [2] [3]ɽ͔͠͠ɼ͜ΕΒͷιουநग़ͷର৅ͱͳͬͨϝιουͷಛ௃Λௐࠪͨ͠ [6]ɽٕज़΍πʔϧΛɼ։ൃऀ͸͋·Γར༻͍ͯ͠ͳ͍ͱ͍͏ใৄࡉʹ͸ɼΦʔϓϯιʔεϓϩδΣΫτͰ͋Δ jEdit*1 ͷࠂ΋͋Δ [4]ɽͦͷͨΊɼ‫ऀڀݚ‬͸ΑΓ޿͘ར༻͞ΕΔϦ7,707 ϦϏδϣϯ‫ݸ‬ͷର৅ʹ౻‫ݪ‬ΒͷఏҊͨ͠ Kenja[7] ΛϑΝΫλϦϯάࢧԉπʔϧΛ։ൃ͢ΔͨΊʹɼ։ൃऀͷϦ༻͍ͯɼϝιουநग़ϦϑΝΫλϦϯάͷ‫ݕ‬ग़ΛߦͬͨɽϑΝΫλϦϯά࡞‫ۀ‬ͷ࣮ଶΛΑΓਖ਼֬ʹ೺Ѳͨ͠͏͑Ͱɼͦͷ‫ޙ‬ɼιʔείʔυͷ඼࣭ʹӨ‫ڹ‬Λ༩͍͑ͯΔͱߟ͑Βࢧԉख๏Λ‫ݕ‬౼͍ͯ͘͠ඞཁ͕͋ΔɽΕΔɼίʔυยͷมߋճ਺΍ɼͦͷมߋʹؔΘͬͨ։ൃऀιʔείʔυͷಛ௃Λఆྔతʹද‫͢ݱ‬Δํ๏ͱͯ͠ɼϓ਺౳ͷϝτϦΫεΛ༻͍ͯநग़ͷର৅ͱͳͬͨϝιουͱɼϩμΫτϝτϦΫεҎ֎ʹɼ։ൃͷཤྺ৘ใΛ༻͍ͯ‫ܭ‬ଌର৅ͱͳΒͳ͔ͬͨϝιουΛൺֱ͠ɼίʔυยͷมߋճ͢ΔϓϩηεϝτϦΫε͕͋Δ [5]ɽ։ൃϓϩηε͸ιʔ਺ͱΦʔαʔ਺ɼίʔυยͷมߋྔͰ͋Δ௥Ճɾ࡟আɾมείʔυͷ඼࣭ʹӨ‫ڹ‬Λ༩͑ΔɽϦϑΝΫλϦϯά͸Ұൠߋߦ਺ʹɼϝιουநग़ͷର৅ͱͳͬͨϝιουͱɼର৅తʹɼอकੑ΍Մಡੑ͕௿͍඼࣭ͷѱ͍ίʔυยΛର৅ʹͱͳΒͳ͔ͬͨϝιουؒͰ༗ҙ͕ࠩ֬ೝͰ͖ͨɽද 1 ͸ௐࠪର৅ͷϓϩηεϝτϦΫεͷҰཡͱൺֱ݁ՌΛදͯ͠

123ಸྑઌ୺ٕज़େֶӃେֶ৘ใՊֶ‫ڀݚ‬Պ໊‫ݹ‬԰େֶେֶӃ৘ใՊֶ‫ڀݚ‬Պ๛ా޻‫ߴۀ‬౳ઐ໳ֶߍ৘ใ޻ֶՊ

*1

http://www.jedit.orgද 1ࠞೖͳͲଞͷଟ͘ͷϓϩηεϝτϦΫε͕ଘࡏ͢Δɽ‫ܭ‬ଌϓϩηεϝτϦΫεͱൺֱ݁ՌϝτϦΫε༗ҙࠩ͋Γιʔείʔυͷมߋճ਺˓ιʔείʔυͷΦʔαʔ਺˓ͦͷͨΊɼ‫ط‬ଘͷϓϩηεϝτϦΫε͔ΒͲͷϓϩηεϝτϦΫεΛௐࠪର৅ʹ͢Δ΂͖͔Λ‫ݕ‬౼͢Δඞཁ͕͋Δɽଘࡏ‫ؒظ‬ιʔείʔυͷ௥Ճߦ਺˓ιʔείʔυͷ࡟আߦ਺˓ιʔείʔυͷมߋߦ਺˓

4. ·ͱΊຊߘͰ͸ɼϓϩηεϝτϦΫεΛ༻͍ͨϝιουநग़ϦϑΝΫλϦϯάͷਪનΛߦ͏ͨΊʹɼզʑͷ‫ط‬ଘͷ‫ڀݚ‬Λ঺հ͠ɼຊϫʔΫγϣοϓͰͱࠓ‫ޙ‬ͷ՝୊Λٞ࿦͢Δɽࠓ͍Δɽ·ͨɼϓϩηεϝτϦΫεͷௐࠪ݁ՌΛ౿·͑ɼϝιο‫ޙ‬ͷ՝୊ͱͯ͠ɼΑΓଟ͍ϦϑΝΫλϦϯάύλʔϯ͓Αυநग़ͷର৅ͱͳΔϝιουΛਪન͢Δ‫ػ‬ցֶशϞσϧΛͼϓϩηεϝτϦΫεΛର৅ʹௐࠪΛߦ͍ɼϓϩηεϝτߏங͠ɼͦͷ༗ޮੑΛධՁͨ͠ɽֶशʹར༻͢ΔϝτϦΫϦΫεΛ༻͍ͨϝιουநग़ϦϑΝΫλϦϯάͷਪનπʔεͷ૊Έ߹ΘͤΛมԽͤͨ͞ 6 छྨͷϞσϧΛߏங͠ɼͦϧΛ։ൃ͢Δɽ

ΕΒͷਫ਼౓Λൺֱͨ͠ɽ࣮‫ݧ‬ͷ݁ՌɼैདྷΑΓར༻͞Ε͖ͯͨϓϩμΫτϝτϦΫεͱɼຊ‫ڀݚ‬ͷௐࠪର৅Ͱ͋Δϓࢀߟจ‫ݙ‬ϩηεϝτϦΫεͷ྆ํΛར༻ͨ͠ਪનϞσϧ͕ɼF ஋͕[1]

0.827 ͱ࠷΋ߴ͍ਫ਼౓Λࣔͨ͠ɽ[2]

3. ٞ࿦͍ͨ͜͠ͱ2 ষͰ঺հͨ͠զʑͷ‫ط‬ଘ‫ڀݚ‬Λ݁ՌΛ౿·͑ͯɼຊϫʔΫγϣοϓͰ͸ҎԼͷ࿩୊ʹؔͯٞ͠࿦Λߦ͍͍ͨɽର৅ϦϑΝΫλϦϯάύλʔϯʹؔͯ͠ɿ[3]զʑͷ‫ط‬ଘ‫ݚ‬‫Ͱڀ‬͸ɼϝιουநग़ϦϑΝΫλϦϯάύλʔϯͷΈ[4]Λର৅ʹͨ͠ɽ͔͠͠ɺMurphy-Hill ͷௐࠪʹΑΔͱɼ։ൃऀ͸ϝιουநग़ϦϑΝΫλϦϯάύλʔϯҎ֎[5]ʹϝιουͷΠϯϥΠϯԽϦϑΝΫλϦϯάύλʔϯͳͲͷϦϑΝΫλϦϯάύλʔϯ΋සൟʹ࣮ࢪ͍ͯ͠

[6]

Δ [4]ɽͦͷͨΊʹɼϝιουநग़ϦϑΝΫλϦϯάύλʔϯҎ֎ͷϦϑΝΫλϦϯάύλʔϯʹ΋ࢧԉ͕ඞཁͰ͋ΓɼͦΕΒͷϦϑΝΫλϦϯάύλʔϯʹؔ͠

[7]ͯ΋ௐࠪ͢Δඞཁ͕͋Δɽ͔͠͠ɼFowler ఏҊͨ͠ɼ̒̏‫ݸ‬ͷϦϑΝΫλϦϯάύλʔϯͷதͰͲͷϦϑΝΫλϦϯάύλʔϯΛௐࠪର৅ʹ͢Δ͔ΛܾΊͳ͚Ε͹ͳΒͳ͍͕ͲͷϦϑΝΫλϦϯάύλʔϯΛௐࠪର৅ʹؔͯ͠Λ‫ݕ‬౼͢Δඞཁ͕͋ΔɽϦϑΝΫλϦϯά‫ݕ‬ग़ʹؔͯ͠ɿզʑͷ‫ط‬ଘ‫Ͱڀݚ‬͸,ίϛοτ୯ҐͰϝιουநग़ϦϑΝΫλϦϯάΛ‫ݕ‬
ग़͢Δπʔϧ Kenja[7] Λ༻͍ͯͨɽ‫Ͱ·ࡏݱ‬ଟ͘ͷϦϑΝΫλϦϯά‫ݕ‬ग़πʔϧ͕ఏҊ͞Ε͖͕ͯͨɼίϛοτ୯ҐͰϦϑΝΫλϦϯά‫ݕ‬ग़Λߦ͏πʔϧ͸গͳ͍ [8]ɽͦͷͨΊʹɼίϛοτ୯ҐͰޮ཰తʹϦϑΝΫλϦϯά‫ݕ‬ग़Λߦ͏ͨΊʹͲ͏ͨ͠Β͍͍͔Λ‫ݕ‬౼͢Δඞཁ͕͋Δɽௐࠪର৅ϓϩηεϝτϦΫεʹؔͯ͠ɿզʑͷ‫ط‬ଘ‫ڀݚ‬Ͱ͸, ιʔείʔυͷมߋճ਺ɼιʔείʔυͷΦʔαʔ਺ɼιʔείʔυͷ௥Ճߦ਺ɼιʔείʔυͷ࡟আߦ਺ɼιʔείʔυͷมߋߦ਺ͷ̒‫ݸ‬ͷϓϩηεϝτϦΫεΛର৅ʹͯ͠ௐࠪΛߦͬͨɽ͔͠͠ɼόάͷ[8]Fowler, M.: Refactoring: Improving the Design of Existing Code, Addison Wesley (1999).
Tsantalis, N. and Chatzigeorgiou, A.: Identiﬁcation of extract method refactoring opportunities for the decomposition of methods, The Journal of Systems and Software,Vol. 84, pp. 1757–1782 (2011).
‫ޙ‬౻ɹ঵ɼ٢ాଇ༟ɼ౻‫ݡݪ‬ೋɼቐɹԸಬɼҪ্ࠀ࿠ɿ‫ػ‬ցֶशΛ༻͍ͨϝιουநग़ϦϑΝΫλϦϯάͷਪનํ๏ɼ
৘ใॲཧֶձ࿦จࢽɼVol. 56, No. 2, pp. 627–636 (2015).
Murphy-Hill, E., Parnin, C. and Black, A. P.: How We
Refactor, and How We Know It, IEEE Transactions onSoftware Engineering, Vol. 38, No. 1, pp. 5–18 (2012).
ാɹल໌ɼਫ໺ɹमɼ٠໺ɹ‫ږ‬ɿෆ۩߹༧ଌʹؔ͢ΔϝτϦΫεʹ͍ͭͯͷ‫ڀݚ‬࿦จͷ‫ܥ‬౷తϨϏϡʔɼίϯϐϡʔλιϑτ΢ΣΞɼVol. 29, No. 1, pp. 106–117 (2012).
ాதେथɼቐɹԸಬɼ٢ాଇ༟ɼ౻‫ݡݪ‬ೋɼ൧ాɹ‫ݩ‬ɿϓϩηεϝτϦΫεΛ༻͍ͨϝιουநग़ࣄྫͷௐࠪͱ༧ଌϞσϧͷߏஙɼిࢠ৘ใ௨৴ֶձٕज़‫ڀݚ‬ใࠂ 512,SS2016-73ɼిࢠ৘ใ௨৴ֶձ (2017).
౻‫ݡݪ‬ೋɼ٢ాଇ༟ɼ൧ాɹ‫ݩ‬ɿߏจ৘ใϦϙδτϦΛ༻͍ͨࡉཻ౓ϦϑΝΫλϦϯά‫ݕ‬ग़ख๏ɼ৘ใॲཧֶձ࿦จ
ࢽɼVol. 56, No. 1, pp. 47–59 (2015).
ቐɹԸಬɼ౻‫ݡݪ‬ೋɼ٢ాଇ༟ɼྛɹ৾ฏɿมߋཤྺղੳʹ‫ͮ͘ج‬ϦϑΝΫλϦϯά‫ݕ‬ग़ٕज़ͷௐࠪɼίϯϐϡʔλιϑτ΢ΣΞɼ Vol. 32, No. 12, pp. 2346–2357 (2015).