Extending Functions
Sometimes, you have a function already programmed, and then you need a more refined function, that takes even more parameters. Refactoring? A pain in the ass. Thank god I finally learned how to circumvent that pain:
Make a new, more refined function:
function moreComplexFunction(parameter1, parameter2, parameter3) { //execute stuff }
Then replace the original code in the simple function, replacing the superfluous parameters with standard values:
function simpleFunction(parameter1, parameter2) { return moreComplexFunction(parameter1,parameter2,"standardValue"); }
I could hit myself for not figuring that out earlier ...
Sometimes, you have a function already programmed, and then you need a more refined function, that takes even more parameters. Refactoring? A pain in the ass. Thank god I finally learned how to circumvent that pain:Make a new, more refined function:function moreComplexFunction(parameter1, parameter2, parameter3) { //execute stuff}Then replace the original code in the simple function, replacing the superfluous parameters with standard values:function simpleFunction(parameter1, parameter2) { return moreComplexFunction(parameter1,parameter2,"standardValue");}I could hit myself for not figuring that out earlier ...




Post new comment