Code revisiting and housekeeping

Its a great success for every programmer once a project or an assignment has been completed. But give it a day, a week or even a month and the good old code in place is now stale.

Its every programmer's duty to revisit their codes once in awhile and reassess if the old codes are still pretty much the best codes to be inplace or if there's something new that could do something better, faster and easier with much less effort than before. Guess that's part of of every code/project's technical debt.

This old code could really say a lot:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  def languages_s
    tmp_array = self.languages
    txt_array = Array.new

    for tmp in tmp_array
      txt_array << tmp.name.delete(" ")
    end

    if txt_array
      tmp_arr = txt_array.sort

      if tmp_arr
        return tmp_arr.join(" ")
      else
        return ''
      end
    else
      return ''
    end
  end

Could really be waiting to become something like this: (if only programmers weren't as lazy as they are)

1
2
3
  def languages
    (self.languages.blank?) ? '' : self.languages.collect{|x| x.name}.sort.join(" ")
  end

Personally, everytime I have a free time to spare, I take a breeze through old codes, and try to keep them in tougher shape. I do believe your code says a lot about yourself. So everytime you improve your skills, go improve on all possible evidence too! smile

Leave a Reply

Hi, I've been busy you know. wink If you don't know yet, this site and my blog codes are hosted in . I recently moved to Git and found that they have support for private Git repositories. Below are details of my last git push.

Maricris S. Nonato on 26 Mar
Commit: e734bd6878629223c5067326471d7ec0aac7d6e4

Updated display of ads and popular content