May 2016 Blog Posts

Why do I hate this code?

During a recent code review, I gave feedback asking for code like the following to be refactored: function getPreferenceLevelText(companyName, companyPreferenceLevel, segmentType) { var preferenceLevel; if (companyPreferenceLevel == PREFERENCE_LEVEL_MOST_PREFERRED) { preferenceLevel = getLocalizedMessage("Most preferred"); } else if (companyPreferenceLevel == PREFERENCE_LEVEL_LESS_PREFERRED) { preferenceLevel = getLocalizedMessage("Less preferred"); } else if (companyPreferenceLevel == PREFERENCE_LEVEL_PREFERRED) { preferenceLevel = getLocalizedMessage("Preferred"); } else { return...

posted @ Sunday, May 1, 2016 11:02 PM | Feedback (5)