Upgrade to Pro — share decks privately, control downloads, hide ads and more …

モジュールの深さについて / depth of module

nakabonne
January 28, 2019

モジュールの深さについて / depth of module

nakabonne

January 28, 2019
Tweet

More Decks by nakabonne

Other Decks in Technology

Transcript

  1. Ϟδϡʔϧͷਂ͞ʹ͍ͭͯ CAEC MeetUP #4

  2. Me • தඌ ྋ (@nakabonne) • தԝେֶ঎ֶ෦3೥ • AWAϚΠΫϩαʔϏε •

    Go, Envoy, etc…
  3. My tasks https://www.redhat.com/cms/managed-files/service-mesh-1680.png

  4. My tasks https://github.com/DataDog/dd-py-tracing-workshop

  5. Agenda • ྑ͍Ϟδϡʔϧͱ͸ • deep moduleͱ͸

  6. ྑ͍Ϟδϡʔϧͱ͸

  7. খ͍͞Ϟδϡʔϧʁ

  8. –The Unix Philosophy “Small is beautiful”

  9. ԿނϞδϡʔϧΛ࡞Δͷ͔

  10. ؔ࿈ੑͷߴ͍ཁૉ͕ू·Δ →࣮૷ͷෳࡶ͞ΛԼ͛Δ

  11. Open a file in Java FileInputStream fileStream = new FileInputStream(fileName);

    BufferedInputStream bufferedStream = new BufferedInputStream(fileStream); ObjectInputStream objectStream = new ObjectInputStream(bufferedStream);
  12. Open a file in Java FileInputStream fileStream = new FileInputStream(fileName);

    BufferedInputStream bufferedStream = new BufferedInputStream(fileStream); ObjectInputStream objectStream = new ObjectInputStream(bufferedStream); ॳาతͳI/O
  13. Open a file in Java FileInputStream fileStream = new FileInputStream(fileName);

    BufferedInputStream bufferedStream = new BufferedInputStream(fileStream); ObjectInputStream objectStream = new ObjectInputStream(bufferedStream); όοϑΝϦϯά
  14. Open a file in Java FileInputStream fileStream = new FileInputStream(fileName);

    BufferedInputStream bufferedStream = new BufferedInputStream(fileStream); ObjectInputStream objectStream = new ObjectInputStream(bufferedStream); read/write
  15. ࣮૷ͷෳࡶ͕͞࿙ΕͯΔ…

  16. • খ͍͞ͱ͍͏͜ͱ͸ɺ࣋ͬͯΔ৘ใྔ͕গͳ͍ • ࣋ͬͯΔ৘ใྔ͕গͳ͍ͱɺ࣮૷ͷෳࡶ͕͞࿙ Ε΍͍͢ • ࣮૷ͷෳࡶ͕͞࿙Ε͍ͯΔͱɺ࣮૷มߋ͕पΓ ʹӨڹΛ༩͑΍͘͢ͳΔ

  17. খ͞͞Λҙࣝ͗͢͠Δ

  18. খ͞͞Λҙࣝ͗͢͠Δ

  19. ߴڽूʁૄ݁߹ʁ

  20. ߴڽूʁૄ݁߹ʁ

  21. ߴڽूʁૄ݁߹ʁ ྑ͍ΠϯλʔϑΣʔε͕ඞཁ

  22. ྑ͍ΠϯλʔϑΣʔεͱ͸

  23. Bad interface

  24. Bad interface

  25. Bad interface

  26. ͔͠͠ιϑτ΢ΣΞ͸มߋ͞ΕΔ →͜ͷໃ६ͷதͰ΋่Εͳ͍͜ͱ͕ٻΊΒΕΔ

  27. Good interface ෆมʢ௥ՃҎ֎ͷมߋΛڐ͞ͳ͍ʣ

  28. And

  29. ࢖͍΍͋͘͢Δ΂͖

  30. –Rich Hickey “Easy is relative”

  31. Կ͕ศར͔͸ϢʔβʔʹΑΔ

  32. Use case Edge case General case

  33. Use case Edge case General case

  34. Ұൠతͳέʔεʹߜͬͯ ࢖͍΍͢͞Λ௥ٻ͢Δ

  35. ෳࡶԽͷཧ༝ FileInputStream fileStream = new FileInputStream(fileName); BufferedInputStream bufferedStream = new

    BufferedInputStream(fileStream); ObjectInputStream objectStream = new ObjectInputStream(bufferedStream); όοϑΝϦϯά͠ͳ͍ͱ͍͏ ΤοδέʔεΛڐ༰͍ͯ͠Δ
  36. Good module ؔ࿈ੑͷߴ͍ͨ͘͞ΜͷཁૉΛӅ࣋ͪ͠ɺ ҰൠతͳέʔεͰ࢖͍΍͘͢ෆมͳΠϯλʔ ϑΣʔεʹΑͬͯڧྗͳػೳΛఏڙ͢Δ

  37. ߟ͑Δ͜ͱଟ͗͢ʂ

  38. ຊ୊

  39. deep module

  40. A Philosophy of Software Design • ஶऀ͸ελϯϑΥʔυେֶ John Ousterhoutڭत •

    ઐ໳͸෼ࢄγεςϜ΍OS ͳͲଟذʹ౉Δ
  41. deep module γϯϓϧͳΠϯλʔϑΣʔεͰ ڧྗͳػೳΛఏڙ͢Δ

  42. deep vs shallow modules

  43. deep vs shallow modules

  44. ΠϯλʔϑΣʔεͷෳࡶ͞͸ίετͰ ػೳͷڧྗ͞͸རӹ

  45. ࢹ఺ • ػೳ͸ڧྗ͚ͩͲɺͦΕҎ্ʹΠϯλʔ ϑΣʔε͕ෳࡶʹͳͬͯͳ͍͔ʁ • ΠϯλʔϑΣʔε͸؆୯͚ͩͲɺػೳ ͸ශऑͰ͸ͳ͍͔ʁ

  46. ྫɿUnix ϑΝΠϧI/O • open() • read() • write() • close()

    • lseek() ←ෆม
  47. Χʔωϧ ϢʔβΞϓϦέʔγϣϯΛ҆ఆͯ͠ ಈ࡞ͤ͞ΔͨΊʹઃܭ͞Ε͍ͯΔ →ࢀߟʹͳΔ

  48. ·ͱΊ

  49. ·ͱΊ • ྑ͍Ϟδϡʔϧͱ͸ʮؔ࿈ੑͷߴ͍ͨ͘͞ΜͷཁૉΛӅ࣋ͪ͠ɺҰൠత ͳέʔεͰ࢖͍΍͘͢ෆมͳΠϯλʔϑΣʔεʹΑͬͯڧྗͳػೳΛఏ ڙ͢Δ΋ͷʯ • ࣮ݱ͢ΔͨΊʹʮϞδϡʔϧͷਂ͞ʯΛҙࣝ͢Δ • ͋͘·ͰҰͭͷߟ͑ํͰ͋ΔͨΊɺ൓࿦΢ΣϧΧϜ

  50. ͋Γ͕ͱ͏͍͟͝·ͨ͠