Hacker News new | ask | show | jobs
by linuxdude314 657 days ago
The examples are pretty silly, especially the first one.

If you know that you need either a shipping or billing address and the user has specified which one they need, just query based on that.

There’s no need to introduce a function (getTableName) to detemplate a string or match on a case.

Instead just create a function that gets the item you want from the DB and has the table name as input.

On your UI make sure when the users specifies billing or shipping address the correct parameter is passed to the API.