Reputation: 19617
Let's say I want to write an FTP client from scratch. In the command channel various status and error codes can be passed between server and client such as :
Ideally, the numeric code and a human-readable message should be kept.
How should these be represented ? As an enum in some sort of Connection
class ? What could be done to accomodate different messages or new codes ?
Upvotes: 0
Views: 197
Reputation: 5327
I would prefer the enums with some logic contains:
public enum FTPReturnCode {
OKAY(200), NAME_OK_PW_NEEDED(331), ... ;
}
Since the FTP doesn't change since 1985 (rfc959), you can add all FTP response codes into the enum class.
Upvotes: 1