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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -