Thursday, May 31, 2007

Component or Service?

What exactly is the difference between a component and a service?

This is a question that popped into my head when reading a response to Todd Biske's blog entry Challenge of Data Services. In the response, Udi Dahan comments that access to data should be done through components and not services. But what exactly is the distiction that Udi is making here?

After trolling a bit for a definition of a component, I came across the following on wikipedia:



A software component is a system element offering a predefined service and able to communicate with other components.



Clemens Szyperski and David Messerschmitt give the following five criteria for what a software component shall be to fulfill the definition:


  • Multiple-use

  • Non-context-specific

  • Composable with other components

  • Encapsulated i.e., non-investigable through its interfaces

  • A unit of independent deployment and versioning



A component is an object written to a specification.



A definition of service comes from ServiceOriented.org:


A Service is a callable routine that is made available over a network. Services have well defined interfaces (inbound and outbound).


While you may argue the exactitude of all these definitions, its pretty easy to see that a service and a component are very similiar if not indistinguishable. In fact it might be that the only difference between a service and a component is its accessibility via a network.

One might argue that a service is nothing more than the manifestation of a component on a network. To make this point I ask the following question: Does a component, written as a Java class, suddenly become a service when it is made accessible via an EJB or a Servlet or a Web Service? Or does it remain a component which is now offered as a service?

Of course you could still argue that the component was always a service from the point of view of other local Java classes.

I believe the Service Component Architecture puts its best:


SCA encourages an SOA organization of business application code based on components that implement business logic, which offer their capabilities through service-oriented interfaces called services...


Given all of this, if data should only be accessed via components and not services, then what happens when my Java implemented service needs access to data that is exposed via a .NET component? Do I re-write the component in Java and maintain both implementations? Or would I make that component a service and be done with it?

Thus I see no reason why data access can't be done via services.

No comments: