News for hackers. Stuff that matters.
Re:Ask HN: How would you an API to handle request variabilit... by gitgud on Tuesday March 31, 2020 @02:06AM (#22735265)
Short advice: avoid inheritance, favour composition.

Some other things I would do:

- Simplify API: (/service/${STATE})

- Create a dictionary of ${STATE} to RequestHandler's for all cases, and a default case.

- Divide as much functionality into reusable stateless functions.

- Compose RequestHandler's with reusable functions.

Now when the server receives a request with ${STATE} it can look up the appropriate handler in the dictionary and process the request.

Re:Ask HN: How would you an API to handle request variabilit... by ortne on Tuesday March 31, 2020 @07:37AM (#22736590)
Thanks for the advice! This seems like a reasonable approach I might give a test drive.