java - How to design a robust Status class for an API or framework in OOP? -


i'm working on generating api ad-hoc enterprise solution , i'm stuck in process of generating both generic , expressive class handling status operations in related classes.

in nutshell, want know standards (or best practices) on designing status handler. want achieve methods , classes belong common 'module', of them return , handle status messages belong defined status structure, different status messages not dependent of implementation.

a possible solution be: - create status class in module defines series of status numbers constants - status class manage defined status numbers , define status messages each one. - methods of module require status handling return instance of status, handled in higher layers of module, , not hard coded in each method.

any suggestions better models? how api's manage this?

use status enum, not class of constants. provide defined , constrained set of status values. can have getmessage() other status related functionality.


Comments