Service Reusability

Jakob Jenkov
Last update: 2014-05-23

The reusability of a service depends a lot on its design and purpose. By "reusability" is meant in how applications or larger services, can a given smaller service be reused. I'll explain this with a small example:

Imagine you have two applications, A and B, that both need customer information. Application A only needs the customers first name and last name, but application B needs the customers first name, last name, customer number, phone number, email address etc. The requirements are summarized here:

Application A
 - First Name
 - Last Name

Application B
 - First Name
 - Last Name
 - Customer Number
 - Phone Number
 - Email Address
 - etc.

In order to service both application A and B you have two options:

  1. Create one big Customer Service which returns all customer information
  2. Create two Customer Services. One that returns all customer information, and one that only returns first name and last name.

From a service reusability perspective it would of course be nice to only have one customer service to develop and maintain. This service could then be reused in both appliation A and B.

From a performance perspective though, the one big customer service would impose an overhead on the communication when used by application A (which only needs first name and last name), because the big customer service sends back more data than application A needs.

The design choice between one wide service or multiple tailored services is illustrated here:

Service Reuse
Service Reuse - Reuse one wide service and live with overhead, or create services tailored for each applications needs?

Jakob Jenkov

Featured Videos

Java ForkJoinPool

P2P Networks Introduction


Java Persistence
Close TOC
All Tutorial Trails
All Trails
Table of contents (TOC) for this tutorial trail
Trail TOC
Table of contents (TOC) for this tutorial
Page TOC
Previous tutorial in this tutorial trail
Next tutorial in this tutorial trail