Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

There is an interesting interview with Werner Vogels which is partly about how Amazon does Service Oriented Architecture:

For us service orientation means encapsulating the data with the business logic that operates on the data, with the only access through a published service interface. No direct database access is allowed from outside the service, and there’s no data sharing among the services.

I do not understand that. Why do they need to 'wrap' a database into some layer if it already can be consumed as a service by other service through database adaptors? Does Amazon do that just because they need to expose the database to third parties or because of anything else?

Why "no direct database access is allowed"? What are the advantages of such an architectural decision?

share|improve this question

migrated from stackoverflow.com Jun 24 '12 at 0:58

This question came from our site for professional and enthusiast programmers.

2 Answers 2

up vote 8 down vote accepted

Not allowing "direct database access" from an application allows the underlying database, and even the schema, to change without having to change the client applications.

Clients simply code to the service interface, never needing to know how the data is persisted.

share|improve this answer
    
Ray, I see your point. But for example can we call the Active Record in Ruby on Rails to be a database service interface? Or is it still a 'direct database access'? –  Martin Lee Jul 31 '12 at 7:26
    
ActiveRecord can go either way. On the one hand you are not writing SQL, but on the other hand the schema is pretty much exposed (unless there are some ActiveRecord tricks I am not aware of -- I'm only an AR novice at best). So there are actually degrees of encapsulation. AR encapsulates to a much lesser degree than other SOA persistence services such as those in AWS or GAE. –  Ray Toal Jul 31 '12 at 14:04

I agree with Ray Toal's point. Another is that a service that owns its own data becomes the only place where business rules to guarantee its integrity and proper usage need to be maintained.

Maintain it in one place rather than forcing clients to duplicate that logic. Keeps things nice and DRY.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.