To chance the pin number without searching the whole code for where this pin is used.
button=digitalRead(buttonpin)
Only read the pin once at this point in the code and be able to do multiple if statements on button without the state changing during your program.
This also saves CPU time by putting a 1 or 0 in button you don't have to run the whole digitalRead code again.
Your solution is also working and for that it is not wrong, but if you gonna make a large program and you use the variables again and again in the code this is easy to correct faster and more reliable.
For myself I use both of the options.
If I have to test some hardware and want to now what the input on A analog pin is I use:
Serial.println(analogRead(0));
but if the program is going to get bigger and I need the variable more than once I do:
int readpin = 0;
int reading=(analogRead(readpin));
Serial.println(reading);
if (reading >200 && reading <400) Serial.println("test1");
if (reading >400 && reading <600) Serial.println("test2");
if (reading >600 && reading <800) Serial.println("test3");