Click here to Skip to main content
15,890,579 members
Home / Discussions / C#
   

C#

 
GeneralRe: cannot load data from database to textbox in Visual c# 2008 Pin
Adekolurejo13-Jun-09 7:23
Adekolurejo13-Jun-09 7:23 
AnswerRe: cannot load data from database to textbox in Visual c# 2008 Pin
alamree13-Jun-09 7:08
alamree13-Jun-09 7:08 
QuestionRe: cannot load data from database to textbox in Visual c# 2008 Pin
Adekolurejo13-Jun-09 7:25
Adekolurejo13-Jun-09 7:25 
Question[Message Deleted] Pin
hkjghkj113-Jun-09 5:46
hkjghkj113-Jun-09 5:46 
AnswerRe: Sound Delay Pin
Henry Minute13-Jun-09 6:40
Henry Minute13-Jun-09 6:40 
AnswerRe: Sound Delay Pin
Dave Kreskowiak13-Jun-09 6:45
mveDave Kreskowiak13-Jun-09 6:45 
AnswerRe: Sound Delay Pin
0x3c013-Jun-09 7:34
0x3c013-Jun-09 7:34 
Questiona question for OOP experts and Presentation/Business/DB Layer Pin
pierpaolo paparo13-Jun-09 4:14
pierpaolo paparo13-Jun-09 4:14 
Hi All,
I have been studing some OOP books and some of them present this solution to break down an application beetween Presentation, Business and DB Layer.
Quick Example in pseudo-code

Business Layer

Class Customer
ID
Name
Surname
SaveCustomer {...}

void LoadCustomer(ID){
this = CustomerDB.LoadCustomer(ID)
}




end


DB Layer

Class CustomerDB
SaveCustomer{....}
Customer customer = LoadCustomer(ID){
//connect to a DB and load ID, Name, Surname
c = new Customer()
c.Name = DB.Name;
.....
return c
}

End

Here Class Customer delegate SaveCustomer, LoadCustomer to CustomerDB.
A presentation layer call would be

Custoer c = new Customer()
c.LoadCustomer(3)
print c.Name


Why do many books suggest this solution?

Personally I see these shortcomings

1) The Business Layers will not compile byitself, because has a reference to the DBLayer
2) The Customer object contains preperties that are not tipical of a Customer (Save, Load)
3) The Customer object is thightly coupled with CustomerDB

Would not be a better solution this one?
My solution

Class Customer
ID
Name
Surname
end


Class CustomerDB

Customer customer = Load(ID)
bool save(Customer customer)
end



and the presentation Layer will call

CustomerDB customerDB = new CustmerDB();
Custmer c = customerDB.Load(ID);
print c.Name


this way
1) The Business Layer is completely indipendent from the Business and Presentation Layer
2) It compiles byitself
3) The Customer Class does not have any strange property (Save, Load)
4) Customer is loosely cupled with CustomerDB

but
5) The presentation Layer must know about both business and DB Layer. (I don't like this)
What solution from a OOP programming is better?
Using the solution I suggested how can I let the presentation layer to be decoupled with the DB Layer?

Thanks

Pierpaolo
AnswerRe: a question for OOP experts and Presentation/Business/DB Layer Pin
Colin Angus Mackay13-Jun-09 4:30
Colin Angus Mackay13-Jun-09 4:30 
GeneralRe: a question for OOP experts and Presentation/Business/DB Layer Pin
pierpaolo paparo14-Jun-09 0:27
pierpaolo paparo14-Jun-09 0:27 
QuestionGot an error -->An unhandled exception of type 'System.StackOverflowException' occurred in PROJECT pro.exe Pin
KIDYA13-Jun-09 2:34
KIDYA13-Jun-09 2:34 
AnswerRe: Got an error -->An unhandled exception of type 'System.StackOverflowException' occurred in PROJECT pro.exe Pin
Anthony Mushrow13-Jun-09 2:43
professionalAnthony Mushrow13-Jun-09 2:43 
GeneralRe: Got an error -->An unhandled exception of type 'System.StackOverflowException' occurred in PROJECT pro.exe Pin
Luc Pattyn13-Jun-09 3:00
sitebuilderLuc Pattyn13-Jun-09 3:00 
GeneralRe: Got an error -->An unhandled exception of type 'System.StackOverflowException' occurred in PROJECT pro.exe Pin
KIDYA13-Jun-09 18:17
KIDYA13-Jun-09 18:17 
AnswerRe: Got an error -->An unhandled exception of type 'System.StackOverflowException' occurred in PROJECT pro.exe Pin
Colin Angus Mackay13-Jun-09 3:35
Colin Angus Mackay13-Jun-09 3:35 
AnswerRe: Got an error -->An unhandled exception of type 'System.StackOverflowException' occurred in PROJECT pro.exe Pin
dybs13-Jun-09 5:11
dybs13-Jun-09 5:11 
Questionwhat is the use of Httphandlers Pin
Shaik Haneef13-Jun-09 1:32
Shaik Haneef13-Jun-09 1:32 
AnswerRe: what is the use of Httphandlers Pin
Manas Bhardwaj13-Jun-09 2:00
professionalManas Bhardwaj13-Jun-09 2:00 
AnswerRe: what is the use of Httphandlers Pin
Gary Stafford13-Jun-09 8:19
Gary Stafford13-Jun-09 8:19 
QuestionBinding two projects into one exe Pin
KIDYA13-Jun-09 1:22
KIDYA13-Jun-09 1:22 
AnswerRe: Binding two projects into one exe Pin
Dave Kreskowiak13-Jun-09 2:11
mveDave Kreskowiak13-Jun-09 2:11 
QuestionI created Public Assembly by providing strong name, then what is that use still i need to give reference of that assembly. Pin
Shaik Haneef13-Jun-09 1:14
Shaik Haneef13-Jun-09 1:14 
AnswerRe: I created Public Assembly by providing strong name, then what is that use still i need to give reference of that assembly. Pin
Colin Angus Mackay13-Jun-09 3:38
Colin Angus Mackay13-Jun-09 3:38 
QuestionI created Public Assembly by providing strong name, then what is that use still i need to give reference of that assembly. Then what is the use of Global assembly ? How i utilize i know how to make the Assembly as Global but i don't know how to use, Pin
Shaik Haneef13-Jun-09 1:14
Shaik Haneef13-Jun-09 1:14 
QuestionGenerating Crystal Reports from class objects Pin
Andy Rama12-Jun-09 23:53
Andy Rama12-Jun-09 23:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.