How to transfer data between BLL and UI in a three-layer (single-level) application?

I am a newbie programmer who is trying to learn the basics of n-layered architecture (DAL, BLL, UI). The application I program is a single-level, three-layer application written in VB.NET (.Net 3.5). Layers:

Gave

Bll

interface

COMMON - Contains DTO right now.

I am having trouble deciding what needs to go between my BLL and UI. My instinct tells me that I should only pass data to the user interface, and not the complete business object from the BLL. Consider two scenarios:

1) Transfer the BO directly from the BLL to the user interface. This provides BO methods and allows the UI to directly access the BO, which seems bad.

2) Only transfer relevant data from the BO to the user interface. For example, a customer has a name and address. This data really shows what we want to display / edit in the user interface, so we will return this data only to the user interface, not the full BO. The user interface should then call BLL to update a specific BO.

I tend to use # 2, but I don't know how best to implement it. As I programmed it now, if I only return data from the BLL, all links to my BO will be lost, and the GC will declare it. Based on this, I have a few questions:

1) Should I save business objects between BLL calls? An alternative is to re-create them every time I pass data through the BLL, which seems wrong.

2) BO ( , ?)

3) n-level? BO BLL ? " " BLL, , BO , ?

, - . , , , , .

+3
2

. . BLL, DAL , . , singleton factory .

CRUD, :

FooInfo DALFactory.FooService.Retrieve(int id);
FooInfo BLLFactory.FooService.Retrieve(int id);

IList<FooInfo> DALFactory.FooService.RetrieveAll;
IList<FooInfo> BLLFactory.FooService.RetrieveAll;

FooInfo DALFactory.FooService.Create(FooInfo entity);
FooInfo BLLFactory.FooService.Create(FooInfo entity);

FooInfo DALFactory.FooService.Edit(FooInfo entity);
FooInfo BLLFactory.FooService.Edit(FooInfo entity);

void DALFactory.FooService.Delete(FooInfo entity);
void BLLFactory.FooService.Delete(FooInfo entity);

, (, ), . BLL -.

Retrieve RetrieveAll , . Create . "-" Business Logic Layer BLLFactory.FooService FooInfo.

stateless BLLFactory.FooService , . FooInfo , ASP.NET - .

0

:

UI - ASP.Net Windows -
- , COMMON - DTO -
BLL - - DTO Business Objects DTO
DAL -

0

Source: https://habr.com/ru/post/1724757/


All Articles