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

C#

 
GeneralRe: Help with generics Pin
GuimaSun22-Apr-09 9:30
GuimaSun22-Apr-09 9:30 
GeneralRe: Help with generics Pin
0x3c022-Apr-09 9:52
0x3c022-Apr-09 9:52 
GeneralRe: Help with generics Pin
GuimaSun22-Apr-09 9:56
GuimaSun22-Apr-09 9:56 
GeneralRe: Help with generics Pin
Thomas Weller22-Apr-09 20:22
Thomas Weller22-Apr-09 20:22 
GeneralRe: Help with generics Pin
0x3c022-Apr-09 9:30
0x3c022-Apr-09 9:30 
Questionpublically readonly but internally writable objects? Pin
student_rhr22-Apr-09 7:43
student_rhr22-Apr-09 7:43 
AnswerRe: publically readonly but internally writable objects? Pin
harold aptroot22-Apr-09 7:49
harold aptroot22-Apr-09 7:49 
AnswerRe: publically readonly but internally writable objects? Pin
Thomas Weller22-Apr-09 8:33
Thomas Weller22-Apr-09 8:33 
student_rhr wrote:
I was just wondering if there is a preferred way of dealing with situations like these

There are three ways (that I know of... Smile | :) ):
1.
Create an interface that only declares the elements (e.g. property getters) that the UI should see. 'Implement' it on the class of interest (actually you only have to declare it). Then pass this interface around instead of the 'real' object.
2.
Implement the Data Transfer Object design pattern to handle the situation. It is described here^. In
short, this method declares a struct or immutable class with all the data of interest, and if you have to pass around
these data you create such an object (with a copy of the relevant data) for this purpose.
3.
Declare the objects property setters and methods (if they are able to change the objects state) as internal, everything else as public. 'Internal' means exactly that: Public for everything inside the same assembly, invisible for everything outside.

What best suits your needs depends on your overall architecture and the situation...

Hope this helps.

Regards
Thomas

www.thomas-weller.de

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Programmer - an organism that turns coffee into software.


AnswerRe: publically readonly but internally writable objects? Pin
0x3c022-Apr-09 8:36
0x3c022-Apr-09 8:36 
QuestionSerialization and ViewState Pin
Fayu22-Apr-09 7:11
Fayu22-Apr-09 7:11 
AnswerRe: Serialization and ViewState Pin
Fayu22-Apr-09 7:25
Fayu22-Apr-09 7:25 
GeneralRe: Serialization and ViewState Pin
OriginalGriff22-Apr-09 9:17
mveOriginalGriff22-Apr-09 9:17 
GeneralRe: Serialization and ViewState Pin
Fayu22-Apr-09 9:33
Fayu22-Apr-09 9:33 
GeneralRe: Serialization and ViewState Pin
OriginalGriff22-Apr-09 21:43
mveOriginalGriff22-Apr-09 21:43 
QuestionJust for fun - how slow are exceptions? Pin
Rob Philpott22-Apr-09 6:12
Rob Philpott22-Apr-09 6:12 
AnswerRe: Just for fun - how slow are exceptions? Pin
Eddy Vluggen22-Apr-09 6:24
professionalEddy Vluggen22-Apr-09 6:24 
GeneralRe: Just for fun - how slow are exceptions? Pin
Rob Philpott22-Apr-09 6:38
Rob Philpott22-Apr-09 6:38 
GeneralRe: Just for fun - how slow are exceptions? Pin
Eddy Vluggen22-Apr-09 6:45
professionalEddy Vluggen22-Apr-09 6:45 
GeneralRe: Just for fun - how slow are exceptions? Pin
Luc Pattyn22-Apr-09 6:46
sitebuilderLuc Pattyn22-Apr-09 6:46 
GeneralRe: Just for fun - how slow are exceptions? Pin
Rob Philpott22-Apr-09 6:50
Rob Philpott22-Apr-09 6:50 
GeneralRe: Just for fun - how slow are exceptions? Pin
Luc Pattyn22-Apr-09 6:54
sitebuilderLuc Pattyn22-Apr-09 6:54 
AnswerRe: Just for fun - how slow are exceptions? Pin
Luc Pattyn22-Apr-09 6:31
sitebuilderLuc Pattyn22-Apr-09 6:31 
GeneralRe: Just for fun - how slow are exceptions? Pin
Rob Philpott22-Apr-09 6:33
Rob Philpott22-Apr-09 6:33 
GeneralRe: Just for fun - how slow are exceptions? Pin
Rob Philpott22-Apr-09 6:41
Rob Philpott22-Apr-09 6:41 
GeneralRe: Just for fun - how slow are exceptions? Pin
Skymir23-Apr-09 2:58
Skymir23-Apr-09 2:58 

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.