Tuesday, May 10th 2016
What is Generic Programming? Generic Programming is a style of writing code whereby code functions are written input type agnostic. That is, regardless of the type of input (array, obj, etc), the function is able to process that information all the same and return a predictable output. A perfect example of a function that was written with generic programming principles is the forEach function. forEach detect what the type of the input was (array/object based) and then iterates through the list accordingly.
Generic programming helps us abstract towards the purpose of the function. Rather than having to create several different functions (all with the same purpose but fit for different input types), we can abide by DRY by simply using one function.
References
http://www.generic-programming.org/
http://www.boost.org/community/generic_programming.html
http://stackoverflow.com/questions/3862378/what-is-the-meaning-of-generic-programming-in-c
No comments:
Post a Comment