✅ Best approach for returning typed objects
Hello,
I am porting a popular UA parser library called DeviceDetector to .NET.
The library determines the client from the user agent, which can be a browser, media player, feed reader, etc.
With the current implementation, there is an interface that all client models implement, and the returned object after parsing is of type
Which of these approaches would be the best to follow?
1st approach
2nd approach - it's similar to the 1st approach, but it is extended with an enum that represents the concrete type
I am porting a popular UA parser library called DeviceDetector to .NET.
The library determines the client from the user agent, which can be a browser, media player, feed reader, etc.
With the current implementation, there is an interface that all client models implement, and the returned object after parsing is of type
IClientInfo. This means that users would need to perform type checking and casting to determine the exact client type. As I see it, there are two possibilities, each providing the user with a different way of handling the concrete client.Which of these approaches would be the best to follow?
1st approach
2nd approach - it's similar to the 1st approach, but it is extended with an enum that represents the concrete type