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
今日から書けるリーダブルコード
Search
Daiki Nojiri
February 14, 2020
Programming
0
340
今日から書けるリーダブルコード
Daiki Nojiri
February 14, 2020
Tweet
Share
More Decks by Daiki Nojiri
See All by Daiki Nojiri
イメージで理解するgRPC
nojiri1098
0
260
GitのCLI操作を楽にするためにエイリアスを作った話
nojiri1098
0
230
Other Decks in Programming
See All in Programming
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
160
Recoilを剥がしている話
kirik
5
7.6k
iOS開発におけるCopilot For XcodeとCode Completion / copilot for xcode
fuyan777
1
680
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
360
PHPで作るWebSocketサーバー ~リアクティブなアプリケーションを知るために~ / WebSocket Server in PHP - To know reactive applications
seike460
PRO
2
690
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
250
20241217 競争力強化とビジネス価値創出への挑戦:モノタロウのシステムモダナイズ、開発組織の進化と今後の展望
monotaro
PRO
0
130
AWSのLambdaで PHPを動かす選択肢
rinchoku
2
330
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
990
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
370
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
470
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
340
Featured
See All Featured
Making Projects Easy
brettharned
116
6k
GitHub's CSS Performance
jonrohan
1031
460k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
Designing for humans not robots
tammielis
250
25k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
44
9.3k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.1k
A Modern Web Designer's Workflow
chriscoyier
693
190k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Transcript
Ϧʔμϒϧίʔυ ΑΓྑ͍ίʔυΛॻͨ͘Ίͷ࣮ફతͳςΫχοΫ
None
ࠓͷΰʔϧ ɾϦʔμϒϧίʔυͬͯͳʹʁ ɾͳΜͰϦʔμϒϧίʔυΛॻ͘ͷʁ ɾͲ͏ͬͯϦʔμϒϧίʔυΛॻ͘ͷʁ
Ϧʔμϒϧίʔυͬͯͳʹʁ
Ϧʔμϒϧίʔυ ˜ SFBEBCMFDPEF ˜ ಡΈ͍͢ίʔυ
ಡΈ͍͢ίʔυͬͯ ͲΜͳίʔυͩͱࢥ͍·͔͢ʁ
ݟ͕͍ͨͬͯΕಡΈ͍͢ʁ function isNull($array) { foreach($array as $v) { if (is_null($v))
{ return false; } } return true; } Πϯσϯτ͕͖Ε͍ͳίʔυ CSSͰ͍͍͔ function isNull($array) { foreach ($array as $v) { if (is_null($v)) { return false; } } return true; }
Ϧʔμϒϧίʔυͱ ଞͷਓ͕࠷࣌ؒͰ ཧղͰ͖Δίʔυ
Ϧʔμϒϧίʔυͱ ଞͷਓ͕࠷࣌ؒͰ ཧղͰ͖Δίʔυ
Ϧʔμϒϧίʔυͱ ଞͷਓ͕࠷࣌ؒͰ ཧղͰ͖Δίʔυ
͍͚Ͳɺ͙͢ʹཧղͰ͖ͳ͍ if (split(':', $line)[0] === 'root') { // }
͘ͳ͍͍͔ͬͯΒӅͯ͠͠·͏ if (split(':', $line)[0] === 'root') { // } $username
= split(':', $line)[0]; if ($username === 'root') { // } ˜
if (split(':', $line)[0] === 'root') { // } ˜ //
ίϩϯͷࠨଆΛநग़͢Δ $username = split(':', $line)[0]; if ($username === root) { // } ඞཁͳΒίϝϯτ
ͳΜͰϦʔμϒϧίʔυΛॻ͘ͷʁ
ͳΜͰಡΈ͍͢ίʔυΛ ॻ͍ͨ΄͏͕͍͍ͱࢥ͍·͔͢ʁ
Ϧʔμϒϧίʔυͱ ଞͷਓ͕࠷࣌ؒͰ ཧղͰ͖Δίʔυ
։ൃ͕εϜʔζʹਐΉ ಡΈ͍͢ίʔυͳΒʜ ɾղऍʹ໎Θͳ͍ɺޡղ͕ੜ·Εͳ͍ ɾಈ࡞ͷཧղ͕ૣ͘ͳΔ ɾҾ͖ܧָ͕͗ ɾಥવϓϩδΣΫτʹΞαΠϯ͞Εͯେৎ ಡΈʹ͍͘ίʔυͩͱʜ ɾೝ͕͍͕ࣝͪ͘͏ɺޡղ͕ੜ͡Δ ɾಡΈͨ͘ͳ͘ͳΔ ɾετϨεΛײ͡Δ
ɾͪΐͬͱͨ͠ػೳՃʹ͕͔͔࣌ؒΔ
։ൃ͕εϜʔζʹਐΉ ಡΈ͍͢ίʔυͳΒʜ ɾղऍʹ໎Θͳ͍ɺޡղ͕ੜ·Εͳ͍ ɾಈ࡞ͷཧղ͕ૣ͘ͳΔ ɾҾ͖ܧָ͕͗ ɾಥવϓϩδΣΫτʹΞαΠϯ͞Εͯେৎ ಡΈʹ͍͘ίʔυͩͱʜ ɾೝ͕͍͕ࣝͪ͘͏ɺޡղ͕ੜ͡Δ ɾಡΈͨ͘ͳ͘ͳΔ ɾετϨεΛײ͡Δ
ɾͪΐͬͱͨ͠ػೳՃʹ͕͔͔࣌ؒΔ ಡΈ͍͢ίʔυΛॻ͜͏ʂ
Ϧʔμϒϧίʔυͬͯ Ͳ͏ͬͯॻ͘ͷʁ
͜͜·Ͱͷ෮श ಡΈ͍͢ίʔυͬͯͳʹʁ ˠଞͷਓ͕࠷࣌ؒͰཧղͰ͖Δίʔυ ͳΜͰಡΈ͍͢ίʔυΛॻ͘ͷʁ ˠ։ൃ͕εϜʔζʹͳΔ͔Β ɹ։ൃָ͕ʹͳΔ͔Β
Ͱɺ۩ମతʹͲ͏ͬͯॻ͘ͷʁ
ૣ͘SFUVSO͢Δ ⁞ม໊ΛΧϥϑϧʹ͢Δ JGจΛׂ͢Δ ͙͢ʹਅࣅͰ͖ΔͭͷςΫχοΫ
⁞໊લΛΧϥϑϧʹ͢Δ
⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF ͳΜͰಉ͡ಈࢺʹ͕ͪ͠ ɾHFU'JMF ɾHFU+TPO ɾHFU)UNM ɾHFU%BUB ɾHFU1BHF ɾHFU6TFS/BNF ɾHFU1BSBNT
ɾHFU4FBSDI2VFSZ
͍ΖΜͳ୯ޠ͕͋Γ·͢ HFU ͍ۙͱ͜Ζ͔Βऔͬͯ͘Δ GFUDI ԕ͍ͱ͜Ζ͔Βऔͬͯ͘Δ NBLF ൺֱతখ͞ͳͷΛ࡞Δ ࡐྉΛՃ͢Δ CVJME ൺֱతେ͖ͳͷΛ࡞Δ
ΈཱͯΔ HFOFSBUF Կ͔Λมͯ͠࡞Γग़͢ DSFBUF Կͳ͍ͱ͜Ζʹ৽͘͠࡞Δ
⁞໊લΛΧϥϑϧʹ͢Δ BGUFS HFU)UNM QPTU ɹ%#ʹอଘ͞Ε͍ͯΔ)5.-Λऔͬͯ͘Δ GFUDI)UNM VSM ɹࢦఆͨ͠63-͔Β)5.-Λऔͬͯ͘Δ
HFOFSBUF)UNM UFNQMBUF ɹςϯϓϨʔτ͔Β)5.-Λੜ͢Δ CVJME)UNM QBSUT ɹ෦ΛΈ߹Θͤͯ)5.-Λੜ͢Δ
ૣ͘SFUVSO͢Δ
ૣ͘SFUVSO͢Δ CFGPSF if (auth(‘admin’)->check() || (auth()->check() && auth()->user()->isPurchased($item) ) )
{ if ($item->raw()—>exists()) { return Storage::download($item->raw); } } return redirect()->back(); ݖݶνΣοΫ ϑΝΠϧͷଘࡏ֬ೝ
ૣ͘SFUVSO͢Δ CFGPSF if (auth(‘admin’)->check() || (auth()->check() && auth()->user()->isPurchased($item) ) )
{ if ($item->raw()—>exists()) { return Storage::download($item->raw); } } return redirect()->back(); JGจ͕ωετ͍ͯ͠Δ
ૣ͘SFUVSO͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check()
|| (auth()->check() && auth()->user()->isPurchased($item) ) ) { return Storage::download($item->raw); } return redirect()->back();
ૣ͘SFUVSO͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check()
|| (auth()->check() && auth()->user()->isPurchased($item) ) ) { return Storage::download($item->raw); } return redirect()->back(); ϑΝΠϧͷଘࡏ֬ೝ ݖݶνΣοΫ ϑΝΠϧ͕ͳ͍࣌ͰSFUVSO͢Εɼ ݖݶνΣοΫͰϑΝΠϧͷ͜ͱΛؾʹ͠ͳ͍͍ͯ͘
JGจΛׂ͢Δ
JGจΛׂ͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check()
|| (auth()->check() && auth()->user()->isPurchased($item)) ) { return Storage::download($item->raw); } return redirect()->back(); BENJOͱVTFSΛҰʹνΣοΫ͠Α͏ͱ ͢Δ͔Βͪ͝Όͪ͝Όͯ͠͠·͏
JGจΛׂ͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check())
{ return Storage::download($item->raw); } if (auth()->check() && auth()->user()->isPurchased($item)) { return Storage::download($item->raw); } return redirect()->back(); BENJOͷݖݶνΣοΫ VTFSͷݖݶνΣοΫ
JGจΛׂ͢Δ BGUFS if ($item->raw()—>doesNotExists()) { return redirect()->back(); } if (auth(‘admin’)->check())
{ return Storage::download($item->raw); } if (auth()->check() && auth()->user()->isPurchased($item)) { return Storage::download($item->raw); } return redirect()->back(); ϑΝΠϧͷଘࡏ֬ೝ BENJOͷݖݶνΣοΫ VTFSͷݖݶνΣοΫ
ࠓͷ·ͱΊ ಡΈ͍͢ίʔυͬͯͳʹʁ ˠଞͷਓ͕࠷࣌ؒͰཧղͰ͖Δίʔυ ͳΜͰಡΈ͍͢ίʔυΛॻ͘ͷʁ ˠ։ൃ͕εϜʔζʹͳΔ͔Β Ͳ͏ͬͯಡΈ͍͢ίʔυΛॻ͘ͷʁ ˠ͍ΖΜͳςΫχοΫ͕͋ͬͯɺ ɹʰϦʔμϒϧίʔυʱͰͨ͘͞Μհ͞Εͯ ɹ͍Δ
͓·͚ ϘπҊ ͔ͤͬ͘ͳͷͰ͚ͱ͖·͢
⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF %#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO
֓ཁ DMJFOUTEFTDSJQUJPO උߟ
%#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO ֓ཁ DMJFOUTEFTDSJQUJPO
උߟ EFUBJMৄࡉɺEFTDSJQUJPOઆ໌ ⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF
%#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO ֓ཁ DMJFOUTEFTDSJQUJPO
උߟ ཧ໊͕ҧ͏ͷʹཧ໊ಉ͡ ⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF
%#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO ֓ཁ DMJFOUTEFTDSJQUJPO
උߟ ཧ໊͕ҧ͏ͷʹཧ໊ಉ͡ ⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF
%#ͷΧϥϜ໊Λྫʹ ཧ໊ ཧ໊ OFXTEFUBJM ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ TFSJFTEFTDSJQUJPO ֓ཁ DMJFOUTEFTDSJQUJPO
උߟ ύοͱݟ͚ͨͩͰΘ͔Βͳ͍ ⁞໊લΛΧϥϑϧʹ͢Δ CFGPSF
⁞໊લΛΧϥϑϧʹ͢Δ BGUFS ӳ୯ޠͷόϦΤʔγϣϯΛ૿ͯ͠ΈΔ ཧ໊ ཧ໊ OFXTCPEZ ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ ৄࡉ
BVUIPSTEFTDSJQUJPO ஶऀʹ͍ͭͯ આ໌ TFSJFTPWFSWJFX ֓ཁ DMJFOUTSFNBSL උߟ
ӳ୯ޠͷόϦΤʔγϣϯΛ૿ͯ͠ΈΔ ཧ໊ ཧ໊ OFXTCPEZ ͓Βͤ༰ BVUIPSTEFUBJM ஶऀʹ͍ͭͯ ৄࡉ BVUIPSTEFTDSJQUJPO ஶऀʹ͍ͭͯ
આ໌ TFSJFTPWFSWJFX ֓ཁ DMJFOUTSFNBSL උߟ ӳ୯ޠΛ͓ͬͯ͘ ඞཁ͕͋Δ͚Ͳɺ ཧ໊Λݟ͚ͨͩͰ Λ૾Ͱ͖Δ ⁞໊લΛΧϥϑϧʹ͢Δ BGUFS