良いコードを書くためにやってみてること3つ.pdf

 良いコードを書くためにやってみてること3つ.pdf

9d4a459864f822fb5aa7a5741e60e26b?s=128

Keisuke kiuchi

October 31, 2018
Tweet

Transcript

  1. ྑ͍ίʔυΛॻͨ͘Ίʹ ΍ͬͯΈͯΔ͜ͱͭ LJVDIJLFJTVLF 4IJCVZBBQL

  2. ໦಺ܒี w ৬ۀɿ:ͷ"OESPJEΤϯδχΞ݉ҭࣇύύ w झຯͰ࡞ͬͨϞϊɿʮΒ͘ͰΜ "QQ ʯɺ
 ʮ$MFBO"SDIJUFDUVSF5FNQMBUF'PS,PUMJO 044 ʯ

    w Ϟοτʔɿ໌೔ͷࣗ෼ʹ༏͍͠ίʔυΛॻ͘ w 4/4
 5XJUUFS!GFJ@LPNF
 (JUIVC!LJVDIJLFJTVLF
 2JJUB!L@LFJTVLF
  3. ࠷ۙͷΞΫςΟϏςΟ

  4. ࠓճͷൃද͸ كʹΑ͋͘Δ໰୊Λ ׂͱΑ͋͘Δख๏Ͱղܾ͠Α͏ͥ ͱ͍͏γϯϓϧͳ࿩

  5. ΞδΣϯμ wҙຯͱ੍໿Λදݱ͠Α͏ wແΛදݱ͠Α͏ wϨϏϡʔ؍఺ΛγΣΞ͠Α͏

  6. ҙຯͱ੍໿Λදݱ͠Α͏

  7. ಥવͰ͕࣭͢໰Ͱ͢ WBMQIPOF/VN4USJOH ͱ͍͏ม਺ΛݟͨΒͲΜͳ஋Λ
 ૝૾͠·͔͢ʁ

  8. ࣍ͷ࣭໰ WBMUFMFQIPOF/VN4USJOH ͳΒͲ͏͍͏஋Ͱ͠ΐ͏

  9. None
  10. ࣅͯΔ͚ͲผͷҙຯΛ࣋ͭม਺ w QIPOF/VNl9999:::: w UFMFQIPOF/VNlUFM9999::::z ʮΒ͘ͰΜʯͷΞϓϦΑΓҰ෦վѱͯ͠ൈਮ

  11. EBUBΫϥε JOJUؔ਺Ͱ
 ҙຯͱ੍໿Λදݱ͠Α͏

  12. UFMFQIPOF/VNCFSJT data class TelephoneNumber(val number: String) { init { if

    (!number.startsWith(SCHEME)) { throw IllegalArgumentException(“error“) } else if (number.substring(SCHEME.length) .contains(Regex(“.*[^0-9#¥+¥*() -]+.*"))) { throw IllegalArgumentException(“error”) } } companion object { const val SCHEME = "tel:" } } 4$)&.&͔Β
 ࢝·ͬͯΔ͜ͱ ಛఆͷਖ਼نදݱΛ
 ຬͨ͢͜ͱ
  13. QIPOF/VNCFSJT class PhoneNumber(val number: String) { init { if (number.startsWith(TelephoneNumber.SCHEME))

    { throw IllegalArgumentException(“error") } else if ((number.contains(Regex(".*[^0-9#¥+¥*() -]+.*")))) { throw IllegalArgumentException(“error") } } } 4$)&.&͔Β࢝·ͬͯ
 ͍ͳ͍͜ͱ ಛఆͷਖ਼نදݱΛ
 ຬͨ͢͜ͱ
  14. ิ଍JOMJOF$MBTT PSEBUB$MBTT w *OMJOFDMBTT ,PUMJOWFSd  w JOJUϝιουΛ࣋ͯͳ͍ͷͰɺܕ੍໿ͷΈͰे෼ͷ৔߹ ʹར༻ w

    EBUBDMBTT w JOJUϝιουΛ࣋ͯΔͰɺܕ੍໿ ϩδΧϧͳ੍໿Λ΋ ͍ͨͤͨ৔߹ʹར༻ ˞͋͘·Ͱ๻ݸਓͷߟ͑ํͰ͢
  15. ແΛදݱ͠Α͏

  16. ࣍ͷ໰୊ ͋Δ-JTU͔Β৚݅ʹ߹கͨ͠
 ཁૉΛऔΓग़ؔ͢਺Λ࡞Γ͍ͨ

  17. val contactList = List<Contact>() fun findSameNumberContact(phoneNumber: PhoneNumber):Contact? { return contactList.find

    { it.getPhoneNumber() == phoneNumber } } ۭͷ-JTU͚ͩͲΩχγφΠσ
  18. ͍͍Ͷʂ☺

  19. val contactList = List<Contact>() fun findSameNumberContact(phoneNumber: PhoneNumber):Contact? { return contactList.find

    { it.getPhoneNumber() == phoneNumber } } Μʁ
  20. /VMMBCMFͩ

  21. ແΛදݱ͠Α͏

  22. val contactList = List<Contact>() fun findSameNumberContact(phoneNumber: PhoneNumber):Contact { return contactList.find

    { it.phoneNumber == phoneNumber } ?: Contact.NONE } data class Contact(val displayName: String, val contactId: String, val phoneNumber: PhoneNumber) { companion object { val NONE = Contact("", "", PhoneNumber("")) } } dddddddddddddddddddddddddddddddddddddddddddddddddddd
  23. /PO/VMMͰແΛදݱʂ ☺ ˞ͨͩ͠ɺ/VMMͷ··ʹͨ͠΄͏͕ྑ͍৔߹΋͋ΔͷͰ༻๏༻ྔΛकͬͯ࢖͍·͠ΐ͏

  24. ิ଍/VMMBCMF PSແΛදݱ w ແΛදݱˠ/VMMʹͳΔ͜ͱ͕ਖ਼ৗܥͷൣғ಺ͷ৔߹ྫ֎ॲཧ͕ෆ ཁʹͳΔ৔߹ w ྫ&EJU5FYUʹϢʔβʔ͕ೖྗͨ͠ి࿩൪߸ʹϚον͢Δి࿩൪߸Λ pOEͰݟ͚ͭɺి࿩൪߸Λදࣔ͢Δ ݟ͔ͭΒͳ͍ͳΒۭจࣈ 

    w /VMMͷ··ˠ/VMMʹͳΔ͜ͱ͕ຊདྷ͋Γ͑ͳ͍৔߹ w ྫి࿩ாҰཡͰνΣοΫΛೖΕͨ൪߸͚ͩΛpOEͰݟ͚ͭΔ ˞͋͘·Ͱ๻ݸਓͷߟ͑ํͰ͢
  25. ϨϏϡʔ؍఺ΛγΣΞ͠Α͏

  26. ๭೔ɺ͋Δ13ΛϨϏϡʔ ͍ͯͨ࣌͠ͷ͜ͱ

  27. ࢦఠͨ͠΄͏͕͍͍
 Օॴ͕ଟ͗͢Δ

  28. ࢦఠ͠ͳ͍Θ͚ʹ΋͍͔ͳ͍͕ɺ શ෦ࢦఠ͢Δͷ΋͠ΜͲ͍

  29. ͳͷͰɺָΛͭͭ͠ νʔϜٕज़ྗͷ޲্ʹܨ͕Δํ๏ Λ΍ͬͯΈͨ

  30. ձٞࣨΛ઎ڌͯ͠
 ϞϒϓϩతϨϏϡʔձΛ࣮ࢪ

  31. ϞϒϓϩతϨϏϡʔ w ࢀՃऀɿ"OESPJE&OHਓɺJ04&OHਓ w ୊ࡐɿྫͷ13 ,PUMJO  w ΍ͬͨ͜ͱɿ
 ࢦఠՕॴΛͲΜͲΜϗϫΠτϘʔυʹॻ͖ग़͢


    Ͳ͏௚ͨ͠΄͏͕͍͍͔ɺΛٞ࿦͢Δ
 ࢦఠΛ൓ө ͔͚ͨͬͨ͠Ͳ࣌ؒͷ౎߹্࣮ݱͤͣ
  32. ϞϒϓϩతϨϏϡʔ ˞ࣾ֎ൿͳͷͰϞβΠΫॲཧͯ͠·͢

  33. ΍ͬͯΈͨײ৮ w վΊͯݟͯΈΔͱʮ͜ͷ࣮૷ԿΛҙਤͯ͠ΔΜͩ ʯͬͯͷ͕
 ग़ͯ͘Δ w ࢦఠ͞ΕΕ͹౰ͨΓલͱࢥ͑Δ΋ͷ͕ଟ͍ w ม਺໊ؔ਺໊ͷ໋໊ͷେ੾͞Λ࠶ೝࣝͨ͠ w

    ,PUMJOʹ׳Εͯͳ͍ਓ͕ॻ͘ͱ7BS͕ଟ͘ͳΔ
  34. ϨϏϡʔ؍఺ΛγΣΞͯ͠ɺ
 νʔϜΈΜͳ͕ཧղͰ͖Δ
 ࣮૷Λ৺͕͚Α͏

  35. ·ͱΊ wࣅͨҙຯΛ͚࣋ͭͲҟͳΔม਺
 ˠҙຯͱ੍໿Λදݱ͠Α͏ wOVMMBCMFΛແ͘͢ํ๏
 ˠແΛදݱ͠Α͏ wνʔϜͷٕज़ྗ޲্΋݉Ͷͯۮʹ͸
 ϨϏϡʔ؍఺ΛγΣΞ͠Α͏

  36. ͓ΘΓͰͬ͢ʂ