Dofactory.com
Dofactory.com
 Back to list
Views:   7.9K
Replies:  1
Archived

Passing information: parameter vs property.

Hi,

Which method is best for passing information?
I have created 3-layered architecture

GUI - MODEL(BL) - DAL

here is what I have coded

BL OBJECT

Category
{
  public string CategoryName {get;set;}

 Category()
 {
  //do nothing
 }

 Category(string categoryName)
 {
  CategoryName = categoryName;
 }

 DeleteCategory()
 {
 }
}

DAL

CategoryDao
{
 DeleteCategory(string CategoryName)
 {
          SqlConnection SqlConn = new ....
          SqlCommand sqlCmd = new ....
          cmd.paramater.AddWithValue("@categoryName",CategoryName);

           try
         {
                bla..
        }
        Catch....
 }
}


UI Layer

some.aspx.cs

btnDeleteCategory_Click(Sender s, Eventargs arg)
{

  //My QUESTION -> IS THIS A GOOD APPROACH
  Category c = new Category(txtCategoryName.Text)
  c.DeleteCategory();

  //OR

  //SHOULD IT BE DONE THIS WAY
 Category c = new Category()
 c.DeteleCategory(categoryName);   -> Consider that DeleteCategory takes one string argument.
 
}


Regards and THANKS in advance
Asmprogs Asmprogs, Jul 12, 2011
Reply 1
Hi your BL will have a logic to perform operations, so better to use parameterized methods.
If you are creating custom entities then properties will do the things. 
I hope second approch is fine.
Imran Khan, Jul 12, 2011
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.