I often have the same problems when I have to create my own class for a web application. Requirements: - supported (for example, without copying) - the layers are completely separated (the business layer does not need to know which method is used for the data layer) - high performance: do not load useless data.
First, I have a table with all my clients and their addresses: Code:
Customer
--Id
--Name
--Address
Now I need a table (on another page) with all my clients and the books they bought, I have several options:
1 / I create a new class:
The code:
CustomerWithBooks
--Id
--Name
--Books[]
PRO: I load only useful data CONS: I create my class after my user interface, and there is a copy.
2/ Books [] .
PRO: ,
CONS: . , : , , , , DAL , .
3/ :
:
ClientBase
--ID
--Name
ClientWithBooks : ClientBase
--Books[]
ClientWithAdress : ClientBase
--Address
PRO: ,
CONS: , ?
4/?? ,