i have a sealed class with about 10 subclasses (an...
# announcements
t
i have a sealed class with about 10 subclasses (and growing). now i need to map them to a frontend model. so i end up with a huge
when
statement which is more or less unreadibl. so again i end up with a visitor for this class. how do you handle this situation?
mmh ok at least implementing the visiotr is slightly more easy with a
sealed class
k
You could add an abstract method to the sealed class.
s
I don't know your exact use-case, but you can subclass a sealed class with other sealed classes. This could allow you to create (sub)categories of your data.
t
yeah in fact i did excactly that . in the end i was trying to find out how other people handle this situation
i mean sealed classes are cool and the exhaustiveness check of the compiler is cool, too. but in the end the visitor pattern still rules... i think
k
Or just normal polymorphism?