Friday, April 16, 2010

More real example about how to write clean code

DO NOT DO THIS !

    // Check to see if the employee is eligible for full benefits
    if ((employee.flags & HOURLY_FLAG) &&
          (employee.age > 65))

PREFER THIS WAY

    if (employee.isEligibleForFullBenefits())


Note: Yes yes....I am planning to combine all good samplings about writing clean code under a unique Header in My Blog.

No comments:

Post a Comment