Click here to Skip to main content
15,666,479 members
Home / Discussions / C#
   

C#

 
GeneralRe: Best practice Pin
Not Active7-May-12 7:29
mentorNot Active7-May-12 7:29 
AnswerRe: Best practice Pin
PIEBALDconsult7-May-12 6:13
professionalPIEBALDconsult7-May-12 6:13 
AnswerRe: Best practice Pin
Jeremy Hutchinson7-May-12 7:03
professionalJeremy Hutchinson7-May-12 7:03 
GeneralRe: Best practice Pin
PIEBALDconsult7-May-12 7:38
professionalPIEBALDconsult7-May-12 7:38 
GeneralRe: Best practice Pin
Jeremy Hutchinson7-May-12 8:39
professionalJeremy Hutchinson7-May-12 8:39 
GeneralRe: Best practice Pin
Not Active7-May-12 10:14
mentorNot Active7-May-12 10:14 
AnswerRe: Best practice Pin
mo5andes7-May-12 7:14
mo5andes7-May-12 7:14 
AnswerRe: Best practice Pin
BobJanova8-May-12 0:22
BobJanova8-May-12 0:22 
Unfortunately the simplest answer to this is 'it depends'. Both approaches can be correct, depending on how complex the object is and what the data source is (i.e. does constructing the object require a database hit?).

I would typically have a layer of model objects which map directly to database rows, and my data access layer would create those from a pseudo-factory (actually, last time I did this, the data access layer instantiated and populated those objects by reflection, and EF does something similar for you). That means that you can do a single query, pull the query results into memory and create a list of data objects without repeatedly accessing the data source.

Then, if those data objects weren't sufficient for what I actually wanted in my application object model, I'd have the application objects take the relevant data objects as constructor parameters.

In the past, though, I have had application objects directly take the data source (a byte array) as a constructor parameter, because in that case the data source was zero cost so the extra indirection wasn't worth it.
QuestionDictionary object (need logic) in C# Pin
Member 89377326-May-12 23:05
Member 89377326-May-12 23:05 
GeneralRe: Dictionary object (need logic) in C# Pin
harold aptroot7-May-12 0:38
harold aptroot7-May-12 0:38 
AnswerRe: Dictionary object (need logic) in C# Pin
Maciej Los7-May-12 1:22
mveMaciej Los7-May-12 1:22 
GeneralRe: Dictionary object (need logic) in C# Pin
Manfred Rudolf Bihy7-May-12 2:30
professionalManfred Rudolf Bihy7-May-12 2:30 
QuestionVertexBuffer for collection of vertex Pin
ITSparrow6-May-12 6:56
ITSparrow6-May-12 6:56 
AnswerRe: VertexBuffer for collection of vertex Pin
Luc Pattyn6-May-12 10:25
sitebuilderLuc Pattyn6-May-12 10:25 
QuestionLooping based on user input Pin
abollmeyer6-May-12 4:08
abollmeyer6-May-12 4:08 
AnswerRe: Looping based on user input Pin
Richard MacCutchan6-May-12 4:21
mveRichard MacCutchan6-May-12 4:21 
NewsN Queen algorithm design Pin
ShomaL University of AMOL5-May-12 22:45
ShomaL University of AMOL5-May-12 22:45 
AnswerRe: N Queen algorithm design Pin
Sandeep Mewara5-May-12 23:21
mveSandeep Mewara5-May-12 23:21 
GeneralRe: N Queen algorithm design Pin
Richard MacCutchan6-May-12 1:38
mveRichard MacCutchan6-May-12 1:38 
GeneralMy Vote of 1 PinPopular
Keith Barrow6-May-12 2:30
professionalKeith Barrow6-May-12 2:30 
GeneralRe: N Queen algorithm design Pin
PIEBALDconsult6-May-12 5:35
professionalPIEBALDconsult6-May-12 5:35 
QuestionImage Encryption Pin
Danial C5-May-12 21:41
Danial C5-May-12 21:41 
AnswerRe: Image Encryption Pin
Sandeep Mewara5-May-12 23:24
mveSandeep Mewara5-May-12 23:24 
QuestionProblems with PathGeometry Pin
gabriel1235-May-12 18:28
gabriel1235-May-12 18:28 
AnswerRe: Problems with PathGeometry Pin
Sandeep Mewara6-May-12 1:23
mveSandeep Mewara6-May-12 1:23 

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.