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

DDD and Spring Boot

zhanpon
December 15, 2018

DDD and Spring Boot

JJUG CCC 2018 Fallでの発表資料です。

zhanpon

December 15, 2018
Tweet

More Decks by zhanpon

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ: @zhanpon • 2017೥10݄ɿϠϑʔʹ৽ଔೖࣾ • 2018೥4݄ɿJava, Spring BootΛ࢖͍͸͡ΊΔ • 2018೥5݄ɿJJUG

    CCC 2018 SpringʹॳࢀՃ ձࣾͰͷओͳ׆ಈ • ਪનγεςϜͷ։ൃɾӡ༻ Copyright © 2018 Yahoo Japan Corporation. All rights reserved.
  2. DDDͱ͸Կ͔ • υϝΠϯۦಈઃܭ (Domain-Driven Design) ͷུশ • Eric Evans ͷ

    "Domain-Driven Design: Tackling Complexity in the Heart of Software" ͱ͍͏ຊ͕ݩʹͳ͍ͬͯΔ • ෯޿͍࿩୊͕͋ͬͯҰݴͰ͸આ໌Ͱ͖ͳ͍ Copyright © 2018 Yahoo Japan Corporation. All rights reserved.
  3. ΤϯςΟςΟΛ࣮૷͢Δ @Entity public class User { @Id private String id;

    private String fullName; // getterͱsetter } Copyright © 2018 Yahoo Japan Corporation. All rights reserved.
  4. ίϯτϩʔϥʔΛ࣮૷͢Δ @RestController public class UserController { @Autowired UserRepository userRepository; @GetMapping("/users")

    public List<User> allUsers() { return userRepository.findAll(); } } Copyright © 2018 Yahoo Japan Corporation. All rights reserved.
  5. φΠʔϒʹ࣮૷ͨ͠Β • ϦϙδτϦʹΞΫηε͢ΔΫϥε (DockerRegistryAccessor) ͱ࣮ߦ؀ڥʹσϓϩΠ͢ΔΫϥε (KubernetesDeployer) Λ༻ ҙ͢Δ • DockerRegistryAccessor

    ͕࠷৽൛Λऔͬͯ͘Δ • KubernetesDeployer ͕ͦΕΛσϓϩΠ͢Δ Copyright © 2018 Yahoo Japan Corporation. All rights reserved.
  6. Version • ఆظతʹੜ੒͞ΕΔػցֶशͷ੒Ռ෺ɻྫɿݘೣ෼ྨثͷ2018 ೥12݄15೔9࣌όʔδϣϯ @Value public class Version { private

    final String modelName; private final Instant instant; } Copyright © 2018 Yahoo Japan Corporation. All rights reserved.
  7. Policy public enum Policy { NONE((versions, t) -> Optional.empty()), LATEST((versions,

    t) -> { return versions.latest(); }) private BiFunction<VersionSet, Instant, Optional<Version>> policy; Policy(BiFunction<VersionSet, Instant, Optional<Version>> policy) { this.policy = policy; } } Copyright © 2018 Yahoo Japan Corporation. All rights reserved.
  8. Deployer public interface Deployer { void deploy(Version version); } Copyright

    © 2018 Yahoo Japan Corporation. All rights reserved.