値オブジェクトの悩みポイントとどう付き合っていくか

D98762c822b683773188e826a00d243e?s=47 yachiy
July 30, 2019

 値オブジェクトの悩みポイントとどう付き合っていくか

D98762c822b683773188e826a00d243e?s=128

yachiy

July 30, 2019
Tweet

Transcript

  1. ஋ΦϒδΣΫτͷ೰ΈϙΠϯτͱ Ͳ͏෇͖߹͍͔ͬͯ͘ !ZBDIJZ@

  2. !ZBDIJZ@ IUUQTZBDIJZIBUFOBCMPHDPN ࠓճͷࢿྉ΍ࡌ͖ͤΕͳ͔ͬͨ ೰ΈϙΠϯτ͸ͪ͜ΒͰ΋ڞ༗͠·͢ʂ

  3. ࿩͢͜ͱ

  4. None
  5. wϞσϧͱ࣮૷ΛΑΓਂ݁͘ͼ͚ͭΔ wෳࡶͳίʔυΛ໌നͰ༧ଌͰ͖Δ΋ͷʹ͢Δ ஋ΦϒδΣΫτΛ࣮૷͍ͯ͘͠ʹ͋ͨͬͯͷ೰ΈϙΠϯτ

  6. Ͳ͜·Ͱܕͱͯ͠༻ҙ͢Δ͔ /VMMBCMFͳ஋ΛऔΓѻ͏৔߹ όϦσʔγϣϯͲ͜ʹॻ͔͘ (FUUFS4FUUFSΛॻ͖ͨ͘ͳ͍͕ར༻ଆͰ಺෦ͷ஋Λࢀর͍ͨ͠ͱ͖Ͳ͏͢Δ͔ Ͳ͜·ͰίϨΫγϣϯΦϒδΣΫτΛ༻ҙ͢Δ͔ TUBUJDϑΝΫτϦϝιουΛ༻͍Δ΂͖͔ ύοέʔδߏ੒Ͳ͏͢Δ͔ JOOFS$MBTTΛ࢖͏΂͖͔൱͔ ೰Έ͕ͪ ࡉ͔͍࿩

  7. Ͳ͜·Ͱܕͱͯ͠༻ҙ͢Δ͔

  8. public class PersonName { private String firstName; private String lastName;

    public String fullName() { return String.format("%s %s", firstName, lastName); } } ͜ͷ͘Β͍ͳΒಛʹ೰·ͳ͍ ྫͷࢀরݩɿ
  9. public class PersonName { private String firstName; private String lastName;

    public String fullName() { return String.format("%s %s", firstName, lastName); } } ݸผͷৼΔ෣͍͸ͳͦ͞͏ͳͷͰಛʹ೰·ͳ͍
  10. public class PersonName { private String firstName; private String lastName;

    private String middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } }
  11. public class PersonName { private String firstName; private String lastName;

    private String middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } ໊ࣈɺ໊લͱ͸ໟ৭͕ҧ͏ ˠݸผͷৼΔ෣͍͕͋Γͦ͏ ˠཁૉͷ஋ΦϒδΣΫτԽΛݕ౼
  12. public class MiddleName { private static final int MIN_LENGTH =

    1; private static final int MAX_LENGTH = 100; // null͕ೖΒͳ͍͜ͱ͸ݕূ͞Ε͍ͯΔ૝ఆ → ࢦఆ͕ͳ͍͜ͱ͸ۭจࣈͰදݱ private String value; // ίϯετϥΫλ΍ੜ੒ϝιουͰݕূ͢Δ͔ར༻ଆͰݕূ͔ͯ͠Β౉͔͢͸·ͨผͷ೰ΈϙΠϯτ… ... // ඞཁʹԠͯ͡༻ҙ public boolean isSpecified() { // value͕ۭจࣈͰͷੜ੒͸ڐͯ͠΋nullͰͷੜ੒͸ڐ͞ͳ͍ඞཁ͋Γ return !value.isEmpty(); } @Override public String toString() { return value; } ... }
  13. public class MiddleName { private static final int MIN_LENGTH =

    1; private static final int MAX_LENGTH = 100; // null͕ೖΒͳ͍͜ͱ͸ݕূ͞Ε͍ͯΔ૝ఆ → ࢦఆ͕ͳ͍͜ͱ͸ۭจࣈͰදݱ private String value; // ίϯετϥΫλ΍ੜ੒ϝιουͰݕূ͢Δ͔ར༻ଆͰݕূ͔ͯ͠Β౉͔͢͸·ͨผͷ೰ΈϙΠϯτ… ... // ඞཁʹԠͯ͡༻ҙ public boolean isSpecified() { // value͕ۭจࣈͰͷੜ੒͸ڐͯ͠΋nullͰͷੜ੒͸ڐ͞ͳ͍ඞཁ͋Γ return !value.isEmpty(); } @Override public String toString() { return value; } ... } ໊લ΍໊ࣈʹ΋ಉ༷ͷੑ࣭͸͋Γͦ͏ ˠ4USJOH͔Β஋ΦϒδΣΫτԽΛݕ౼ͯ͠΋ྑͦ͞͏ ஋ͷൣғΛ੍ݶͯ͠ ϓϩάϥϜΛΘ͔Γ ΍҆͘͢શʹ
  14. public class MiddleName { private static final int MIN_LENGTH =

    1; private static final int MAX_LENGTH = 100; // null͕ೖΒͳ͍͜ͱ͸ݕূ͞Ε͍ͯΔ૝ఆ → ࢦఆ͕ͳ͍͜ͱ͸ۭจࣈͰදݱ private String value; // ίϯετϥΫλ΍ੜ੒ϝιουͰݕূ͢Δ͔ར༻ଆͰݕূ͔ͯ͠Β౉͔͢͸·ͨผͷ೰ΈϙΠϯτ… ... // ඞཁʹԠͯ͡༻ҙ public boolean isSpecified() { // value͕ۭจࣈͰͷੜ੒͸ڐͯ͠΋nullͰͷੜ੒͸ڐ͞ͳ͍ඞཁ͋Γ return !value.isEmpty(); } @Override public String toString() { return value; } ... } όϦσʔγϣϯΛͲ͜ʹஔ͔͘͸·ͨผͷ೰ΈϙΠϯτ
  15. public class MiddleName { private static final int MIN_LENGTH =

    1; private static final int MAX_LENGTH = 100; // null͕ೖΒͳ͍͜ͱ͸ݕূ͞Ε͍ͯΔ૝ఆ → ࢦఆ͕ͳ͍͜ͱ͸ۭจࣈͰදݱ private String value; // ίϯετϥΫλ΍ੜ੒ϝιουͰݕূ͢Δ͔ར༻ଆͰݕূ͔ͯ͠Β౉͔͢͸·ͨผͷ೰ΈϙΠϯτ… ... // ඞཁʹԠͯ͡༻ҙ public boolean isSpecified() { // value͕ۭจࣈͰͷੜ੒͸ڐͯ͠΋nullͰͷੜ੒͸ڐ͞ͳ͍ඞཁ͋Γ return !value.isEmpty(); } @Override public String toString() { return value; } ... } Ͳ͏ͯ͠΋ར༻ଆͰ஋ͷ͋Δͳ͠Λؾʹ͢ΔͳΒ࣮૷
  16. public class PersonName { private FirstName firstName; private LastName lastName;

    private MiddleName middleName; ... public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } }
  17. public class PersonName { private FirstName firstName; private LastName lastName;

    private MiddleName middleName; ... public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } ͜͜·Ͱຖճࡉ͔͘஋ΦϒδΣΫτԽ͢Δͷ͔
  18. public class PersonName { private String firstName; private String lastName;

    private String middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } public class PersonName { private FirstName firstName; private LastName lastName; private MiddleName middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } }
  19. public class PersonName { private String firstName; private String lastName;

    private String middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } public class PersonName { private FirstName firstName; private LastName lastName; private MiddleName middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } public class PersonName { private static final int MIN_FIRST_NAME_LANGTH = 1; private static final int MAX_FIRST_NAME_LENGTH = 100; private static final int MIN_MIDDLE_NAME_LENGTH = 1; private static final int MAX_MIDDLE_MAME_LENGTH = 100; private static final int MIN_LAST_NAME_LENGTH = 1; private static final int MAX_LAST_NAME_LENGTH = 100; private String firstName; private String lastName; private String middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } ্Ґ֓೦͕ߏ੒ཁૉͷ ஋ͷൣғΛ୲อ
  20. public class PersonName { private static final int MIN_FIRST_NAME_LANGTH =

    1; private static final int MAX_FIRST_NAME_LENGTH = 100; private static final int MIN_MIDDLE_NAME_LENGTH = 1; private static final int MAX_MIDDLE_MAME_LENGTH = 100; private static final int MIN_LAST_NAME_LENGTH = 1; private static final int MAX_LAST_NAME_LENGTH = 100; private String firstName; private String lastName; private String middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } public class PersonName { private String firstName; private String lastName; private String middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } public class PersonName { private FirstName firstName; private LastName lastName; private MiddleName middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } public class PersonName { private FirstName firstName; private LastName lastName; private MiddleName middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } ্Ґ֓೦͕ߏ੒ཁૉͷ ஋ͷൣғΛ୲อ ಛʹมΘΓͳ͠
  21. ஋ΦϒδΣΫτͷ਺Λ཈͑ΒΕΔ ্Ґ֓೦͕ߏ੒ཁૉͷੑ࣭΍ৼΔ෣͍΋୲อ ͢Δඞཁ͕͋Γݟ௨͕͠˚ ্Ґ֓೦ͷݟ௨͕͠˕ ஋ΦϒδΣΫτͷ਺͕૿͑Δ ʢதʹ͸΄΅ಉ͡Α͏ͳ΋ͷ΋ʣ ༻ҙ͞Ε͍ͯΔܕͷΈ ஋ΦϒδΣΫτͷΈ

  22. ஋ΦϒδΣΫτͷ਺Λ཈͑ΒΕΔ ্Ґ֓೦͕ߏ੒ཁૉͷੑ࣭΍ৼΔ෣͍΋୲อ ͢Δඞཁ͕͋Γݟ௨͕͠˚ ্Ґ֓೦ͷݟ௨͕͠˕ ஋ΦϒδΣΫτͷ਺͕૿͑Δ ʢதʹ͸΄΅ಉ͡Α͏ͳ΋ͷ΋ʣ ༻ҙ͞Ε͍ͯΔܕͷΈ ஋ΦϒδΣΫτͷΈ ͡Ό͋ϋΠϒϦου͸ʁ

  23. public class PersonName { private static final int MIN_FIRST_NAME_LANGTH =

    1; private static final int MAX_FIRST_NAME_LENGTH = 100; private static final int MIN_LAST_NAME_LANGTH = 1; private static final int MAX_LAST_NAME_LENGTH = 100; private String firstName; private String lastName; private MiddleName middleName; public String fullName() { return String.format("%s %s %s", firstName, middleName, lastName); } } ϛυϧωʔϜ͚͕ͩಛघͱ͍͏ҙਤ͸఻ΘΓͦ͏ ཧղͷෛՙ͸ߴͦ͏
  24. ؅ཧ͢Δߏ੒ཁૉ͕ଟ͘ͳ͍͔ ɹɹˠ੹຿͕ͭʹͳ͍ͬͯΔ͔  ݸʑͷৼΔ෣͍΍ੑ࣭͕গͳ͍͔ ɹɹˠ஋ΦϒδΣΫτʹҠৡͨ͠΄͏͕γϯϓϧʹͳΒͳ͍͔ Λݕ౼ গͳ͘ͱ΋ͭͷ֓೦ͷதͰ͸ͲͪΒ͔ʹ׬શʹ౗͢ ؾʹ͢Δ͜ͱ͕গͳ͍͏ͪ͸ ·ͱΊͯऔΓѻ͏͜ͱ΋ʜ ؾʹ͢Δ͜ͱ͕ଟ͘ͳ͖ͬͯͨΒؔ৺ࣄ

    ͝ͱʹऔΓѻ͍͍ͨ
  25. Ͳ͜·Ͱܕͱͯ͠༻ҙ͢Δ͔ /VMMBCMFͳ஋ΛऔΓѻ͏৔߹ όϦσʔγϣϯͲ͜ʹॻ͔͘ (FUUFS4FUUFSΛॻ͖ͨ͘ͳ͍͕ར༻ଆͰ಺෦ͷ஋Λࢀর͍ͨ͠ͱ͖Ͳ͏͢Δ͔ Ͳ͜·ͰίϨΫγϣϯΦϒδΣΫτΛ༻ҙ͢Δ͔ TUBUJDϑΝΫτϦϝιουΛ༻͍Δ΂͖͔ ύοέʔδߏ੒Ͳ͏͢Δ͔ JOOFS$MBTTΛ࢖͏΂͖͔൱͔ ೰Έ͕ͪ ࡉ͔͍࿩

    օ༷͕ͲͷΑ͏ʹߟ͑ͯɺͲ͏ͯͦ͠ͷ࣮૷ʹͨ͠ͷ͔ ͥͻͥͻɺ͓ฉ͔͍ͤͩ͘͞