Skip to main content
added 361 characters in body
Source Link
Ian
  • 4.6k
  • 20
  • 28

It is OK to rename built in functions provided the new names makes your code a lot clear and will not be miss understood by anyone. (If you are using C/C++ do not use a #define as it makes it hard to see what is going on.) The name of a function should act like a comment explaining what the calling code is doing and why it is doing to.

You are not the only person that has had this problem with min and max, however I yet to see a good general solution that works across all domains. I think one problem with naming of these functions is that the two arguments have different different logical meanings, but are presented as meaning the same.

If your language allows it you could try

return  calculatedDiscount.ButNoMoreThen(maxAllowedDiscount)

return  CDsInStocked.ButNoMoreThen(CasesInStock)

You are not the only person that has had this problem, however I yet to see a good general solution that works across all domains. I think one problem with naming of these functions is that the two arguments have different logical meanings, but are presented as meaning the same.

If your language allows it you could try

return  calculatedDiscount.ButNoMoreThen(maxAllowedDiscount)

return  CDsInStocked.ButNoMoreThen(CasesInStock)

It is OK to rename built in functions provided the new names makes your code a lot clear and will not be miss understood by anyone. (If you are using C/C++ do not use a #define as it makes it hard to see what is going on.) The name of a function should act like a comment explaining what the calling code is doing and why it is doing to.

You are not the only person that has had this problem with min and max, however I yet to see a good general solution that works across all domains. I think one problem with naming of these functions is that the two arguments have different logical meanings, but are presented as meaning the same.

If your language allows it you could try

return  calculatedDiscount.ButNoMoreThen(maxAllowedDiscount)

return  CDsInStocked.ButNoMoreThen(CasesInStock)
Source Link
Ian
  • 4.6k
  • 20
  • 28

You are not the only person that has had this problem, however I yet to see a good general solution that works across all domains. I think one problem with naming of these functions is that the two arguments have different logical meanings, but are presented as meaning the same.

If your language allows it you could try

return  calculatedDiscount.ButNoMoreThen(maxAllowedDiscount)

return  CDsInStocked.ButNoMoreThen(CasesInStock)