Identifying hooked up components and changing code

I have a project that I haven't touched in a long time, but it'd would be nice to determine components that are hooked up and have the code change to include those.

Example would be (uses predetermined standard pins) Component A = 4 pins for display Component B = 2 pins for Thermometer Component C = 2 pins for another Thermometer Component D = 9 or 10 pins for 8 port relay (I forget how many pins) Component E = 5 pins for 4 different float switches

So specific ports must be used for each components (I think) but what if someone decides they don't want to use 4 float switches rather just 2 or not use second thermometer, how doable is this and can someone point me to demo code?

Its been a long time since I touched Arduino code, so I'm asking those that are actively coding

With a display and some buttons, you can ask the user what they plugged in. For example most PCs will detect when something is plugged in the headphone jack and the PC will ask if it is headphones or speakers.