grid
grid copied to clipboard
UpdateMessage type is problematic
Short description
The UpdateMessage
type contains every possible field an incoming message can have. Because not every message will have every field, each field is an option type. This is less than ideal –
- To understand what messages it's possible to send, you must inspect the message switch code.
- To understand the correct combination of fields for a message, you must understand the implementation of each the message handler.
- It's possible to construct badly formed messages at the point of serialisation.
- To handle this proliferation of possible message shapes, each handler must contain code to extract the appropriate fields, making handlers more verbose than necessary.
We should use a sum type, and parse, rather than validating.
This PR details a possible solution.