How to properly set up a Limit Switch

I was just wondering the properly way to program and set up a digital/limit switch in Command Based Programming, does any one know the proper way to set it up?

That depends on how you use it. In our code (eg. this file from last year), we make the DigitalInput part of the subsystem, then access it from outside with a more significant name (isForward() in this case). By doing it this way, the rest of the code does not have to care too much about the internal details, and if it turns out that the limit switch indicates the opposite of what you think, you can negate it in that named method, so it only has to be done in one place.

Our team is just wanting to use it for a safety switch basically.