Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending User Info From Application to Business Logic 1

Status
Not open for further replies.

FOR111

Programmer
Sep 29, 2005
103
MT
Hi All,

As most developers do i want to seperate the Application design / Presentation from the business logic. I have an application which i'm starting from scratch and i would like some advice...

I have 3 different projects, the EXE where its most forms , and 2 dlls, one takes care of the business logic and the other handles all the database calls.

My question is this:

In my exe i would like to send the form information to the business logic where it will be parsed, validated and saved, or sends an exception where needed.

What is the common or best way of sending the data from the form to the dll? filling up a HashMap or can i send the whole object?

Well any information u cna gather would be great..and i would be greatly in debt!

Regards and thanks
Nick
 
unless there is a specific requirement I don't see the need to seperate the bll and dal assemlbies. 2 physical dlls doesn't create a seperation concern. the objects can exist within the same assembly.

as for how to transfer data between the PL and BL. I use dto's (data transfer objects) that are specific to the request.

so if I want to access an order I would pass a GetOrderDto which has a single property, OrderNumber. my service fascade would load the order and return a ViewOrderDto which would have information petaining to viewing the order. order number, customer, order date, number of items, total sales amount of order, etc.

another feature about dto's. they are immutable. that is, readonly.
Code:
public class MyDto
{
   private readonly int i;
   private readonly string s;

   public MyDto(int i, string s)
   {
     this.i = i;
     this.s = s;
   }

   public int I { get { return i; } }
   public string S { get { return s; } }
}

I prefer dto's to hashmaps because a dto is strongly typed, so you get compile time checks for valid data. with a hash map you won't know until runtime if information missing.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I was thinking about DTO, and as you said they are strongly typed therefore no concern from that part. The thing that kept me back was that i would need a good number of DTOs for the application. but i guess that is the standard.

Thanks once again for your insight..

Regards
Nick
 
I often find DTOs an unnecessary tool. You can easily end up with class explosion. Usually, I simply populate the business object directly using a constructor.

Where I do use DTOs is where there is a remote call.

C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top