Instead of the push buttons, I want to attach reed switches. I've done that by connecting one end of each reed switch to 5V, and the other end to an input of the 74HC165 via a 22k resistor. I am using this sketch to read data -
Please don't use that code. The 74HC165 is normally used with the Clock Enable connected to GND and using the Latch pin and without shiftIn().
When using shiftIn(), the data might be collected at the very edge of the clock pulse.
If the reed contact is open, it will result in a HIGH, if it's closed it will result in a LOW. If that's the wrong way around, you can swap the resistor and the reed contact or change the code to cater for it.
It isn't "wrong way around". It's a perfectly valid way of testing if the reed switch is open or closed. Just as valid as if you swap the resistor and reed switch.
The advantage is that you don't need to route 5V over potentially long wires to where the reed switch is situated. If you did that, and the 5V wire became broken or disconnected, it could cause a short circuit which could damage components or the power supply. But with my suggested wiring, if the wire gets damaged or disconnected and a short circuit occurs, the resistor limits the current, preventing damage.