Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
[作成途中]Unity設計勉強会 ポリモーフィズム編 / Unity Architecture...
Search
Ryo Yamamoto
September 05, 2019
Programming
0
47
[作成途中]Unity設計勉強会 ポリモーフィズム編 / Unity Architecture Polymophism
Ryo Yamamoto
September 05, 2019
Tweet
Share
More Decks by Ryo Yamamoto
See All by Ryo Yamamoto
Unity設計勉強会 単一責任原則編 / Unity Architecture SRP
ryo24
0
64
3 Education Topics For LightningTalk
ryo24
1
28
Presentationに流れを作ろう
ryo24
1
65
定期発表会スライドアドバイス
ryo24
0
51
ライトニングトークレベルアップ講座
ryo24
1
110
Other Decks in Programming
See All in Programming
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
2.4k
ユーザーも開発者も悩ませない TV アプリ開発 ~Compose の内部実装から学ぶフォーカス制御~
taked137
0
190
MCPとデザインシステムに立脚したデザインと実装の融合
yukukotani
4
1.4k
スケールする組織の実現に向けた インナーソース育成術 - ISGT2025
teamlab
PRO
1
130
プロポーザル駆動学習 / Proposal-Driven Learning
mackey0225
2
1.3k
Deep Dive into Kotlin Flow
jmatsu
1
360
Performance for Conversion! 分散トレーシングでボトルネックを 特定せよ
inetand
0
2.4k
AIコーディングAgentとの向き合い方
eycjur
0
280
Navigating Dependency Injection with Metro
zacsweers
3
2.5k
Design Foundational Data Engineering Observability
sucitw
3
200
AI Coding Agentのセキュリティリスク:PRの自己承認とメルカリの対策
s3h
0
230
より安全で効率的な Go コードへ: Protocol Buffers Opaque API の導入
shwatanap
2
360
Featured
See All Featured
Done Done
chrislema
185
16k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
Faster Mobile Websites
deanohume
309
31k
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
Facilitating Awesome Meetings
lara
55
6.5k
How to Ace a Technical Interview
jacobian
279
23k
Optimizing for Happiness
mojombo
379
70k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.8k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Side Projects
sachag
455
43k
Being A Developer After 40
akosma
90
590k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.7k
Transcript
Date : 09/05 Time : 15:00~ Place: LiT! Osaka S.O.L.I.D
Object Oriented Design Thurs 09/05
None
ಜεΫϦϓτ Ͱͷศརͳૢ࡞ ํ๏
1PMZNPQIJTN Λ͍͜ͳ͢ʂ
S.O.L.I.D.
40-*%ݪଇ ɾ4ɿ୯Ұͷݪଇ ɾ0ɿ։์ดͷݪଇ ɾ-ɿϦείϑͷஔݪଇ ɾ*ɿΠϯλʔϑΣΠεͷݪଇ ɾ%ɿґଘੑٯసͷݪଇ
جఈΫϥεੜΫϥεͱ ަՄೳͰͳ͚ΕͳΒͳ͍ ݪଇ Ϧείϑͷஔ๏ଇ
ʁʁʁʁ
ΦϒδΣΫτ ࢦ
ؔͱมΛ ·ͱΊΔ
ܧঝͱҕৡ Ϋϥε Πϯλʔ ϑΣΠε
None
ɾΧϓηϧԽ ɹ֎෦Ϋϥε͔Β࣮ΛӅṭ͢Δ ɹˠ$ϓϩύςΟ͕ศར ɾϙϦϞʔϑΟζϜ ɹಉ໋͡ྩͰҟͳΔΦϒδΣΫτ ɹΛૢ࡞͢Δ 001ͷେཁૉ
ΧϓηϧԽ
Class Human{ public string name; public int age; } Class
Game{ Human alex = new Human(); alex.name = “Alex”; alex.age = 22; } Human bob = new Human(); alex.name = “Bob”; alex.age = -20;
ਓؒؒҧ͑Δ ͜ͱ͋Δ
BHFΛ֎͔Β ݟ͑ͳ͍Α͏ ʹ͢Δ
Class Human{ private string name; private int age; public int
GetAge(){ return age; } public void SetAge(int input){ if(input > 0){ age = input; }else{ age = 99; } }
ϑΟʔϧυQSJWBUF ϝιουQVCMJD
(FUUFS 4FUUFS
Class Human{ //লུ } Class Game{ Human alex = new
Human(); alex.SetName(“Alex”); alex.SetAge(22); Debug.Log(“Alex age: ” + alex.getAge()); }
ຖճ࡞Δͷ ͩΔ͘ͳ͍ʁ
ຖճϝιουͳͷ ͩΔ͘ͳ͍ʁ
ͦͦ ྸϑΟʔϧυ ͱͯ͠ར༻͍ͨ͠
$ ศརͳΜͰ͢
ͦΜͳػೳ͕ ͋Γ·͢
֎෦͔Βʮมʯʹݟ͑ͯ ෦͔Βʮؔʯʹݟ͑Δ ϓϩύςΟ $ͱͯ͠ͷػೳ
Class Human{ private string name; private int age; public int
GetAge(){ return age; } public void SetAge(int input){ if(input > 0){ age = input; }else{ age = 99; } }
Class Human{ private int _age; public string Name{get; set;}; public
int Age{ get{ return _age; } set{ _age = value > 0 ? value : 99; } } }
Class Human{ //লུ } Class Game{ Human alex = new
Human(); alex.SetName(“Alex”); alex.SetAge(22); Debug.Log(“Alex age: ” + alex.getAge()); }
Class Human{ //লུ } Class Game{ Human alex = new
Human(); alex.Name = “Alex”; alex.Age = 22; Debug.Log(“Alex age: ” + alex.Age); }
͖ͬ͢Γ
(BNFΫϥε "HFͷ࣮Λ ؾʹ͠ͳ͍͍ͯ͘
ΧϓηϧԽ
ϙϦϞʔ ϑΟζϜ
)VNBOΛϕʔε ʹϝϯλʔͱϝϯ όʔΛ࡞Ζ͏
)VNBOΫϥεΛ ܧঝͨ͠ϝϯλʔ Ϋϥεͱϝϯόʔ ΫϥεΛ࡞Ζ͏
Class Human{ //লུ public string Name{get; set;}; public int Age{get;
set;}; } Class Mentor: Human{ public string Area{get; set;}; public int LdCourse{get; set;}; } Class Member: Human{ public string UsingServce{get; set} public int Course{get; set;}; }
Class Game{ Human alex = new Human(); alex.Name = “Alex”;
alex.Age = 22; Mentor candy = new Mentor(); candy.Name = “Candy”; candy.Age = 22; candy.Area = “Kansai”; candy.LdCource = 3; //Unityͷ͜ͱ }
ϝϯόʔ͋Δ͋Δ ࣈͰछྨΛද͢
FOVN ͑ΔΑʁ
ಛఆͷछྨΛ·ͱΊͯදݱ ࣈʹҙຯΛͨͤΔ͜ͱ્ࢭ จࣈྻͷଧͪؒҧ્͑ࢭ FOVNྻڍܕ ࣮ଶJOUσʔλ
public enum litCourse{ iPhone, Android, Unity, WebDesign, WebService } Class
Mentor: Human{ private litCourse _course; public litCourse LdCourse{get; set;} }
Class Game{ Human alex = new Human(); alex.Name = “Alex”;
alex.Age = 22; Mentor candy = new Mentor(); candy.Name = “Candy”; candy.Age = 22; candy.Area = “Kansai”; candy.LdCource = litCourse.Unity; }
͔͜͜Βຊ
͜͜Ͱ ྫʹઓʂ
ʂ ɾγϡʔςΟϯάήʔϜΛ࡞Ζ͏ʂ ʻબϘλϯʼ ɾఢछྨ ɾยํͰ྆ํಉ࣌Ͱબ0, ɾબ࣌ͦͷݩૉͷબ͕ ɹ͔ΔΑ͏ʹ͢Δ ɹʢςΩετ͕ଟҰ൪ૣ͍ͱࢥ͍·͢ʣ ʻܾఆϘλϯʼ ɾςΩετʹબΕͨݩૉΛදࣔ͢Δ
ϝϯλʔ ϝϯόʔ ʹಉ࣌ʹ ͓ئ͍͍ͨ͠
Class Human{ //লུ public string Name{get; set;}; public int Age{get;
set;}; public int Enegy{get; set;}; //Eat Something public void Eat(){ } }
Class Mentor: Human{ public void Eat(){ food.EatRedbull(); Enegy += 20;
} } Class Member: Human{ public void Eat(){ food.EatHumburger(); Enegy += 8; } }
Class Game{ Human alex = new Human(); Mentor candy =
new Mentor(); Member drake = new Member(); alex.Eat(); drake.Eat(); }
૿͑ͨΒ Ͳ͏͢Δͷʁʁ
Class Game{ Human alex = new Human(); Mentor candy =
new Mentor(); Member drake = new Member(); Mentor elisa = new Mentor(); alex.Eat(); drake.Eat(); elisa.Eat(); }
-JTU5ͱ GPSFBDI ͍͍ͨʂ
Class Game{ Human alex = new Human(); Mentor candy =
new Mentor(); Member drake = new Member(); Mentor elisa = new Mentor(); List<Mentor> mentorList = new List<Mentor>; mentorList.add(drake); }
ϝϯόʔͱϝϯλʔΛ ಉ࣌ʹѻ͍͍ͨ
ࢠΫϥεͷมʢΠϯελϯεʣ ΫϥεͷܕʹೖՄೳ ϙϦϞʔϑΟζϜͷϙΠϯτ ܕΛ߹ΘͤΒΕΔ
ϙϦϞʔϑΟζϜͷϙΠϯτ ਓؒ ϝϯλʔ ϝϯόʔ খΫϥεඞͣΫϥεͷଐੑΛ͍࣋ͬͯΔͨΊ
Class Game{ Human alex = new Human(); Human candy =
new Mentor(); Human drake = new Member(); Human elisa = new Mentor(); List<Human> mentorList = new List<Human>; mentorList.add(drake); }
Class Game{ //alex͔Βelisa·ͰΛ࡞ͬͨ List<Human> mentorList = new List<Human>; mentorList.add(alex); //ਓؒ
mentorList.add(bob); mentorList.add(candy); //ϝϯλʔ mentorList.add(drake); //ϝϯόʔ }
Class Human{ //লུ public string Name{get; set;}; public int Age{get;
set;}; public int Enegy{get; set;}; //Eat Something public virtual void Eat(){ } }
abstract Class Human{ //লུ public string Name{get; set;}; public int
Age{get; set;}; public int Enegy{get; set;}; //Eat Something public abstract void Eat(); }
Class Mentor: Human{ public override void Eat(){ food.EatRedbull(); Enegy +=
20; } } Class Member: Human{ public override void Eat(){ food.EatHumburger(); Enegy += 8; } }
՝
࣭
ײ