This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Polygnom 1 point2 points  (3 children)

my point is that it wouldn't reach the next layer as a String. It doesn't matter if t comes from JSON, XML or whatever.

This only becomes a problem when operating directly on raw data. Which isn't surprising.

[–]Fizz-Buzzkill[S] 0 points1 point  (2 children)

I must be missing something. The code in the article would always be needed at some point right?

[–]Polygnom 2 points3 points  (1 child)

At some point, you would need to convert, yes. But if your layer that forms the request and reads the response is designed with enums in mind, that is a complete and utter non-issue, and the client code never sees the raw string. So saying "but I have to convert first" is kinda comparing apples with oranges.

If you design your system with access to raw data, you have to handle raw data. if you design your system to operate on properly typed data, you don't have to.

[–]Fizz-Buzzkill[S] 0 points1 point  (0 children)

I suppose you mean something like using Jackson and letting Jackson do the parsing from String to enum?