472,986 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 software developers and data experts.

n-tier design with "adapter" layer - keepin business layer clean...

Hi -
(not really a C# question -...apologies)

I seem to have gravitated towards a particlar design pattern - and
would welcome your opinions as to it's sanity - thanks...

The basic idea is that - in an effort to keen the Business Classes as
clean as possible - I have *totally* excluded any data load/
persistance code.

In my model a Data Adapter is used to load/persist the Business
objects eg:

Customer c = Adapter.LoadCustomer(id);

or

Customer c = new Customer(id);
Adapter.Hydrate(c);

Basically the Adapter acts as a bridge between Business and Data
aspects.

The UI gets nice Business Objects to work with, the Data Access Layer
returns only built in types (eg Dataset) and the Adapter marries the
two.

here's a piccie of my architecture:

UI
|
| --------------|
Bus Adapter
|
Data Access
|
Data Source

I don't think I've invented this myself - but googling only turned up
models where the following might be done:

Customer c = new Customer(id);
c.Load();

comments appreciated !

O.
Jun 27 '08 #1
2 2324
I believe the terminology is provider not adapter. That's the best design in
terms of flexibility really because it allows you to separate concer... well
you already figured out what the benefits are. The only downside I impress
upon our architects is that there is added complexity and it may be overkill
for small to medium projects.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------
<ol*******@googlemail.comwrote in message
news:ed**********************************@k13g2000 hse.googlegroups.com...
Hi -
(not really a C# question -...apologies)

I seem to have gravitated towards a particlar design pattern - and
would welcome your opinions as to it's sanity - thanks...

The basic idea is that - in an effort to keen the Business Classes as
clean as possible - I have *totally* excluded any data load/
persistance code.

In my model a Data Adapter is used to load/persist the Business
objects eg:

Customer c = Adapter.LoadCustomer(id);

or

Customer c = new Customer(id);
Adapter.Hydrate(c);

Basically the Adapter acts as a bridge between Business and Data
aspects.

The UI gets nice Business Objects to work with, the Data Access Layer
returns only built in types (eg Dataset) and the Adapter marries the
two.

here's a piccie of my architecture:

UI
|
| --------------|
Bus Adapter
|
Data Access
|
Data Source

I don't think I've invented this myself - but googling only turned up
models where the following might be done:

Customer c = new Customer(id);
c.Load();

comments appreciated !

O.
Jun 27 '08 #2
ol*******@googlemail.com wrote:
Hi -
(not really a C# question -...apologies)

I seem to have gravitated towards a particlar design pattern - and
would welcome your opinions as to it's sanity - thanks...

The basic idea is that - in an effort to keen the Business Classes as
clean as possible - I have *totally* excluded any data load/
persistance code.

In my model a Data Adapter is used to load/persist the Business
objects eg:

Customer c = Adapter.LoadCustomer(id);

or

Customer c = new Customer(id);
Adapter.Hydrate(c);

Basically the Adapter acts as a bridge between Business and Data
aspects.

The UI gets nice Business Objects to work with, the Data Access Layer
returns only built in types (eg Dataset) and the Adapter marries the
two.

here's a piccie of my architecture:

UI
|
| --------------|
Bus Adapter
|
Data Access
|
Data Source

I don't think I've invented this myself - but googling only turned up
models where the following might be done:

Customer c = new Customer(id);
c.Load();

comments appreciated !
This is exactly how our 'Adapter' paradigm works in LLBLGen Pro :)
CustomerEntity c = new CustomerEntity("CHOPS");

using(DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchEntity(c);
}

so no persistence logic inside the entity classes. The advantage is
that UI developers can't make shortcuts to access data or persist data.
This also means that there's no lazy loading.

Most O/R mappers use this pattern with one exception: most o/r mappers
DO implement lazy loading in their implementation of the pattern, which
effectively means it somewhat mitigates the whole purpose of the
pattern. (also, most o/r mappers who implement this have a centralized
'context' or 'session' class which mimics the 'adapter'. However it also
does change tracking. An adapter IMHO shouldn't do that, it should leave
change tracking to the entities itself)

The other paradigm, i.e. with Load/Save etc. as methods on the entity
class is called 'SelfServicing', as we like to call it, as the entities
serve themselves: they can save/load themselves. Of course,
selfservicing does have lazy loading.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: NotNeo | last post by:
I am getting a strange symptom: tnsping and sqlplus work fine on my LINUX server (neo) so the listener and DB are OK. However, from my remote XP Client (tank) I get TNS-12560. I can ping the neo...
19
by: Jaime Stuardo | last post by:
Hi all.. I have created a business logic component that is used from my ASP.NET webform. It works, but connection string to the database is hard coded, as in this method : public DataSet...
2
by: miked | last post by:
I am architecting in a read only class for use in mapping data to a business object. The object makes strong use of nested classes and their ability to access protected fields. The downside is...
2
by: FluffyCat | last post by:
In June I continued my series of design patterns examples using PHP 5 with the Adapter Pattern. Here now is my 17th design pattern example, the Bridge Pattern. ...
1
by: Frank | last post by:
I have read and followed Scott Mitchells' tutorial, Creating a 'Business Logic Layer', @ http://www.asp.net/learn/dataaccess/tutorial02cs.aspx?tabid=63, and it occurred to me that he did not...
0
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it...
12
by: Randy | last post by:
Hi, Trying to pass along a table row delete to the datasource, but I'm crashing. Here is the code: Private Sub btnDeleteIngr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
3
by: daokfella | last post by:
In my solution, I have a project that is my data access layer. This layer simply consists of strongly-typed datasets created by dragging tables from the server explorer into the dataset designer....
9
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic...
4
by: Spam Catcher | last post by:
Hi all, I'm building a multi-tier web application that is primarily driven by a web service back end. Are there any configuration settings I should know about to increase the performance of...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.