Service vs. Component

By | July 14

I was having trouble to differentiate between both nor could I 100% explain to someone what’s the real difference between a Service and a Component. Today I’ve found a really nice definition by Martin Fowler which I would like to share with you:

Component

I use component to mean a glob of software that’s intended to be used, without change, by application that is out of the control of the writers of the component. By ‘without change’ I mean that the using application doesn’t change the source code of the components, although they may alter the component’s behavior by extending it in ways allowed by the component writers. - Martin Fowler, Inversion of Control Containers and the Dependency Injection pattern

Service

A service is similar to a component in that it’s used by foreign applications. The main difference is that I expect a component to be used locally (think jar file, assembly, dll, or a source import). A service will be used remotely through some remote interface, either synchronous or asynchronous (eg web service, messaging system, RPC, or socket.) - Martin Fowler, Inversion of Control Containers and the Dependency Injection pattern

2 comments on “Service vs. Component

  1. HEy, i had the same troubles. This definition really comes in handy

  2. Typically these below differences are also helpful:

    Components are self-contained and autonomous with “stateful” information (which is required for implementing persistence).

    On the otherhand, Services are mostly ‘stateless’ (and inherently use components to achieve their intended functionality). Persistence is not something that is directly related to Services.

    Also, the main difference between Component-oriented and Service-Oriented approach is the ‘ownership’. You, the user, own the Component - on the contrary, you do not own the Service, you just ‘use’ the Service (and pay per service).

    Gopalakrishna Palem
    Creator of CFugue C++ Runtime