Slide 1

Slide 1 text

Object Oriented Diversity Masanobu Naruse

Slide 2

Slide 2 text

あなたのオブジェクト指向は何ですか 2

Slide 3

Slide 3 text

3

Slide 4

Slide 4 text

4

Slide 5

Slide 5 text

5

Slide 6

Slide 6 text

6

Slide 7

Slide 7 text

7

Slide 8

Slide 8 text

8 オブジェクト指向

Slide 9

Slide 9 text

9 なんか違う

Slide 10

Slide 10 text

10 それ オブジェクト指向 じゃないよ

Slide 11

Slide 11 text

11 それ オブジェクト指向 じゃないよ いや オブジェクト指向 だよ

Slide 12

Slide 12 text

12

Slide 13

Slide 13 text

13 それ オブジェクト指向 じゃないよ いや オブジェクト指向 だよ

Slide 14

Slide 14 text

14 それ オブジェクト指向 じゃないよ いや オブジェクト指向 だよ C++ Smalltalk

Slide 15

Slide 15 text

15 それ オブジェクト指向 じゃないよ いや オブジェクト指向 だよ 抽象データ型 メッセージ パッシング

Slide 16

Slide 16 text

Object Oriented Diversity Masanobu Naruse

Slide 17

Slide 17 text

Object Oriented Diversity Masanobu Naruse

Slide 18

Slide 18 text

18 Diversity

Slide 19

Slide 19 text

19 多様性

Slide 20

Slide 20 text

多様性を上手く扱うには? 20

Slide 21

Slide 21 text

多様性を上手く扱うには? 21

Slide 22

Slide 22 text

多様性 22

Slide 23

Slide 23 text

Polymorphism 23

Slide 24

Slide 24 text

オブジェクト指向プログラミングを見てみよう! 24

Slide 25

Slide 25 text

25 public class ProposalSubmitService { private readonly IProposalRepository proposalRepository; public ProposalSubmitService(IProposalRepository proposalRepository) { this.proposalRepository = proposalRepository; } public void Handle(ProposalSubmitCommand command) { ... var proposal = new Proposal(command.Title, command.Outline); proposalRepository.Save(proposal); ... } }

Slide 26

Slide 26 text

26 public class ProposalSubmitService { private readonly IProposalRepository proposalRepository; public ProposalSubmitService(IProposalRepository proposalRepository) { this.proposalRepository = proposalRepository; } public void Handle(ProposalSubmitCommand command) { ... var proposal = new Proposal(command.Title, command.Outline); proposalRepository.Save(proposal); ... } }

Slide 27

Slide 27 text

27 public class ProposalSubmitService { private readonly IProposalRepository proposalRepository; public ProposalSubmitService(IProposalRepository proposalRepository) { this.proposalRepository = proposalRepository; } public void Handle(ProposalSubmitCommand command) { ... var proposal = new Proposal(command.Title, command.Outline); proposalRepository.Save(proposal); ... } }

Slide 28

Slide 28 text

28 public class ProposalSubmitService { private readonly IProposalRepository proposalRepository; public ProposalSubmitService(IProposalRepository proposalRepository) { this.proposalRepository = proposalRepository; } public void Handle(ProposalSubmitCommand command) { ... var proposal = new Proposal(command.Title, command.Outline); proposalRepository.Save(proposal); ... } }

Slide 29

Slide 29 text

29 public class ProposalSubmitService { private readonly IProposalRepository proposalRepository; public ProposalSubmitService(IProposalRepository proposalRepository) { this.proposalRepository = proposalRepository; } public void Handle(ProposalSubmitCommand command) { ... var proposal = new Proposal(command.Title, command.Outline); proposalRepository.Save(proposal); ... } }

Slide 30

Slide 30 text

30 public interface IProposalRepository { Proposal Find(ProposalId id); void Save(Proposal proposal); void Delete(Proposal proposal); }

Slide 31

Slide 31 text

31 public interface IProposalRepository { Proposal Find(ProposalId id); void Save(Proposal proposal); void Delete(Proposal proposal); }

Slide 32

Slide 32 text

32 public class ProposalSubmitService { private readonly IProposalRepository proposalRepository; public ProposalSubmitService(IProposalRepository proposalRepository) { this.proposalRepository = proposalRepository; } public void Handle(ProposalSubmitCommand command) { ... var proposal = new Proposal(command.Title, command.Outline); proposalRepository.Save(proposal); ... } }

Slide 33

Slide 33 text

33 public class ProposalSubmitService { private readonly IProposalRepository proposalRepository; public ProposalSubmitService(IProposalRepository proposalRepository) { this.proposalRepository = proposalRepository; } public void Handle(ProposalSubmitCommand command) { ... var proposal = new Proposal(command.Title, command.Outline); proposalRepository.Save(proposal); ... } }

Slide 34

Slide 34 text

34 public class ProposalSubmitService { private readonly IProposalRepository proposalRepository; public ProposalSubmitService(IProposalRepository proposalRepository) { this.proposalRepository = proposalRepository; } public void Handle(ProposalSubmitCommand command) { ... var proposal = new Proposal(command.Title, command.Outline); proposalRepository.Save(proposal); ... } }

Slide 35

Slide 35 text

35 public void Main(string input) { var repository = CreateRepository(input); var proposalSubmitService = new ProposalSubmitService(repository); var command = new ProposalSubmitCommand(); proposalSubmitService.Handle(command); } private IProposalRepository CreateRepository(string input) { switch (input) { case "local" : return new InMemoryProposalRepository(); case "production" : return new SqlProposalRepository(); default: throw new ArgumentOutOfRangeException(); } }

Slide 36

Slide 36 text

36 public void Main(string input) { var repository = CreateRepository(input); var proposalSubmitService = new ProposalSubmitService(repository); var command = new ProposalSubmitCommand(); proposalSubmitService.Handle(command); } private IProposalRepository CreateRepository(string input) { switch (input) { case "local" : return new InMemoryProposalRepository(); case "production" : return new SqlProposalRepository(); default: throw new ArgumentOutOfRangeException(); } }

Slide 37

Slide 37 text

37 public void Main(string input) { var repository = CreateRepository(input); var proposalSubmitService = new ProposalSubmitService(repository); var command = new ProposalSubmitCommand(); proposalSubmitService.Handle(command); } private IProposalRepository CreateRepository(string input) { switch (input) { case "local" : return new InMemoryProposalRepository(); case "production" : return new SqlProposalRepository(); default: throw new ArgumentOutOfRangeException(); } }

Slide 38

Slide 38 text

38 public void Main(string input) { var repository = CreateRepository(input); var proposalSubmitService = new ProposalSubmitService(repository); var command = new ProposalSubmitCommand(); proposalSubmitService.Handle(command); } private IProposalRepository CreateRepository(string input) { switch (input) { case "local" : return new InMemoryProposalRepository(); case "production" : return new SqlProposalRepository(); default: throw new ArgumentOutOfRangeException(); } }

Slide 39

Slide 39 text

39 public void Main(string input) { var repository = CreateRepository(input); var proposalSubmitService = new ProposalSubmitService(repository); var command = new ProposalSubmitCommand(); proposalSubmitService.Handle(command); } private IProposalRepository CreateRepository(string input) { switch (input) { case "local" : return new InMemoryProposalRepository(); case "production" : return new SqlProposalRepository(); default: throw new ArgumentOutOfRangeException(); } }

Slide 40

Slide 40 text

40 オブジェクト指向

Slide 41

Slide 41 text

41 public interface オブジェクト指向 { }

Slide 42

Slide 42 text

42 それ オブジェクト指向 じゃないよ いや オブジェクト指向 だよ C++ Smalltalk

Slide 43

Slide 43 text

43

Slide 44

Slide 44 text

コードを小説として捉えたとき 44

Slide 45

Slide 45 text

Polymorphism の役割は? 45

Slide 46

Slide 46 text

46 文脈

Slide 47

Slide 47 text

47 コンテキスト

Slide 48

Slide 48 text

IT技術分野には多くのコンテキストがある 48

Slide 49

Slide 49 text

モデル 49

Slide 50

Slide 50 text

エンティティ 50

Slide 51

Slide 51 text

ドメイン 51

Slide 52

Slide 52 text

コンテキストが存在することを意識しよう 52

Slide 53

Slide 53 text

プログラミングでも便利 53

Slide 54

Slide 54 text

UserContext 54

Slide 55

Slide 55 text

HttpContext 55

Slide 56

Slide 56 text

コンテキストを恐れないで 56

Slide 57

Slide 57 text

57 重要なのはどのコンテキストなのかを意識すること

Slide 58

Slide 58 text

58 多様性を受け入れよう

Slide 59

Slide 59 text

多様性を恐れないための心構え 59

Slide 60

Slide 60 text

60

Slide 61

Slide 61 text

61

Slide 62

Slide 62 text

62

Slide 63

Slide 63 text

あなたの考えを あなたのコンテキストで 63

Slide 64

Slide 64 text

64

Slide 65

Slide 65 text

65

Slide 66

Slide 66 text

Object Oriented Diversity Masanobu Naruse

Slide 67

Slide 67 text

Auther Masanobu Naruse HomePage https://nrslib.com Twitter @nrslib