Shriti
Shriti

Reputation: 1

Should we use webservices or do direct database access

Should we use webservices or do direct database access. Ofcourse direct DB access is relatively faster and also with webservices it is good if we have to make for multiple platforms. is the time significantly high in case of accessing data through a webservice as against a DB call or is it marginally high ?

Upvotes: 0

Views: 1198

Answers (2)

ryan1234
ryan1234

Reputation: 7275

I would have to disagree with TruthOf42 in that web services are best practices for data access. There is certainly a big shift towards that approach these days, but I don't think common use is the same as best practice. Just because something is common/popular doesn't mean it's the best fit for all situations.

Why use web services?

  1. If you plan on having more than one application use a generic data access layer.
  2. If you plan on exposing your data to external clients.
  3. If you want to draw some hard physical lines between your application and the database.

I would argue making web service calls will always be slower than just writing queries against the database. But you can mitigate the issues with wise network planning and caching.

I agree with Aphelion in that if it's a simple application, then keep it simple.

A good idea would be to make an interface in your code that gets data and you start with a database implementation. If you find you'd like to introduce web services later, then you can keep the same interface and just implement a version that makes web service calls instead of directly dialing the database.

Upvotes: 3

TruthOf42
TruthOf42

Reputation: 2107

Don't try to optimize something you haven't even written yet. It's best practices to use web services. Doing direct calls to the database just opens you to more security issues.

The most important thing when writing software is writing it well, speed is usually of last concern.

Upvotes: 1

Related Questions