featured_image

  1. Overview of the Refactoring process
  2. Identify and Group your Access Modifiers
  3. Choose Wise Variable Names, Prefixes and Suffixes
  4. Sort each Access Modifier Groups Alphabetically
  5. **View All**


If you have ever worked on a large project (or you are currently), you may have experienced the Janitorial-syndrome, which is “Man, I wish there was a virtual Janitor that could clean this mess!” . To fight off this overwhelming feeling, why not take your own actions to help yourself and the other members of your development team?

Refactoring

This is the process of renaming members, such as, variables, accessors, instance and class methods. In layman’s terms, this is an effort to keep your (and others’) code clean, readable, intuitive and meaningful at first glance. They can also be renamed for practical reasons, such as prefixing all the similar variables that store related values or references of a specific feature (ex: a few getter-methods  to retrieve a list of certain grid types, such as tilesEmpty, tilesOccupied, tilesLocked, tilesNearCharacter).

For the sake of demonstrating the cleanup process in an interesting way, we will be using a portion of a Ship Class for an Asteroid kind of game!

Let’s say you started off with these variables:

public static var shots:Array;
private static const firingInterval:int;
public static const firingSpeed:int;
private var speed:int;
private var shotsfired:int;
private var angle:Number;
private var lives:int;
public var score:int;
private var weapon:Weapon;
public var upgrades:Array;

Yuck! Not very pretty! Let’s give this bit of code a good wash, shall we?

Continue to the next page…

  1. Overview of the Refactoring process
  2. Identify and Group your Access Modifiers
  3. Choose Wise Variable Names, Prefixes and Suffixes
  4. Sort each Access Modifier Groups Alphabetically
  5. **View All**