2 ms·
I've consumed enough CSV data to be wary of CSV data that was generated in ten minutes - including the unit tests. Are you sure you already have the data 'in th
by jameshart 11y ago
I've consumed enough CSV data to be wary of CSV data that was generated in ten minutes - including the unit tests. Are you sure you already have the data 'in the right format', for example? Maybe the data that's presented on the page has already been formatted for localization, so when you use that in your CSV export you put out dates in US or european format depending on the user's preferences, creating some hard-to track-down integration bugs later. Or maybe it only includes the display name for the status code, not the status code itself, so when three months later you change the display code from 'cancelled' to 'removed', all your clients' Excel macros break.
And once you've done that ten minute job on this page, how long will it take you to add it to the other 25 pages which also have tables of data that need CSV export? And when the table format changes to add another column, does the next developer also have to adjust your CSV output code?
Sure, YAGNI, but... there's no excuse to just throw a bunch of CSV-export logic inline into a page that previously had shown no interest in knowing how to format CSV files. Take a little longer, think about where to put the logic. There's a middle ground here.