BL DAL Design Issue (using DTOs)

BL DAL Design Issue (using DTOs)

Old forum URL: forums.lhotka.net/forums/t/744.aspx


vicky_iit posted on Thursday, July 27, 2006

Hi Rocky,

I decided to put it as a new thread.

Yr recent posts forced me to ask you one more query, slightly more granular. Sometime back i was wrking on a project whose BL layer used to talk with DAL using DAL DTOs.

There I noticed that the BL objects never had any private members but used the DTO itself.

Eg.: there is a Customer class with 3 attributes.

now, when thinking of using DTOs, my approach is like:

class Customer
{ private string _name;
private int _age;
private int _id;

public Customer() {} //public constructor
internal Customer(customerDTO data)
{
  _name = data.Name;
  _age  = data.Age;
  _id   = data.Id;
}

public string Name
{
//return this._name;
}

//similary properties for each private attribute that needs to be exposed.
}

Now, in CustomerList class i will have some method FindCustomers(criteria) which will return a list of CustomerDTOs. I will then instantiate a new Customer object passing that DTO in the constructor.

But in that project, I noticed different behaviour. The DTO was passed in the Customer objects constructor but the code was like:

class Customer
{
  private CustomerDTO _data;  //no other private attributes
 
  internal Customer(CustomerDTo data)
   {
      this._data = data;
   }

   public string Name
 {
  return _data.Name;
  }

//similarly other properties
}

Now, i think that this approach isnt right as BL is now more tightly coupled with the

DAL DTOs. Its like intead of the BL defining the attributes, the job is upto the DTO.  Am i right?

wud luv to hear u on this.

vivek

vicky_iit replied on Sunday, July 30, 2006

No comments ..Sad [:(]Sad [:(]

some one please enlighten me!!

 

Vivek

Copyright (c) Marimer LLC