Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: Adding Forms to TabControl Pin
BobJanova11-Jul-12 23:29
BobJanova11-Jul-12 23:29 
GeneralRe: Adding Forms to TabControl Pin
AmbiguousName12-Jul-12 0:13
AmbiguousName12-Jul-12 0:13 
GeneralRe: Adding Forms to TabControl Pin
BobJanova12-Jul-12 4:05
BobJanova12-Jul-12 4:05 
GeneralRe: Adding Forms to TabControl Pin
AmbiguousName12-Jul-12 20:11
AmbiguousName12-Jul-12 20:11 
GeneralExposing a queue as a public property Pin
JoeRip11-Jul-12 17:44
JoeRip11-Jul-12 17:44 
GeneralRe: Exposing a queue as a public property Pin
PIEBALDconsult11-Jul-12 19:50
mvePIEBALDconsult11-Jul-12 19:50 
GeneralRe: Exposing a queue as a public property Pin
Abhinav S11-Jul-12 19:59
Abhinav S11-Jul-12 19:59 
GeneralRe: Exposing a queue as a public property Pin
BobJanova11-Jul-12 23:27
BobJanova11-Jul-12 23:27 
Exposing any collection as a public property means that you lose control over the collection, because the calling class can push, pop and inspect items in the collection. It also potentially causes synchronisation issues if you use that collection within your own code and expect it to be unchanging (in particular, if you enumerate over it).

I won't say 'don't do it', because it's often extremely convenient to do so, at least with a list where you want to provide access and you don't want to write a bunch of pointless IList wrapper methods to protect it. (With a queue, chances are all you want to allow the caller to do is add to it, so in that case I would write a wrapper method so I could use something other than a queue later.) But if you do expose a collection, make sure you put a note of caution about how a caller should use it in the documentation, and remember that you're relying on the end user being responsible.

If you do choose to expose a collection, it's generally better to expose it as the relevant interface instead of the concrete class, since the Framework provides both. That allows you to change your underlying data structure in future, and expose a shim that supports the interface and maps to whatever you now use.

None of this has anything to do with generics, by the way. It is exposing collections to the outside that you should be wary of.
GeneralRe: Exposing a queue as a public property Pin
JoeRip12-Jul-12 6:58
JoeRip12-Jul-12 6:58 
GeneralRe: Exposing a queue as a public property Pin
BobJanova12-Jul-12 23:41
BobJanova12-Jul-12 23:41 
GeneralRe: Exposing a queue as a public property Pin
PIEBALDconsult13-Jul-12 3:44
mvePIEBALDconsult13-Jul-12 3:44 
GeneralRe: Exposing a queue as a public property Pin
JoeRip13-Jul-12 8:35
JoeRip13-Jul-12 8:35 
GeneralRe: Exposing a queue as a public property Pin
PIEBALDconsult14-Jul-12 4:13
mvePIEBALDconsult14-Jul-12 4:13 
QuestionPost build event using XML Pin
manishsaiin11-Jul-12 5:58
manishsaiin11-Jul-12 5:58 
AnswerRe: Post build event using XML Pin
Dave Kreskowiak11-Jul-12 7:03
mveDave Kreskowiak11-Jul-12 7:03 
AnswerRe: Post build event using XML Pin
eupendra15-Jul-12 18:58
eupendra15-Jul-12 18:58 
QuestionAn unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code Pin
manikantaer11-Jul-12 2:40
manikantaer11-Jul-12 2:40 
AnswerRe: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code Pin
BobJanova11-Jul-12 2:45
BobJanova11-Jul-12 2:45 
GeneralRe: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code Pin
manikantaer11-Jul-12 17:45
manikantaer11-Jul-12 17:45 
AnswerRe: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code Pin
Wes Aday11-Jul-12 3:03
professionalWes Aday11-Jul-12 3:03 
AnswerRe: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code Pin
Dave Kreskowiak11-Jul-12 4:29
mveDave Kreskowiak11-Jul-12 4:29 
AnswerRe: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code Pin
Luc Pattyn11-Jul-12 4:46
sitebuilderLuc Pattyn11-Jul-12 4:46 
QuestionException: Syntax Error in INSERT TO. Pin
kaycey9011-Jul-12 2:37
kaycey9011-Jul-12 2:37 
AnswerRe: Exception: Syntax Error in INSERT TO. Pin
Pete O'Hanlon11-Jul-12 2:42
mvePete O'Hanlon11-Jul-12 2:42 
AnswerRe: Exception: Syntax Error in INSERT TO. Pin
BobJanova11-Jul-12 2:43
BobJanova11-Jul-12 2:43 

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.