473,386 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 2341
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.