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
huwamoko6210
June 29, 2019
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
コードをきれいに書く基本のキ
コードをきれいに書く上で最低限覚えておいた方がいいことまとめ。
huwamoko6210
June 29, 2019
Transcript
17 slides
新卒一年目の コードをきれいに書く基本のキ 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() { //スコアを出力する } 関数の役割を独立させる
•関数に役割を持たせ、独立させる ー分割したものを関数にして、役割を持たせる ー目的に従ってコードを分割する。 ーそれぞれ依存せず、独立した関数やクラスにすること
参 考 ・ 出 典
ご清聴ありがとうございました!
Other Decks in Programming
See All in Programming
Performance Optimization With LLMs
xleitix
0
260
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
860
PyConTW 2026 - AI Coding 不只是工具升級, 區域醫院醫療資訊系統協作開發與資訊團隊轉型實踐
cclai999
0
250
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
140
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
190
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
350
Seven New Principles of Software Engineering
yegor256
0
490
GraphQL の onError と Nullability のこれから
quramy
0
220
AI Augmentation Techniques with Liberty
ivargrimstad
1
470
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
130
例外からRich Errorsまで Kotlinエラーハンドリングの進化を読み解く
shiita0903
0
130
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
140
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.2k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
980
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
610
Product Roadmaps are Hard
iamctodd
55
13k
Test your architecture with Archunit
thirion
2
2.5k
The Invisible Side of Design
smashingmag
301
52k
How to Talk to Developers About Accessibility
jct
2
620
Bash Introduction
62gerente
615
220k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
770
Building a Scalable Design System with Sketch
lauravandoore
464
34k