Timeline for Is there a special name for a condition which will break a loop if it increments a set number of times
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Dec 9, 2013 at 16:23 | comment | added | Robert Harvey | The 50 is a magic number. Normally, instead of "hardcoding" a stop value there, you would define a constant at the top of your script, such as MAX_VALUE, and say for (var i = 0; i < len && i < MAX_VALUE; i++) But, your mileage may vary; if this is just a small bit of Javascript, it may not matter. My point is that the "hard coding" aspect of this is not particularly significant. | |
| Dec 9, 2013 at 16:18 | comment | added | 1252748 | What magic number in what if? I'm sorry, I'm confused. | |
| Dec 9, 2013 at 16:15 | comment | added | Robert Harvey | @thomas: I'm not totally comfortable with "magic numbers" like the one in your if. Generally, you would define a constant somewhere, like MAX_VALUE, and use the constant for the condition instead of the magic number. | |
| Dec 9, 2013 at 16:15 | comment | added | 1252748 | I think this is a good answer. Do you feel saying "hardcoded boundary condition" is a meaningful way to distinguish this condition from that which @SomeGuy described? | |
| Dec 9, 2013 at 16:13 | comment | added | 1252748 | @SomeGuy "hardcoded boundary condition"? | |
| Dec 9, 2013 at 16:11 | comment | added | Some Guy | Good answer. Might want to clarify that the i < len condition is a boundary condition too. | |
| Dec 9, 2013 at 16:10 | history | answered | Robert Harvey | CC BY-SA 3.0 |