Code refactoring means spring cleaning existing code. It usually implies changing the way the code is expressed without modifying what it does.

A refactor could improve code readability, reduce complexity, increase mainanability, etc.

A simple example could be improving the expressiveness of code by renaming variables. Silly example below:

# Original code
class Rm
  def initialize (n, a, v)
    @n = n.to_i
    @a = a
    @v = v
# Refactored code
class Room
  def initialize (no_of_windows, floor_area, volume)
    @no_of_windows = no_of_windows
    @floor_area = floor_area
    @volume = volume
end # aah, much better

Uncategorized LinksEdit