|
-
May 11th, 2016, 12:45 PM
#6
Re: Trying to understand Collections
 Originally Posted by Poppa Mintin
Thanks for the rapid reply Techgnome,
The 'Key' and 'Value' aspect of Collections just happens to be. All I'm trying to do is keep a pair of data together so that in whatever order I pull 'em back out they're still the right pair.
I'm going to have a play with your suggestion... Sadly not just now... SWMBO has other ideas.
Poppa.
So it's just a pair of values? not a key/value pair?
Two things: 1) create a class that has two properties Thing1, Thing2 ... then make a List(of Things1_2) ... or 2) use a tuple and a List (Of Tuple) ...
 Originally Posted by Sitten Spynne
The reason it's so confusing is VB chose the wrong name when it chose "Collections", and it got more confusing when MS 'fixed' the definition in .NET. The word "collection" was a bad idea on both counts.
The rest of the programming world calls this type of data structure an "associative array", "hashtable", or "dictionary". All of them have the sense of "a value is associated with a unique key, and the key is used to reference values." Sometimes VB is different because it simplifies concepts. In this case, I think VB was different for the sake of being different. (We're talking the context of VB6 and previous, here.)
When MS laid the foundations for .NET, they decided they should probably name things what non-.NET developers would understand. So we end up with a lot of words meaning weird things.
- A 'collection' to .NET is just "a variable that represents many values". For almost all intents and purposes, IEnumerable is the /actual/ abstract concept of a .NET collection. But because of the former statement, .NET has a 'System.Collections' and 'System.Collections.Generic' namespace.
- A CollectionBase class exists. It's purpose isn't explicitly clear, and if you look through the classes that derive from it you won't find many familiar types. It's vestigal and obsolete. It's not even a good base collection type for anything but a list. Whoops.
- The VB Collection type is implemented in the VB6 compatibility libraries. It's there to help interviewers distinguish between .NET developers and people who write VB6 in .NET.
- MS recognized their error, and since about 2005 it's safe to say "Almost no .NET collection derives from CollectionBase at all, but we're stuck with calling these things 'collection types'."
- Because in the Microsoft world, nothing can ever be deleted, even if it's 30 years old and sets your computer on fire when used, almost 50% of the .NET collection types are obsolete traps with new, better replacements, and any time you spend studying them is a waste. Which 50%? Mostly what lives in System.Collections, the MOST OBVIOUS NAMESPACE.
Everyone else is happy calling the whole topic "data structures" and most other languages weren't arrogant enough to assert they could make one base type that represents all data structures. IEnumerable is the closest we get to that concept.
hehehe... now try to explain tuples... 
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|