Article 2WBJ7 CodeSOD: Changing Requirements

CodeSOD: Changing Requirements

by
Remy Porter
from The Daily WTF on (#2WBJ7)

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;}
otter-icon.png [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! TheDailyWtf?d=yIl2AUoC8zABw7H74-4G-E
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments