doing a code review right now and my coworker has run into a surprisingly complex problem which is very simple on the surface
basically a function needs to be abstracted over ipv4 and ipv6 configuration, except the configuration in question uses 4 different ways to differentiate between ipv4 and ipv6:
- "V4" and "V6"
- "v4" and "v6"
- "" and "6"
- "" and "V6"
currently my coworker basically just did a bunch of "Ipv4String" if ipv4 else "Ipv6String" sort of statements and i've been trying to figure out a nicer abstraction and so far everything i've come up with has been probably too complex for it's own good
all of the strings could be hardcoded into a dictionary or dataclass but that's a lot more lines and a lot more complex than the current solution
my best idea so far is something like this:
this works for cases 1-3 but doesn't work for case 4, unless i wanted to add like
noV4but then that's kinda unwieldy...