Jump to content

Why is an arbitrary high number not a good practice?


Montana50
 Share

Recommended Posts

Over the years I saw in some answers that the use of an arbitrary high number [like in calculations] could not be a good practice.

Why not? What could/should be the alternative?

While I see in several custom functions the use of it....

Any example of the use of an alternative would be welcome.

Link to comment
Share on other sites

A calculation is supposed to implement the logic prescribed by the business rules set for the application. When a calculation uses an arbitrary limit - i.e. a limit not prescribed by the business rules - then it fails to express correctly the required logic.

This has two potentially harmful effects:

  • the limit is arbitrary, therefore confusing to the person reading the code;
  • the limit can be exceeded in some unforeseen circumstances. 

In some cases a very high limit could also increase the time required to process the calculation.

 

3 hours ago, Montana50 said:

Any example of the use of an alternative would be welcome.

A classic example is:

MiddleValues ( listOfValues ; 2 ; 999999999999999 )

The intent here is to remove the first value from  listOfValues - which could be easily accomplished by:

MiddleValues ( listOfValues ; 2 ; ValueCount ( listOfValues ) )

or even better:

RightValues ( listOfValues ; ValueCount ( listOfValues ) - 1 )

But the author was too ignorant or too lazy for that. As a result, the person reading the code started a post here asking:

Quote

I am trying to figure out what the "999999999999999" is doing here in this partial script please

 

  • Plus1 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.