狠狠撸

狠狠撸Share a Scribd company logo
オブジェクト指向
こころ編
かわばたれもん エンジニア
(2015:新卒入社)
@Kawabata_Lemon LemonKawabata
オブジェクト指向の用語
カプセル化
継承 委譲
インターフェイス
クラス
インスタンス
ポリモーフィズム
メソッド
あああああああああ!!!!
言葉が多すぎる!!
しかし、オブジェクト指向こそが
プログラムに魔法のような力を与える
秘密なのです
オブジェクト指向を理解する軸
それは………
責任の所在
つまり谁が何をすべきかということ
たとえば
次の授業に向かってください
はい はい
次の授業
英語
次の授業
数学
教授が受講している学生に対して次の授業へ向かうように言う時
次の授業に向かってください
はい はい
英語の教室へ向かう 数学の教室へ向かう
教授は次の授業が何かを知らない。
学生は自分の次の授業を知っている
言い換えれば、自分は何を知って
いて何をするべきかわかっている
オブジェクト指向とはそういうもの
その視点でオブジェクト指向
の単語を振り返ってみる
学生も教授も自分たちのやるべきことや知っておくべきことは
知っている。
自分たちの知っておくべきこと
自分たちのやるべきこと =メソッド
=メンバ変数
責任を負っている単位のこと =クラス
責任を負っている単位の実体 =インスタンス
次の授業へ行く
(数学の授業へ向かう)
学生諸君、
次の授業へ向かいなさい
(教授は次の授業のことは知らないし知らなくていいこと)
次の授業へ行く
(英語の授業へ向かう)
中身の処理を外から見えなくさせること =カプセル化
学生だからそう言えるのであって
高校生なのか大学生なのか知らなくていい。
共通の属性(学生)ならできることを示した表 =インターフェイス
学生
(けど実は大学生)
学生
(実は高校生)
属性ややるべきことを身につけるために引き継ぐこと
学生(やるべきこと:次の授業へ行く)
大学生(数学の講堂へ行く) 高校生(英語の教室へ行く)
=継承
彼らは学生インターフェイスを「継承」していると言う。
学生インターフェイスにはやるべきことの「中身」がなくてそれを持っている人が決
める。やるべきことの中身を相手に「委譲」していると言う
引き継ぎ先に内容をお任せすること =委譲
同じことを言ってもそれぞれがことなる挙動をとれたりできること
学生
大学生 大学生
=ポリモーフィズム(多態性)
そのおかげで同じ「次の授業へいきなさい」と言うだけで二人とも全然違う行動を
とれる
结局、オブジェクト指向ってなんだった?
プログラムの世界が
処理のやりとりのレベルから
意図のやりとりのレベルへ
パラダイムシフトしたことだった。
オブジェクト指向型言语とはなんだ?
意図のやりとりのレベルでのプログラムを
作る仕組みが
(インターフェイスとかカプセル化とか色々)
言語そのものに
もともと備わっている言語のこと。
ほかにも…
オーバーライドとかオーバーロードとかいろいろ
オブジェクト指向の単語はあるが
やるべきこと、知るべきこと、責任などの
視点で確認していけばそんななに怖くない!
はず!
Ad

More Related Content

Viewers also liked (18)

