Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
コードをきれいに書く基本のキ
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
huwamoko6210
June 29, 2019
Programming
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
コードをきれいに書く基本のキ
コードをきれいに書く上で最低限覚えておいた方がいいことまとめ。
huwamoko6210
June 29, 2019
Other Decks in Programming
See All in Programming
市販E-Readerを乗っ取れ 〜Embedded Swiftで電子ペーパーガジェットを制御する〜
trickart
0
230
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
290
AgentCore CLI で進化した AWS での AI エージェントの作り方 : 必要な機能を必要な時に
icoxfog417
PRO
4
410
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
410
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.2k
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
370
Workers Cache を知る
syumai
0
320
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
810
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
5.7k
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
460
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
520
WebRTC映像をAirPlayに対応させる挑戦.pdf
monolithic_adam
0
330
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
930
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
How Software Deployment tools have changed in the past 20 years
geshan
2
34k
How to Think Like a Performance Engineer
csswizardry
28
2.8k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
200
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
560
A Tale of Four Properties
chriscoyier
163
24k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5k
Deep Space Network (abreviated)
tonyrice
0
350
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Test your architecture with Archunit
thirion
2
2.4k
Transcript
新卒一年目の コードをきれいに書く基本のキ 6/29 (若手)エンジニアもくもく会 vol.14 @CrowdWorks
学生時代 コードのきれいさなんて気にしたこともなかった
個人開発 お仕事 ・自分が読めればよし ・他の人も読む ・とりあえず動けばよし ・安全なコード 技術より先にきれいなコードが書けることが大前提!
コードをきれいに書く基本のキ 一貫性 可読性 型指定 役割
class hoge{ } class hoge { } 「正しさ」よりも一貫性を重視する
•一貫性のあるコードは正しいコードよりも重要。 ーチーム全員が一貫したスタイルを持つ ー変数名の書き方も同じ(ex.キャメルケース、スネークケース) ー基本的にはコード規約をまず守ろう! (PHPはPSR)
コードをきれいに書く基本のキ 一貫性 型指定 役割 可読性
time_str += (hour >= 12) ? "pm" : "am"; if(hour
>= 12){ time_str += "pm"; }else{ time_str += "am"; } 理解が早くできるコードはどっち?
•理解が早くできるコードを優先する。 ーネストが深くならないように注意する ーif/else文は直観的に理解しやすい(場合による) ー早く理解できるコードは良いコード
コードをきれいに書く基本のキ 一貫性 型指定 役割 可読性
function addScore($score, $totalScore) { return $totalScore + $score; } どこが間違ってるでしょうか?
型指定をしていない!!!!
型指定はきっちりと function addScore(int $score, int $totalScore): int { return $totalScore
+ $score; }
コードをきれいに書く基本のキ 一貫性 型指定 役割 可読性
function inputScore() { //スコアの入力を行う } function addScore() { //スコアを加算する }
function outputScore() { //スコアを出力する } 関数の役割を独立させる
•関数に役割を持たせ、独立させる ー分割したものを関数にして、役割を持たせる ー目的に従ってコードを分割する。 ーそれぞれ依存せず、独立した関数やクラスにすること
参 考 ・ 出 典
ご清聴ありがとうございました!