Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm new to designing a business logic layar and I'm searching for the optimal design.

What is a better way for the design of the business logic layar:
1. Put the business logic within the business entities.
2. Have a static model and perform de business logic by making use of adapters.

See the examples below.

What is better to do and what are de pro's and cons? Any advise would be greatly appreciated!

Design 1
VB
Dim Customer as New Customer(1)

Customer.Load()
Customer.Name = "John"
Customer.Update()


Design 2
VB
Dim CustomerAdapter As New CustomerAdapter
Dim Customer As New Customer

Customer = CustomerAdapter.GetCustomerByID(1)
Customer.Name = "John"
Customer.Update
Posted

1 solution

Design 1 is stupid. You end up having to call load, for a start. I like a private constructor, and methods to get by ID or create a new object with a constructor taking the values needed, and the method creating an object in the DB, which can be updated by editing the properties.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900