0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

応用カリキュラム 03 読みやすいコードを書く

Last updated at Posted at 2019-11-19

良いコードの要素

  • 命名規則
  • コードのレイアウト
  • コメント

命名規則に関しては今までノータッチだったな・・・
他の開発者の期待に合わせる。。。ふむ。
英語の知識が必要。これは深くてまとめられんのでリンク。
モデルやメソッドに名前を付けるときは英語の品詞に気をつけよう

英語の勉強

  • set
  • add
  • render 変換、編集結果
  • import
  • fetch データベースから情報を取得
  • modify(edit) 部分修正
  • apply 適用する
  • remove データを取り除く。アクセス権のない場所へ移動。元に戻せない処理のみに限らない。
  • is

コードのレイアウト

  • 整列 スペースを使って「=」などの位置を揃えて可読性を上げる。
  • 一貫性 似たようなフォーマットは同じフォーマットでの表示をする
  • ブロック化 同じ系統の変数などをグループ化する

レイアウトは何とな〜くやってく感じでいっかな〜

リファクタリング

処理を変えずに、冗長なコードを削除したり、改善したりすること。

  • 読み手の理解がしやすくなる
  • 修正がしやすくなる

要素が非常に多い。なるべくコードを短くする。

参考

モデルやメソッドに名前を付けるときは英語の品詞に気をつけよう - Qiita
https://qiita.com/jnchito/items/459d58ba652bf4763820?utm_content=bufferf91b0&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?