CodeSOD: Changing Requirements


Requirements change all the time. A lot of the ideology and holy wars that happen in the Git processes camps arise from different ideas about how source control should be used to represent these changes. Which commit changed which line of code, and to what end? But what if your source control history is messy, unclear, or… you’re just not using source control?

For example, let’s say you’re our Anonymous submitter, and find the following block of code. Once upon a time, this block of code enforced some mildly complicated rules about what dates were valid to pick for a dashboard display.

Can you tell which line of code was in a reaction to a radically changed requirement?

function validateDashboardDateRanges (dashboard){
    return true; 
    if(dashboard.currentDateRange && dashboard.currentDateRange.absoluteEndDate && dashboard.currentDateRange.absoluteStartDate) {
        if(!isDateRangeCorrectLength(dashboard.currentDateRange.absoluteStartDate, dashboard.currentDateRange.absoluteEndDate)){
            return false;
        }
    }
    if(dashboard.containers){
        for(var c = 0; c < dashboard.containers.length; c++){
            var container = dashboard.containers[c];
            for(var i = 0; i < container.widgets.length; i++){
                if(container.widgets[i].settings){
                    if(container.widgets[i].settings.customDateRange){
                        if(container.widgets[i].settings.dateRange.relativeDate){
                            if (container.widgets[i].settings.dateRange.relativeDate === '-1y'){
                                return false;
                            }
                        } else if (!isDateRangeCorrectLength(container.widgets[i].settings.dateRange.absoluteStartDate, container.widgets[i].settings.dateRange.absoluteEndDate)){
                            return false;
                        }
                    }
                }
            }
        }
    }
    return true;
}
[Advertisement] Otter allows you to easily create and configure 1,000’s of servers, all while maintaining ease-of-use, and granular visibility down to a single server. Find out more and download today!

http://ift.tt/2uUmbMJ

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s