views:

174

answers:

6

When you say "thin data access layer", does this mainly mean you are talking about writing your SQL manually as opposed to relying on an ORM tool to generate it for you?

+2  A: 

That probably depends on who says it, but for me a thin data access layer would imply that there is little to no additional logic in the layer (i.e. data storage abstractions), probably no support for targeting multiple RDBMS, no layer-specific caching, no advanced error handling (retry, failover), etc.

Since ORM tools tend to supply many of those things, a solution with an ORM would probably not be considered "thin". Many home-grown data access layers would also not be considered "thin" if they provide features such as the ones listed above.

Eric J.
You seem to be saying what it does not represent without specifying what it must contain. Is that because the term itself is vague?
pepper
What exactly constitutes a "thin" layer is subjective more than vague. The only thing that MUST be in there is code to move data between the application representation (typically business objects) and the data representation (typically SQL tables).
Eric J.
+1  A: 

Depends on how we define the word "thin". It's one of the most abused terms I hear, rivaled only by "lightweight".

That's one way to define it, but perhaps not the best. An ORM layer does a lot besides just generate SQL for you (e.g., caching, marking "dirty" fields, etc.) That "thin" layer written in lovingly crafted SQL can become pretty bloated by the time you implement all the features an ORM is providing.

duffymo
Are you using "ORM layer" as a synonym for "data access layer"? I thought there was more of a clear distinction between the two?
pepper
No, ORM is one way to implement a data access layer. Think of data access layer as the class or interface and ORM as a particular implemenation of it.
duffymo
A: 

I think it depends on the context.

It could very well mean that, or it may simply mean that your business objects map directly a simple underlying relational table structure: one table per class, one column per class attribute, so that the translation of business object structure to database table structure is "thin" (i.e. not complex). This could still be handled by an ORM of course.

Deltics
So an ORM could be what you mean when you say "thin data access layer" but it would depend on how full-featured the ORM is - only a minimalistic ORM would qualify? It seems to be a difficult term to define. Maybe it's just vague and not very meaningful. At least that's what I'm getting here.
pepper
+1  A: 

I think "thin" in this context means:

  1. It is lightweight;
  2. It has a low performance overhead; and
  3. You write minimal code.

Writing SQL certainly fits this bill but there's no reason it couldn't be an ORM either although most ORMs that spring to mind don't strike me as lightweight.

cletus
So an ORM could be what you mean when you talk about the data access layer? I thought there was some kind of subtle difference between what an ORM does and what a data access layer does -- although I couldn't tell you what it is :-)
pepper
A data access layer is simply a means of simplifying access to persistent storage. An ORM fits that description too. The "thin" part of this is a subjective test.
cletus
So you're saying it would really depend from one case to the next what someone really meant when they said that the data access layer was "thin" since some ORMs might have more features than others.
pepper
A: 

It may mean that there is no or minimal logic employed on the database such as avoiding the use of stored procedures. As other people have mentioned it depends on the statement's context as to the most likely meaning.

sipwiz
Why would the absence of stored procedures mean that the data access layer is thin?
pepper
A: 

I thought data access were always supposed to be thin... DALs aren't really the place to have logic.

Maybe the person you talked to is talking about a combination of a business layer and a data access layer; where the business layer is non-existent (e.g. a very simple app, or perhaps all of the business rules are in the database, etc).

Giovanni Galbo