Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Remove as many uses of enums as possible #5

Open
Dominaezzz opened this issue May 25, 2022 · 0 comments
Open

Remove as many uses of enums as possible #5

Dominaezzz opened this issue May 25, 2022 · 0 comments

Comments

@Dominaezzz
Copy link
Owner

Enums are nice for type safety and limiting strings to a known set of choices. For example join rules, there's invite, private, knock, public and restricted.
However, this restrictive convenience isn't in the spirit of matrix's extensibility. A server may introduce a custom join rule, which is a perfectly acceptable thing to do in matrix, but using an enum for join rules would prevent matrix-kt from being able to parse the join rule event.

In the case of join rules, it is easy to use polymorphism to allow for extensibility but for some other cases a plain String is more appropriate. A separate object can provide constants to prevent hard coding the enum values.

I understand some people may not like this but I can't think of sane alternatives to keep matrix-kt extensible.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant