|
|
|
|
|
by kennywinker
1704 days ago
|
|
I've seen essentially this code in so many organically grown codebases (when they grew up without types). It's usually close the the UI, because someone had to quickly add an alternate path to support some new user interaction function find_user(person) {
if user is string {
query_by_name(person)
} else {
query_by_name(person.name)
}
}
and yeah, we all know it's kinda messy, but also that logic has to live somewhere and we need this feature asap so it passes code review. I wrote a test for it, ship it. |
|
In a static language, you either can't do it, have to really go out of your way to do it, or at least do function overloading (which is a bit cleaner)