Building the service layer
The service layer classes and interfaces will follow the same naming conventions of our DAO layer, where Service
simply replaces the Dao
equivalent name:
Our first definition will be for the Result
class.
The Result Data Transfer Object
The service layer will communicate with the request handling tier through interfaces that return Result
Data Transfer Objects (DTO). The DTO design pattern is commonly used in enterprise application programming to transfer data between different layers or subsystems. Our Result
DTO will have the following three properties:
boolean success
: This property is used if the action was successful and an appropriate data payload is availableString msg
: This is a message that may be used by the client for logging or informational purposes<T> data
: This is a generically typed data payload that will be consumed by the request handling layer
The Result
class is also a Value Object (VO), an immutable object whose state cannot be changed after...