Hi folks,
If you looked on the Q&A for this section you will have seen an alternative solution to the problem when the max value doesn’t go higher than 999.
The following is my opinion, so take with a great big grain of salt
The solution in the video tutorial.
In the start() function
max = max + 1;
I feel the primary reason for them showing the solution max=max+1 is I think that it’s easier to understand.
Pros : Simple, works effectively, one line code change.
Cons : I feel is not good practice, I get that it’s a really early tutorial but still think it’s worth presenting Corey’s solution as a comparison that solves the problem without altering the max value. Just doesn’t feel clean to me, since accessing the maximum value will show 1001 in any display.
The alternate solution of adjusting the guess seems cleaner.
Pros : No adjustment of the original value, so should it be printed out again it’s still 1000 not 1001.
Cons : Requires 2 lines of code to change Double the coding effort! Slightly more difficult to mathematically/programmatically understand.
Also it’s probably worth mentioning that commenting this is type of detail is a really really good idea.
Those reasons are twofold but are generally to do with remembering why it’s there.
- It means when you go back to it in a month you’ll see why it’s there and what it’s for.
- It means that if someone else comes along they can see what it’s for and whether it’s safe for them to remove if they have a different way of doing it.
I’ll take this opportunity to say these videos are great, it’s nice to start from a basic stand point and work up
Skal,
Solphist