Dual position switch to affect two different modes?

Hello

I have a 2-position switch that I would like to use to change which bit of if code runs in a loop.

I was going to use the tutorial debounce code to do this (the switch is not meant to be changed by a user, just so that I can test the two modes in situ without plugging a usb computer in, and hopefully without any spurious readings).

a - Is the debounce code the right one to use in this situation?
b - What is the best way to combine the switch code, is it with an 'if else', and do I do this in setup or loop?
c - What do I need to get my head around in order to reformulate 'int mode', am I meant to be making a state machine?

Thanks in advance, snippet below...

int mode = 1; // 0 for zero mode or 1 for mode 1

void loop() {


  if (state == HIGH) {
    closeTop();
    digitalWrite(ledPin, currentTrackIsPlaying);
    timeSinceLastCoin = millis() - coinFrequencyTimer;
    Serial.print("Time since end of last track:");
    Serial.println(timeSinceLastCoin);

// mode for using the coin drop time to play

if(mode == 0) {
    Serial.println("We are in mode 0");

//etc

if(mode == 1) { 
  Serial.println("We are in mode 1");
Serial.print("Coin Value:");
Serial.println(coinValue);
Serial.println(" ");

//etc

am I meant to be making a state machine?

Yes. It has 2 states as follows :

if the input pin is HIGH
  execute this code
end if
else
  execute this code
end else