Programming Services

In Domain Driven Design, services are identified and called out explicitly. In other words, services are a part of the vocabulary of the language used to describe the system.

An “invariant in an operation” is a constraint that holds true after the execution of the operation, Eg. An email has status read after the operation read. Services maintain these invariants across time and space. In simpler terms, services are responsible for persisting the state of of an object across multiple machines.

There are four points of interest when defining a service

1. Invocations. Is it a function call or a rest call

2. Parameters

3. Response

4. Consumer

The first three are fairly straight forward. It is the consumer that I am particularly interested in.

The stereotype of a consumer

There is a popular opinion that the consumer of a service should be another service or a controller, essentially a long lived object, one that is managed by the platform ( like spring) on which the application is being developed. The rationale behind this is unknown as yet. I have a feeling that the answer to this question would have to strike at the roots of Object oriented programming specifically on the question of the life time of an object.

Consuming a slow service

Another point of interest in a consumer is how does it consume a service that takes a long time to respond. Does it implement a cache or does it have some other mechanism for making the business operation faster, is a question that needs to be answered when consuming a service. Another point of interest here is, the lifetime of a cache if at all one is implemented, should be long, otherwise there is no point in implementing the cache.


Object Oriented programming is usually viewed as expressing a Turing machine in terms of classes and framework code. It is not even the core of Object oriented systems. The core of Object oriented systems are objects of whom the classes form a blue print. “An object oriented language expresses a system in terms of objects and the values that they take over time in response to operations on them”. Within that statement lies all the difference there is in the world of Object Oriented Programming.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s