El Cabildo maltrata a LPGC en el reparto del Fondo de Desarrollo de CanariasEl Cabildo maltrata a LPGC en el reparto del Fondo de Desarrollo de Canarias
El Cabildo maltrata a LPGC en el reparto del Fondo de Desarrollo de Canarias
Agustín Díaz Lorenzo
?
Freedom of Speech & Freedom of Education in Spain Today
Freedom of Speech & Freedom of Education in Spain TodayFreedom of Speech & Freedom of Education in Spain Today
Freedom of Speech & Freedom of Education in Spain Today
Ignacio Arsuaga
?
How to Take Charge of Your Career and Be Successful
How to Take Charge of Your Career and Be SuccessfulHow to Take Charge of Your Career and Be Successful
How to Take Charge of Your Career and Be Successful
Anna Lundberg
?
Nuorten sosiaalisen viestinn?n muutos - Juha Kiviniemi - Verke - 28.3.2017 - ...
Nuorten sosiaalisen viestinn?n muutos - Juha Kiviniemi - Verke - 28.3.2017 - ...Nuorten sosiaalisen viestinn?n muutos - Juha Kiviniemi - Verke - 28.3.2017 - ...
Nuorten sosiaalisen viestinn?n muutos - Juha Kiviniemi - Verke - 28.3.2017 - ...
Verke
?
?????? ??? ???? ??????? ? ?????? ??? ???? ??????
?????? ??? ???? ??????? ? ?????? ??? ???? ???????????? ??? ???? ??????? ? ?????? ??? ???? ??????
?????? ??? ???? ??????? ? ?????? ??? ???? ??????
Ashraf Osman
?
Manejo de la preeclampsia y vómitos en el embarazoManejo de la preeclampsia y vómitos en el embarazo
Manejo de la preeclampsia y vómitos en el embarazo
Farmacia Hospital Universitario Poniente
?
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
CINEC Campus
?
Instinto, sexo y sexualidadInstinto, sexo y sexualidad
Instinto, sexo y sexualidad
Jesus Villasmil
?
Effective Code Review
Effective Code ReviewEffective Code Review
Effective Code Review
Jane Prusakova
?
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
Harvard Web Working Group
?
Problematicas emergentesProblematicas emergentes
Problematicas emergentes
cursavirtual
?
Edudirectores - El desarrollo de la función directiva - 1? sesión presencialEdudirectores - El desarrollo de la función directiva - 1? sesión presencial
Edudirectores - El desarrollo de la función directiva - 1? sesión presencial
Juanfra ?lvarez Herrero
?
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Codemotion
?
成果を达成するためのテ?サ?インフ?ロセス
成果を达成するためのテ?サ?インフ?ロセス成果を达成するためのテ?サ?インフ?ロセス
成果を达成するためのテ?サ?インフ?ロセス
Yuudai Tachibana
?
Techniques & Tools for Training Strong Distributed Teams
Techniques & Tools for Training Strong Distributed TeamsTechniques & Tools for Training Strong Distributed Teams
Techniques & Tools for Training Strong Distributed Teams
Sococo
?
conservation and rewarding biodiversity conservation Trondheim 05-10-gupta-...
conservation and rewarding biodiversity conservation Trondheim   05-10-gupta-...conservation and rewarding biodiversity conservation Trondheim   05-10-gupta-...
conservation and rewarding biodiversity conservation Trondheim 05-10-gupta-...
Dr Anil Gupta
?
Gr?ce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Gr?ce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGr?ce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Gr?ce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Jérémy Derussé
?
Using Open Data to fuel LegalTech Innovation
Using Open Data to fuel LegalTech InnovationUsing Open Data to fuel LegalTech Innovation
Using Open Data to fuel LegalTech Innovation
Eric Rodriguez (Hiring in Lex)
?
El Cabildo maltrata a LPGC en el reparto del Fondo de Desarrollo de CanariasEl Cabildo maltrata a LPGC en el reparto del Fondo de Desarrollo de Canarias
El Cabildo maltrata a LPGC en el reparto del Fondo de Desarrollo de Canarias
Agustín Díaz Lorenzo
?
Freedom of Speech & Freedom of Education in Spain Today
Freedom of Speech & Freedom of Education in Spain TodayFreedom of Speech & Freedom of Education in Spain Today
Freedom of Speech & Freedom of Education in Spain Today
Ignacio Arsuaga
?
How to Take Charge of Your Career and Be Successful
How to Take Charge of Your Career and Be SuccessfulHow to Take Charge of Your Career and Be Successful
How to Take Charge of Your Career and Be Successful
Anna Lundberg
?
Nuorten sosiaalisen viestinn?n muutos - Juha Kiviniemi - Verke - 28.3.2017 - ...
Nuorten sosiaalisen viestinn?n muutos - Juha Kiviniemi - Verke - 28.3.2017 - ...Nuorten sosiaalisen viestinn?n muutos - Juha Kiviniemi - Verke - 28.3.2017 - ...
Nuorten sosiaalisen viestinn?n muutos - Juha Kiviniemi - Verke - 28.3.2017 - ...
Verke
?
?????? ??? ???? ??????? ? ?????? ??? ???? ??????
?????? ??? ???? ??????? ? ?????? ??? ???? ???????????? ??? ???? ??????? ? ?????? ??? ???? ??????
?????? ??? ???? ??????? ? ?????? ??? ???? ??????
Ashraf Osman
?
Manejo de la preeclampsia y vómitos en el embarazoManejo de la preeclampsia y vómitos en el embarazo
Manejo de la preeclampsia y vómitos en el embarazo
Farmacia Hospital Universitario Poniente
?
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
Innovations, Challenges, and Opportunities to Develop Regional Cooperation fo...
CINEC Campus
?
Instinto, sexo y sexualidadInstinto, sexo y sexualidad
Instinto, sexo y sexualidad
Jesus Villasmil
?
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
5 Steps to (Remote) Team Bliss: How to Build Thriving, High-Performing (Remot...
Harvard Web Working Group
?
Problematicas emergentesProblematicas emergentes
Problematicas emergentes
cursavirtual
?
Edudirectores - El desarrollo de la función directiva - 1? sesión presencialEdudirectores - El desarrollo de la función directiva - 1? sesión presencial
Edudirectores - El desarrollo de la función directiva - 1? sesión presencial
Juanfra ?lvarez Herrero
?
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Distributed System explained (with NodeJS) - Bruno Bossola - Codemotion Milan...
Codemotion
?
成果を达成するためのテ?サ?インフ?ロセス
成果を达成するためのテ?サ?インフ?ロセス成果を达成するためのテ?サ?インフ?ロセス
成果を达成するためのテ?サ?インフ?ロセス
Yuudai Tachibana
?
Techniques & Tools for Training Strong Distributed Teams
Techniques & Tools for Training Strong Distributed TeamsTechniques & Tools for Training Strong Distributed Teams
Techniques & Tools for Training Strong Distributed Teams
Sococo
?
conservation and rewarding biodiversity conservation Trondheim 05-10-gupta-...
conservation and rewarding biodiversity conservation Trondheim   05-10-gupta-...conservation and rewarding biodiversity conservation Trondheim   05-10-gupta-...
conservation and rewarding biodiversity conservation Trondheim 05-10-gupta-...
Dr Anil Gupta
?
Gr?ce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Gr?ce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGr?ce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Gr?ce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Jérémy Derussé
?

More from 和樹 川端 (9)

Nightmarejs
NightmarejsNightmarejs
Nightmarejs
和樹 川端
?
Cocos2d xて?ぬるぬる動くヒ?ルタ?ー機能実装
Cocos2d xて?ぬるぬる動くヒ?ルタ?ー機能実装Cocos2d xて?ぬるぬる動くヒ?ルタ?ー機能実装
Cocos2d xて?ぬるぬる動くヒ?ルタ?ー機能実装
和樹 川端
?
叠谤补颈苍诲辞迟蝉をつくってわかったこと
叠谤补颈苍诲辞迟蝉をつくってわかったこと叠谤补颈苍诲辞迟蝉をつくってわかったこと
叠谤补颈苍诲辞迟蝉をつくってわかったこと
和樹 川端
?
Braindots-開発秘話- Cocos2d-x3.5 開発事例 -
Braindots-開発秘話- Cocos2d-x3.5 開発事例 -Braindots-開発秘話- Cocos2d-x3.5 開発事例 -
Braindots-開発秘話- Cocos2d-x3.5 開発事例 -
和樹 川端
?
Enchantjs
EnchantjsEnchantjs
Enchantjs
和樹 川端
?
肠辞肠辞蝉2诲虫ことはじめ(2.2.5)
肠辞肠辞蝉2诲虫ことはじめ(2.2.5)肠辞肠辞蝉2诲虫ことはじめ(2.2.5)
肠辞肠辞蝉2诲虫ことはじめ(2.2.5)
和樹 川端
?
Nodejs
NodejsNodejs
Nodejs
和樹 川端
?
Adinnolab
AdinnolabAdinnolab
Adinnolab
和樹 川端
?
Cocos2d xて?ぬるぬる動くヒ?ルタ?ー機能実装
Cocos2d xて?ぬるぬる動くヒ?ルタ?ー機能実装Cocos2d xて?ぬるぬる動くヒ?ルタ?ー機能実装
Cocos2d xて?ぬるぬる動くヒ?ルタ?ー機能実装
和樹 川端
?
叠谤补颈苍诲辞迟蝉をつくってわかったこと
叠谤补颈苍诲辞迟蝉をつくってわかったこと叠谤补颈苍诲辞迟蝉をつくってわかったこと
叠谤补颈苍诲辞迟蝉をつくってわかったこと
和樹 川端
?
Braindots-開発秘話- Cocos2d-x3.5 開発事例 -
Braindots-開発秘話- Cocos2d-x3.5 開発事例 -Braindots-開発秘話- Cocos2d-x3.5 開発事例 -
Braindots-開発秘話- Cocos2d-x3.5 開発事例 -
和樹 川端
?
肠辞肠辞蝉2诲虫ことはじめ(2.2.5)
肠辞肠辞蝉2诲虫ことはじめ(2.2.5)肠辞肠辞蝉2诲虫ことはじめ(2.2.5)
肠辞肠辞蝉2诲虫ことはじめ(2.2.5)
和樹 川端
?
Ad

オブジェクト指向