Is there a well-known name for this?
Nov. 8th, 2015 09:38 pmFrom time to time I and colleagues find ourselves extending some function in C in a way that requires extra arguments. Often this happens in a context where it's impractical to change all the callers (for instance, because some of them are in customer code) so the extended version of the function gets a new name and the original name just calls that with some default value of the new arguments.
For instance I might go from this:
int refine_glorp(glorp *g) {
/* refinement */
}
…to this:
int refine_glorp(glorp *g) {
return refine_glorp_ex(g, 0);
}
int refine_glorp_ex(glorp *g, int arg) {
/* extended refinement, based on arg */
}
Is there a well-known name for this transformation?
A colleague who did this a week or so ago started out with 'decapitation' but changed his mind to 'recapitation' on the grounds that he was really adding a second head to the function rather than removing one. But neither of us knew if there was already a name for this.
(no subject)
Date: 2015-11-09 08:30 am (UTC)(And I'm not aware of its name in C++ either)
(no subject)
Date: 2015-11-09 07:16 pm (UTC)(no subject)
Date: 2015-11-09 08:15 pm (UTC)(no subject)
Date: 2015-11-09 08:58 am (UTC)(no subject)
Date: 2015-11-09 09:11 am (UTC)(no subject)
Date: 2015-11-09 06:43 pm (UTC)(no subject)
Date: 2015-11-09 08:13 pm (UTC)(no subject)
Date: 2015-11-09 08:13 pm (UTC)(no subject)
Date: 2015-11-09 08:21 pm (UTC)Language makes sense, right?
(no subject)
Date: 2015-11-09 08:28 pm (UTC)(OED thinks application is ap- from ad- + p rather than the apo- version, but why would anyone let that get in the way?)
(no subject)
Date: 2015-11-09 11:02 pm (UTC)(Yes, I know that Curry was a person's name.)
(no subject)
Date: 2015-11-10 08:16 am (UTC)(no subject)
Date: 2015-11-10 08:16 am (UTC)(no subject)
Date: 2015-11-26 11:22 pm (UTC)refine_glorp_ex_ex. Better to design the new function so that it is more future-proof, for example instead of taking anintas the second argument, it could take an array of options.(no subject)
Date: 2015-11-27 09:15 am (UTC)intargument and the old one becomes a wrapper", I'm looking for a name for "new function with an extra argument and the old one becomes a wrapper".Indeed most of the examples in our code use an indefinitely extensible approach.
(no subject)
Date: 2015-11-27 11:52 am (UTC)The Windows API suffers from this anti-pattern: a typical example is
VirtualAllocExNuma(https://msdn.microsoft.com/en-us/library/windows/desktop/aa366891.aspx), which adds a node argument toVirtualAllocEx(https://msdn.microsoft.com/en-us/library/windows/desktop/aa366890.aspx), which adds a process argument toVirtualAlloc(https://msdn.microsoft.com/en-us/library/windows/desktop/aa366887.aspx). You'd think that when they came to extend it a second time they would have recognized the anti-pattern.(no subject)
Date: 2015-11-27 12:36 pm (UTC)