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
良いコードを書くためにやってみてること3つ.pdf
Search
Keisuke kiuchi
October 31, 2018
Programming
5
620
良いコードを書くためにやってみてること3つ.pdf
shibuya.apk#29
https://shibuya-apk.connpass.com/event/104424/
Keisuke kiuchi
October 31, 2018
Tweet
Share
More Decks by Keisuke kiuchi
See All by Keisuke kiuchi
巨大なプロダクトにおける技術負債と戦った成功と失敗の軌跡(途中経過)
kiuchikeisuke
0
1.4k
Navigationを見据えたリファクタリング -マルチモジュール化を添えて-
kiuchikeisuke
1
2.7k
ぼくのかんがえた最強のUsecaseの作り方~あるいはビジネスロジックとはなにかという1つの回答~
kiuchikeisuke
13
6.8k
NavigationのNavOptions周りを覗いてみよう
kiuchikeisuke
0
680
AndroidStudioのテンプレートを覗いてみよう
kiuchikeisuke
2
800
Kotlin版CleanArchitectureのテンプレート作ったら爆速開発になった話+α
kiuchikeisuke
21
8.5k
Other Decks in Programming
See All in Programming
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
110
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
6
1.3k
Beyond ORM
77web
7
920
MCP with Cloudflare Workers
yusukebe
2
220
命名をリントする
chiroruxx
1
410
testcontainers のススメ
sgash708
1
120
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
260
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
340
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
A Tale of Four Properties
chriscoyier
157
23k
Building Applications with DynamoDB
mza
91
6.1k
Site-Speed That Sticks
csswizardry
2
190
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
A designer walks into a library…
pauljervisheath
204
24k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Code Reviewing Like a Champion
maltzj
520
39k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Transcript
ྑ͍ίʔυΛॻͨ͘Ίʹ ͬͯΈͯΔ͜ͱͭ LJVDIJLFJTVLF 4IJCVZBBQL
ܒี w ৬ۀɿ:ͷ"OESPJEΤϯδχΞ݉ҭࣇύύ w झຯͰ࡞ͬͨϞϊɿʮΒ͘ͰΜ "QQ ʯɺ ʮ$MFBO"SDIJUFDUVSF5FNQMBUF'PS,PUMJO 044 ʯ
w Ϟοτʔɿ໌ͷࣗʹ༏͍͠ίʔυΛॻ͘ w 4/4 5XJUUFS!GFJ@LPNF (JUIVC!LJVDIJLFJTVLF 2JJUB!L@LFJTVLF
࠷ۙͷΞΫςΟϏςΟ
ࠓճͷൃද كʹΑ͋͘ΔΛ ׂͱΑ͋͘Δख๏Ͱղܾ͠Α͏ͥ ͱ͍͏γϯϓϧͳ
ΞδΣϯμ wҙຯͱ੍Λදݱ͠Α͏ wແΛදݱ͠Α͏ wϨϏϡʔ؍ΛγΣΞ͠Α͏
ҙຯͱ੍Λදݱ͠Α͏
ಥવͰ͕࣭͢Ͱ͢ WBMQIPOF/VN4USJOH ͱ͍͏มΛݟͨΒͲΜͳΛ ૾͠·͔͢ʁ
࣍ͷ࣭ WBMUFMFQIPOF/VN4USJOH ͳΒͲ͏͍͏Ͱ͠ΐ͏
None
ࣅͯΔ͚ͲผͷҙຯΛ࣋ͭม w QIPOF/VNl9999:::: w UFMFQIPOF/VNlUFM9999::::z ʮΒ͘ͰΜʯͷΞϓϦΑΓҰ෦վѱͯ͠ൈਮ
EBUBΫϥε JOJUؔͰ ҙຯͱ੍Λදݱ͠Α͏
UFMFQIPOF/VNCFSJT data class TelephoneNumber(val number: String) { init { if
(!number.startsWith(SCHEME)) { throw IllegalArgumentException(“error“) } else if (number.substring(SCHEME.length) .contains(Regex(“.*[^0-9#¥+¥*() -]+.*"))) { throw IllegalArgumentException(“error”) } } companion object { const val SCHEME = "tel:" } } 4$)&.&͔Β ࢝·ͬͯΔ͜ͱ ಛఆͷਖ਼نදݱΛ ຬͨ͢͜ͱ
QIPOF/VNCFSJT class PhoneNumber(val number: String) { init { if (number.startsWith(TelephoneNumber.SCHEME))
{ throw IllegalArgumentException(“error") } else if ((number.contains(Regex(".*[^0-9#¥+¥*() -]+.*")))) { throw IllegalArgumentException(“error") } } } 4$)&.&͔Β࢝·ͬͯ ͍ͳ͍͜ͱ ಛఆͷਖ਼نදݱΛ ຬͨ͢͜ͱ
ิJOMJOF$MBTT PSEBUB$MBTT w *OMJOFDMBTT ,PUMJOWFSd w JOJUϝιουΛ࣋ͯͳ͍ͷͰɺܕ੍ͷΈͰेͷ߹ ʹར༻ w
EBUBDMBTT w JOJUϝιουΛ࣋ͯΔͰɺܕ੍ ϩδΧϧͳ੍Λ ͍ͨͤͨ߹ʹར༻ ˞͋͘·Ͱݸਓͷߟ͑ํͰ͢
ແΛදݱ͠Α͏
࣍ͷ ͋Δ-JTU͔Β݅ʹ߹கͨ͠ ཁૉΛऔΓग़ؔ͢Λ࡞Γ͍ͨ
val contactList = List<Contact>() fun findSameNumberContact(phoneNumber: PhoneNumber):Contact? { return contactList.find
{ it.getPhoneNumber() == phoneNumber } } ۭͷ-JTU͚ͩͲΩχγφΠσ
͍͍Ͷʂ☺
val contactList = List<Contact>() fun findSameNumberContact(phoneNumber: PhoneNumber):Contact? { return contactList.find
{ it.getPhoneNumber() == phoneNumber } } Μʁ
/VMMBCMFͩ
ແΛදݱ͠Α͏
val contactList = List<Contact>() fun findSameNumberContact(phoneNumber: PhoneNumber):Contact { return contactList.find
{ it.phoneNumber == phoneNumber } ?: Contact.NONE } data class Contact(val displayName: String, val contactId: String, val phoneNumber: PhoneNumber) { companion object { val NONE = Contact("", "", PhoneNumber("")) } } dddddddddddddddddddddddddddddddddddddddddddddddddddd
/PO/VMMͰແΛදݱʂ ☺ ˞ͨͩ͠ɺ/VMMͷ··ʹͨ͠΄͏͕ྑ͍߹͋ΔͷͰ༻๏༻ྔΛक͍ͬͯ·͠ΐ͏
ิ/VMMBCMF PSແΛදݱ w ແΛදݱˠ/VMMʹͳΔ͜ͱ͕ਖ਼ৗܥͷൣғͷ߹ྫ֎ॲཧ͕ෆ ཁʹͳΔ߹ w ྫ&EJU5FYUʹϢʔβʔ͕ೖྗͨ͠ి൪߸ʹϚον͢Δి൪߸Λ pOEͰݟ͚ͭɺి൪߸Λදࣔ͢Δ ݟ͔ͭΒͳ͍ͳΒۭจࣈ
w /VMMͷ··ˠ/VMMʹͳΔ͜ͱ͕ຊདྷ͋Γ͑ͳ͍߹ w ྫిாҰཡͰνΣοΫΛೖΕͨ൪߸͚ͩΛpOEͰݟ͚ͭΔ ˞͋͘·Ͱݸਓͷߟ͑ํͰ͢
ϨϏϡʔ؍ΛγΣΞ͠Α͏
ɺ͋Δ13ΛϨϏϡʔ ͍ͯͨ࣌͠ͷ͜ͱ
ࢦఠͨ͠΄͏͕͍͍ Օॴ͕ଟ͗͢Δ
ࢦఠ͠ͳ͍Θ͚ʹ͍͔ͳ͍͕ɺ શ෦ࢦఠ͢Δͷ͠ΜͲ͍
ͳͷͰɺָΛͭͭ͠ νʔϜٕज़ྗͷ্ʹܨ͕Δํ๏ ΛͬͯΈͨ
ձٞࣨΛڌͯ͠ ϞϒϓϩతϨϏϡʔձΛ࣮ࢪ
ϞϒϓϩతϨϏϡʔ w ࢀՃऀɿ"OESPJE&OHਓɺJ04&OHਓ w ࡐɿྫͷ13 ,PUMJO w ͬͨ͜ͱɿ ࢦఠՕॴΛͲΜͲΜϗϫΠτϘʔυʹॻ͖ग़͢
Ͳ͏ͨ͠΄͏͕͍͍͔ɺΛٞ͢Δ ࢦఠΛө ͔͚ͨͬͨ͠Ͳ࣌ؒͷ߹্࣮ݱͤͣ
ϞϒϓϩతϨϏϡʔ ˞ࣾ֎ൿͳͷͰϞβΠΫॲཧͯ͠·͢
ͬͯΈͨײ৮ w վΊͯݟͯΈΔͱʮ͜ͷ࣮ԿΛҙਤͯ͠ΔΜͩ ʯͬͯͷ͕ ग़ͯ͘Δ w ࢦఠ͞ΕΕͨΓલͱࢥ͑Δͷ͕ଟ͍ w ม໊໊ؔͷ໋໊ͷେ͞Λ࠶ೝࣝͨ͠ w
,PUMJOʹ׳Εͯͳ͍ਓ͕ॻ͘ͱ7BS͕ଟ͘ͳΔ
ϨϏϡʔ؍ΛγΣΞͯ͠ɺ νʔϜΈΜͳ͕ཧղͰ͖Δ ࣮Λ৺͕͚Α͏
·ͱΊ wࣅͨҙຯΛ͚࣋ͭͲҟͳΔม ˠҙຯͱ੍Λදݱ͠Α͏ wOVMMBCMFΛແ͘͢ํ๏ ˠແΛදݱ͠Α͏ wνʔϜͷٕज़ྗ্݉Ͷͯۮʹ ϨϏϡʔ؍ΛγΣΞ͠Α͏
͓ΘΓͰͬ͢ʂ