Adapter vs. Self-Servicing Discussion

Posts   
 
    
simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 08-Dec-2006 15:24:42   

I have been using Adapter for a while now. The original decision to choose it was easy because I was told that was the thing to use if you wanted to serialize LLB objects over web services. As I understand it, self-servicing also supports it now in v2.

Possibly mistakenly, I assumed that most other people were using Adapter for 'serious' applications and self-servicing for quick projects.

A year on, and new developers complain about the LLB learning curve when they already know .net 2 data access methods. Then I see the HnD (http://www.llblgen.com/hnd/) project and was surprised that it uses self-servicing.

I can't see moving to self-servicing taking too long, and I'm not bothered about supporting different databases. I suppose this is a discussion point rather than a question, but should I consider moving my application over to use self-servicing? I'd be interested to hear anyones opinion.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 08-Dec-2006 15:38:38   

The following was copied from the docs:

When to use SelfServicing When the project targets a single database type. When you are not using a distributed scenario like remoting or webservices. When you need navigation through your object model in a databinding scenario and you want to load the data using lazy loading. When you don't need to extend the framework. When you like to have the persistence logic into the entity classes. When you do not require fine grained database access control, like targeting per call another database.

When to use Adapter When the project targets multiple database types or would be able to do that in the future. When you are using a distributed scenario like remoting or webservices. When you don't need lazy loading scenarios in relation traversals. You can still navigate relations but you have to fetch the data up-front. When you need to extend the framework with derived classes. When you like to see persistence logic as a 'service', which is offered by an external object (broker, adapter). When you require fine grained database access control.

There was no need to use the Adapter model in the development of HnD, that's why for simplicity the SelfServicing model was used. If that's your case especially in new projects. Then go for SelfServicing. If not then go for the Adapter.

Now for your current projects, I don't see a reason to move your current applications to SelfServicing, unless you have the time and you are willing to spend it that way.

BTW: I always use the Adapter model, even in the simplest possible applications. Maybe that's because I'm used to it.Or maybe because I always take into consideration any possible changes in the future that will need the Adapter capabilities. (like porting to another database...etc)

simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 08-Dec-2006 15:45:32   

Oh right, so adapter is still recommended for webservices then?

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 08-Dec-2006 15:52:43   

Adapter is the flag ship here, unless you wanted the slight easiness of SelfServicing and/or the Lazy Loading fetaure.

simon831
User
Posts: 152
Joined: 19-Jan-2006
# Posted on: 11-Dec-2006 13:59:28   

I would have thought that virtually everyone uses Adapter, but looking through the forums I am surprised by the number of people using self-servicing. I'm just curious as to why. Have you any idea of the percentage split?

mihies avatar
mihies
User
Posts: 800
Joined: 29-Jan-2006
# Posted on: 11-Dec-2006 16:40:09   

IMO adapter is the way to go. If you suddenly feel a need to do some remoting you don't have much to change. There are other benefits, too, i.e. having full control of operations.

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 11-Dec-2006 19:26:44   

I've used both. 95% Adapter, 5% SelfService.

The SelfService project was just to see if I wanted to pursue using SelfService in my other projects.

I decided to only use Adapter after realizing that I always want to wrap my actual data access calls within a BL and not have the temptation to make the db calls directly from my ui layer.

e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 19-Dec-2006 21:53:21   

Fishy wrote:

I've used both. 95% Adapter, 5% SelfService.

The SelfService project was just to see if I wanted to pursue using SelfService in my other projects.

I decided to only use Adapter after realizing that I always want to wrap my actual data access calls within a BL and not have the temptation to make the db calls directly from my ui layer.

did you look at the HnD project? its using selfservice but all BL is seperate from the GUI. So its using the simplicity of selfservice and separating the BL from the GUI also. What do you guys think about this?

-shane

Fishy avatar
Fishy
User
Posts: 392
Joined: 15-Apr-2004
# Posted on: 19-Dec-2006 22:08:22   

e106199 wrote:

did you look at the HnD project? its using selfservice but all BL is seperate from the GUI. So its using the simplicity of selfservice and separating the BL from the GUI also. What do you guys think about this?

-shane

No, I haven't looked at the HnD project.

For me, a rule of thumb would be, use adapter if your ui is going to be using llbl entities. Otherwise, use adapter because you only need to learn one way of doing it. simple_smile