Help us understand the problem. What is going on with this article?


More than 5 years have passed since last update.

リーダブルコード ―より良いコードを書くためのシンプルで実践的なテクニックがとても良い感じなのでシェア。例えば以下のコードは配列から行列を作るコードだが、afterのようにfor文を回すときのi,jの名前をひと工夫すると、間違いが起きにくいコードに生まれ変わる。

  _putShuffleMatrix: ->
    a = []
    a = @_putShuffleArray()
    b = []
    for i in [0...@height]
      b[i] = []
      for j in [0...@width]
        b[i][j] = a[i * @width + j]
    return b
  putShuffleMatrix_: ->
    shuffleArray = []
    shuffleArray = @putShuffleArray_()
    shuffleMatrix = []
    for height_i in [0...@height]
      shuffleMatrix[height_i] = []
      for width_j in [0...@width]
        shuffleMatrix[height_i][width_j] =
        shuffleArray[(height_i * @width) + width_j]
    return shuffleMatrix

ブログやってます:PAPA-tronix !

今はHoloLensのアプリを開発しており、技術記事はすべてブログ( )に書いています。以前はSwift、OpenCV+Python、JavaScript、Objective-Cを書いていました。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away