Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

All request and response bodies for the repository services have a JSON format.  The controller layer is where all  Plain Old Java Objects (POJOs) are marshaled to/from JSON.  Every request and response objects is defined by a JSON schema, which is then used to auto-generate a POJO.  For more information on this process see the /wiki/spaces/JSTP/pages/7867487 and the /wiki/spaces/JSTP/overview project.

...

Ideally the services/managers layer encapsulates all repository services "business logic".  This business logic includes any object composition/decomposition. This layer is also where all authorization rules are applied.  If the caller is not allowed to perform some action an UnauthorizedException will be raisedFor example, while a WikiPage is a single Managers interact with datastore such a RDS using a DAO, which will be covered in more details in the next section.

DAO

A Data Access Object (DAO) serves as an abstraction to a datastore.  For example, WikiPages are stored in a RDS MySQL database.  The WikiPageDAO serves an an abstraction for all calls to the database.  This forces the separation of the "business logic" from the details of Creating, Reading, Updating, and Deleteing (CRUD) objects from a datastore.

One of the major jobs of a DAO is the translation between Data Transfer Objects (DTO) which are the same objects exposed in the public API, to Database Objects (DBO).  This translation means DTOs and DBOs can be loosely coupled.  So a database schema change might not result in an API change and vice versa.  This also provides the means to both normalize and de-normalize relational database data.  For example, an WikiPage (a DTO) object provided by an API caller will be translated into four normalized relational database tables each with a corresponding DBO.

Acronym summary:

  • DTO - Data Transfer Object is same object end-users see/use when making API calls.
  • DBO - Database Object is a POJO that maps directly to table.  For every column of the table there will be a matching field in the corresponding DBO.
  • DAO - Data Access Object is the abstraction that translates to DTOs into DBOs directly performs all datasource CRUD.
  • CRUD - Create, Read, Update, and Delete.