Hacker News new | ask | show | jobs
by computerslol 4416 days ago
I think I see where you're coming from. Correct me if I am wrong.

If I were solving the same problem:

public void CreateBooking( int chosenBookingType,... ){ ...

- and -

public string[] GetAvailableBookingTypes(){ ...

or something similar.

Your implementer can call GetAvailableBookingTypes at run-time to populate whatever interface lets you select one, then pop the index of the selection back into CreateBooking. I have it returning an array of strings as a very simple solution; you can just as easily return an array of objects that better represent your booking types (containing descriptions, and URIs to icon images or colors or whatever). The methods are named in such a way as to lend to the fact that they are related. No enums, no wonkiness and you can add new booking types at will without having to let your implementer know something changed. If your implementers are not catching on that the two methods are related, you can solve that problem with easy to read documentation.