Chapter 5. Services

Table of Contents
Overview
Service Implementation Abstraction
Example: Voting

Overview

The notion of a service helps to separate the business logic functionality from the other implementation. The key component is a "Service" interface which provides means of "being service". It means that if a component holds business logic, it makes such visible by realizing "Service" interface. "Service" consist of set of elementary functions (operations), which make up the service as a whole. For example, a "Voting service" has functions such as: "getVotingQuestion", "getVotingStatistics", "vote", etc.

The component, implementing "Service" interface, either provide the service functions explicitly, or makes them accessible through "execute" operation. It is, however, good practice, to extend "Service" interface and enumerate all the service functions, which makes up an API of the service.

Figure 5.1: Class Diagram: Service

All the available services are initialized at the application startup and are managed by a "ServiceMgr". The "ServiceMgr" is a multiton instance which means that there is a set of "ServiceMgr" instances denoted by its name.