Click here to Skip to main content
15,888,733 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: lock Pin
Covean29-Apr-10 6:13
Covean29-Apr-10 6:13 
GeneralRe: lock Pin
supercat929-Apr-10 9:11
supercat929-Apr-10 9:11 
GeneralRe: lock Pin
Luc Pattyn29-Apr-10 9:38
sitebuilderLuc Pattyn29-Apr-10 9:38 
GeneralRe: lock Pin
supercat929-Apr-10 13:10
supercat929-Apr-10 13:10 
GeneralRe: lock Pin
Luc Pattyn29-Apr-10 13:56
sitebuilderLuc Pattyn29-Apr-10 13:56 
GeneralRe: lock Pin
supercat930-Apr-10 5:02
supercat930-Apr-10 5:02 
GeneralRe: lock Pin
Luc Pattyn30-Apr-10 5:19
sitebuilderLuc Pattyn30-Apr-10 5:19 
GeneralEnumerators Pin
supercat930-Apr-10 6:12
supercat930-Apr-10 6:12 
The way I see it, the programmer needs to be able to predict the behavior, so he can code accordingly. With a more complex behavior a class would risk to be less popular and/or lead to accidents, such as unexpected exceptions (because the user did not understand the contract well).



I guess I don't really see a whole lot of situations where the exception behavior is more useful than the behavior I described, especially since--if iEnumerator provided a collectionChanged property--one could code a generic class that, given an iEnumerator(of T), would implement iEnumerator(of T) but throw an exception if an effort was made to fetch an item after the underlying class had changed. Thus, if one wanted to have a "For Each" loop that would throw an exception if the collection changed, one could write:

For Each myThing as myClass in New ProtectedEnumerable(myCollection)
  ...
EndIf

Since one new generic ProtectedEnumerable() class could make any iEnumerable implement the present more-strict contract, I would think the less strict contract would be more useful.

If it were possible to simply implement and use an iNiceEnumerable which followed a different contract, I wouldn't mind the behavior of iEnumerable. As it is, however, iEnumerable and iDisposable are both hard-coded into the compilers for C# and VB.net; if a collection doesn't implement an interface which is called iEnumerable, it can't be used with for-each loop. Even if it would be useful to have an interface defined that implements Microsoft's strict contract, I don't think it's very nice to declare that only interfaces that adhere to that strict contract should be used in for-each loops.

Also, with regard to programmer confusion, it seems far less confusing to say that one must use certain collection types if one is going to modify a collection during enumeration, than to say that one must write enumeration code as:
Using MyNiceEnum as iNiceEnum(of MyThing) = myNiceCollection.GetNiceEnum
  Dim MyItem as MyThing
  While MyNiceEnum.GetNext
    MyItem = MyNiceEnum.TheItem
    .. Do something with MyItem
  End While
End Using

as opposed to:
For Each MyItem in myNiceCollection
  .. Do something with MyItem
Next

GeneralRe: Enumerators Pin
Luc Pattyn30-Apr-10 9:18
sitebuilderLuc Pattyn30-Apr-10 9:18 
GeneralRe: Enumerators Pin
supercat930-Apr-10 11:31
supercat930-Apr-10 11:31 
QuestionReference a .NET 3.5 assembly form a .NET 2.0 other assembly: in VS2008 ok, not in VS2010 Pin
Ferdinando Santacroce29-Apr-10 3:22
Ferdinando Santacroce29-Apr-10 3:22 
AnswerRe: Reference a .NET 3.5 assembly form a .NET 2.0 other assembly: in VS2008 ok, not in VS2010 Pin
Not Active29-Apr-10 3:35
mentorNot Active29-Apr-10 3:35 
GeneralRe: Reference a .NET 3.5 assembly form a .NET 2.0 other assembly: in VS2008 ok, not in VS2010 Pin
Luc Pattyn29-Apr-10 4:18
sitebuilderLuc Pattyn29-Apr-10 4:18 
AnswerRe: Reference a .NET 3.5 assembly form a .NET 2.0 other assembly: in VS2008 ok, not in VS2010 Pin
Ferdinando Santacroce29-Apr-10 5:54
Ferdinando Santacroce29-Apr-10 5:54 
QuestionAny Problem with VS 2010 Ultimate? if VS 2008 already exists.. Pin
yadlaprasad29-Apr-10 1:26
yadlaprasad29-Apr-10 1:26 
AnswerRe: Any Problem with VS 2010 Ultimate? if VS 2008 already exists.. Pin
Michel Godfroid29-Apr-10 1:47
Michel Godfroid29-Apr-10 1:47 
AnswerRe: Any Problem with VS 2010 Ultimate? if VS 2008 already exists.. Pin
Not Active29-Apr-10 1:56
mentorNot Active29-Apr-10 1:56 
QuestionSetting DisplayMember & ValueMember with DataTable Pin
massaslayer28-Apr-10 10:21
massaslayer28-Apr-10 10:21 
AnswerRe: Setting DisplayMember & ValueMember with DataTable Pin
Ashfield29-Apr-10 3:39
Ashfield29-Apr-10 3:39 
Questionlinking two tables Pin
kolisa28-Apr-10 1:29
kolisa28-Apr-10 1:29 
AnswerRe: linking two tables Pin
Dave Kreskowiak28-Apr-10 2:17
mveDave Kreskowiak28-Apr-10 2:17 
AnswerRe: linking two tables Pin
Abhinav S28-Apr-10 5:51
Abhinav S28-Apr-10 5:51 
AnswerRe: linking two tables Pin
GauravKP28-Apr-10 9:36
professionalGauravKP28-Apr-10 9:36 
AnswerRe: linking two tables Pin
Peace ON29-Apr-10 1:12
Peace ON29-Apr-10 1:12 
Questionmac number of client system Pin
Gayathri devi sivanesan27-Apr-10 23:24
Gayathri devi sivanesan27-Apr-10 23:24 

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.