performance - Do I create a duplicate function with slightly different algorithm, or use a slower, more general function? -


i've been advocate of dry principle: in other words, write code once , once. have function filters out data "latest unique report". in algorithm, function assumes incoming data sorted, making efficient. however, function potentially has handle data not sorted. better practice: having 1 general solution slower, or having 2 different functions, 1 being more efficient?

edit: should make note while performance nice thing have, not critical application internal tool.

the way put it sounds make function sorts data, , puts filtering function.

so

function filterdata(object data) {     ... }  function sortandfilterdata(object data) {     // sorting     ...     // filtering     filterdata(data); } 

Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -