In my company, the system is designed for 3 levels. Layer1 is responsible for handling business logic. Layer3 invokes reverse systems. Layer2 is between two layers, so layer1 does not need to know about the back systems. To pass information from layer 3, layer2 must define an interface for layer1.
For example, layer1 wants to verify the correct PIN from the user. It calls the layer2 checkPin () method, and then layer2 calls the corresponding back system. The results of checkPin () can be: correctPin, inCorrectPin and internalError. At the moment, we have defined the return type 'int'. Therefore, if layer2 returns 0, it means correctPin; if 1 is returned, it means inCorrectPin; if 9 is returned, it means internalError.
It works. However, I am a little worried about this approach. Are there any better ways to do this? For example, define the enumeration CheckPinResult {CORRECT_PIN, INCORRECT_PIN, INTERNAL_ERROR} and return the type CheckPinResult?
Thanks Sarah
source share