LoginSignup
1
3

More than 3 years have passed since last update.

はじめてのコード整理チェックリスト

Last updated at Posted at 2020-11-25

はじめに

コードレビューをもらう前などにチェックしているリストです。
誰でもできます。
気づいたことがあれば更新する予定です。

超基礎編

・ selfを付ける

・空行、空白が統一されているか

・メソッド名や変数名がキャメルケースになっているか

// NG例
func appendname() {
    let Name = "なまえ"
}

// OK例
func appendName() {
    let name = "なまえ"
}

・不要な変数、処理、コメントがないか

  • 定義したけど使わなかった変数
  • 実は処理が通っていないメソッド
  • メモ程度で書いていたコメントなど...

基礎編

・マークコメントを付ける

例)
  //MARK: - Action       //ここからはActionの処理を実装しますという意味

    @IBAction func numButton(_ sender: UIButton) {
        guard let num = numLabel.text else {
            return
        }
        guard let senderdNum = sender.titleLabel?.text else {
            return
        }
        numLabel.text = num + senderdNum
    }
マークコメントを付けると、選択したマークコメントに飛べます
MARC.gif

・ドックコメントを付ける

    /// ボタンを押下した時の処理       //メソッドなどの処理説明を書く
    /// - Parameter sender: UIButton     
    @IBAction func numButton(_ sender: UIButton) {

        guard let num = numLabel.text else {
            return
        }
        guard let senderdNum = sender.titleLabel?.text else {
            return
        }
        numLabel.text = num + senderdNum
    }

ショートカットキー

ドッグコメント
command⌘ + option + /

・アクセス修飾子を付ける

知っているようで知らないSwift5のアクセス修飾子

・メソッドの命名をわかりやすくする(どんな処理をしているのか)

うまくメソッド名を付けるための参考情報

参考

知っているようで知らないSwift5のアクセス修飾子
うまくメソッド名を付けるための参考情報

1
3
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
1
3