C#/ / .NET Observation
-
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFiles -
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesHashtable? How quaint. Dictionary<TKey, TValue>, hours of abuse :)
I'm largely language agnostic
After a while they all bug me :doh:
-
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesJames R. Twine wrote:
Is it just me, or does anyone else notice that as well?
I haven't seen it yet, but the day is still young and i still have a great deal of code to review. :sigh: FWIW, i use
std::map
andstd::multimap
frequently. Very handy templates. -
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesA lot of developers learn by copy-and-paste and have not been exposed to the other collection options in .NET. Personally, my predominate collection type is the generic List<>. In the .NET environment the efficiency is close so many choose the hash incorrectly thinking it does not matter. I have many discussions with Junior developers about the importance of order in certain sets. Most of which falls on deaf ears until something blows up in there face.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway -
A lot of developers learn by copy-and-paste and have not been exposed to the other collection options in .NET. Personally, my predominate collection type is the generic List<>. In the .NET environment the efficiency is close so many choose the hash incorrectly thinking it does not matter. I have many discussions with Junior developers about the importance of order in certain sets. Most of which falls on deaf ears until something blows up in there face.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest HemingwayI agree, I use List<> frequently when order is not an issue. I seldom use Hashtable unless both key and value are both of type Object, which is exceptionally rare. Usually I know what the key is going to be. I remember one developer got stumped on some of my code when they encountered a linked list, I was forced to refactor it to a much less elegant solution! I can also remember when a migrating VB 'developer' told me "I hate arrays, arrays are hard and multi-dimensional arrays are impossible, I never use them". Still makes me smile thinking about it.
I'm largely language agnostic
After a while they all bug me :doh:
-
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesWhen I was working with C# before happily returning back to C++ one thing I noticed being *really* abused was the reflection. I understand there are valid uses of reflection/introspection - mostly for the dev tools and code analysis - but creating the complete UI out of some crazy XML files with reflection was simply wrong - it made the application less robust and it would take forever to start.
-
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesI have never knowingly used a hashtable in C#, and I stayed as far away as possible from STL when I was doing C++.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesHmm, I've never used an
Hashtable
explicitly myself, but I useDictionary<TKey, TValue>
quite often, as well asList<T>
. Could you provide some example (not code, just scenarios, otherwise we'd hurt the feelings of the lounge)?If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker My Photos/CP Flickr Group - ScrewTurn Wiki
-
When I was working with C# before happily returning back to C++ one thing I noticed being *really* abused was the reflection. I understand there are valid uses of reflection/introspection - mostly for the dev tools and code analysis - but creating the complete UI out of some crazy XML files with reflection was simply wrong - it made the application less robust and it would take forever to start.
Nemanja Trifunovic wrote:
but creating the complete UI out of some crazy XML files with reflection was simply wrong - it made the application less robust and it would take forever to start.
:~ :-D Marc
-
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesprotected KeyedList<ViewListenerKey, List<SessionContainerListener>> viewListeners;
protected KeyedList<ViewListenerKey, ViewKeyData> viewKeyData;
protected KeyedList<SessionContainerViewListenerKey, List<DataTable>> sessionTransactions;Run. Don't walk, run. :-D Marc
-
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesIt does not surprise me that people did not use std::map, most people simply used CArray and didn't move beyond that. Personally, I used std::map all the time, although not for collections of numbers or collections of 5 objects :-) The syndrome is the same in both cases, only a subset of the people using a language are interested in learning to use it well.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
As I now need to start getting into C# after a very happy and fruitful live with C++, I have noticed something and wanted to know if any other pre-C#/.NET developers have noticed the same thing. I have seen LOTS of uses of the
Hashtable
type - far more than I would expect. And in places where I would not normally expect. For example, I have seen keys like "1
", "2
", "3
", etc. (i.e. simple indexers), or seen them used for collections of less than 5 items or so. It just seems a bit weird to me - I mean,std::map
andstd::multimap
have been around for a number of years, and I have seen plenty of complex systems that rarely used them. But now I see the simplest systems _(ab)_useHashtable
. Is it just me, or does anyone else notice that as well? I am not sure if it is the child with a hammer syndrome or not... What do you think? Peace!-=- James
Please rate this message - let me know if I helped or not! * * *
If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
See DeleteFXPFilesJames R. Twine wrote:
I have seen LOTS of uses of the Hashtable type
In Pre .NET 2.0 code. 2.0 introduced Generics and everything collection wise changed drastically. All old collection code should be migrated to using Generics, well there are exceptions of course but as a rule of thumb, just do it. So stop looking at 1.X code. ;P
led mike
-
It does not surprise me that people did not use std::map, most people simply used CArray and didn't move beyond that. Personally, I used std::map all the time, although not for collections of numbers or collections of 5 objects :-) The syndrome is the same in both cases, only a subset of the people using a language are interested in learning to use it well.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
It's not just the abuse of reflection which is abundant but as mentioned blind 'hey it'll handle it for me' CLR collection following and not understanding how expensive those, default and often dev induced, lousy Equality tests are. There is much hacking there and MS attempting to fix by-large an inefficient and at times broken model. It isn't funny, IEquatable, IComparable, casts, boxing even when many think they are avoiding it, virtual dispatch, devs not understanding good hash impls, you name it. I mean it is obvious when a C# guy asks for VB.NET to be converted and vice versa. And I agree whenever a return to C++ is due, it ends up always refreshing. Even if you have no System.Object, KeyValueDictionary generic is involved in hash as well, it makes most of the code involved, or better put modeling/naming with it suck too ( Heck the hash in object is the Java idea, but I'll agree hash has its purposes and at least one dynamic language implementation excels on it). Anyway, after 7 years of working with collections in .NET I think it just shows how badly the entire show is for Key/Value, value vs reference, and runtime binding.. Don't even get me on multiple inheritance, something no matter what runtime zealots say is bad, it just blasts away all key/value attempts to 100% .NET runtime blindess. It is all meant to be about building types, but when you look at it CLR/Java mentality prefers to get a guy thinking he is up and running quick and cool. And after a while you just see the effect it has on software quality: Incorectness/incompleteness, RAM and CPU over-utilisation.
-
It's not just the abuse of reflection which is abundant but as mentioned blind 'hey it'll handle it for me' CLR collection following and not understanding how expensive those, default and often dev induced, lousy Equality tests are. There is much hacking there and MS attempting to fix by-large an inefficient and at times broken model. It isn't funny, IEquatable, IComparable, casts, boxing even when many think they are avoiding it, virtual dispatch, devs not understanding good hash impls, you name it. I mean it is obvious when a C# guy asks for VB.NET to be converted and vice versa. And I agree whenever a return to C++ is due, it ends up always refreshing. Even if you have no System.Object, KeyValueDictionary generic is involved in hash as well, it makes most of the code involved, or better put modeling/naming with it suck too ( Heck the hash in object is the Java idea, but I'll agree hash has its purposes and at least one dynamic language implementation excels on it). Anyway, after 7 years of working with collections in .NET I think it just shows how badly the entire show is for Key/Value, value vs reference, and runtime binding.. Don't even get me on multiple inheritance, something no matter what runtime zealots say is bad, it just blasts away all key/value attempts to 100% .NET runtime blindess. It is all meant to be about building types, but when you look at it CLR/Java mentality prefers to get a guy thinking he is up and running quick and cool. And after a while you just see the effect it has on software quality: Incorectness/incompleteness, RAM and CPU over-utilisation.
-
User of Users Group wrote:
and MS attempting to fix by-large an inefficient and at times broken model.
Mostly the model is broken by the loose nut between the chair and the keyboard.
led mike
Yeah right, I can see your post below and you are probably not aware (or the guy voting you 5, plenty of those runtime lovers around) most of those Generics still use the hash (and some broken/unchecked runtime comparisons if you prefer), it has nothing to do with 1.1 :) Besides when they initially did that Rotor hack in MSR, many people in languages field (and less broken models) just went: *sigh*. Generics (List and some other bits aside) are so weak in comparison to alternatives by not just C++, it doesn't surprise me to see people believe they are sooo, oh soo 'powerful', or thinking that by default they really eliminate boxing or virtual dispatch (that is the type responsibility and implementing one as complete as MS does for its own, shows you how much bloat is involved to express a simple primitive).
modified on Thursday, January 31, 2008 3:07:44 PM
-
When I was working with C# before happily returning back to C++ one thing I noticed being *really* abused was the reflection. I understand there are valid uses of reflection/introspection - mostly for the dev tools and code analysis - but creating the complete UI out of some crazy XML files with reflection was simply wrong - it made the application less robust and it would take forever to start.
Nemanja Trifunovic wrote:
but creating the complete UI out of some crazy XML files with reflection was simply wrong
(cough)XAML(cough)(gag)(spittle)
¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog
-
I have never knowingly used a hashtable in C#, and I stayed as far away as possible from STL when I was doing C++.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001Why? Associative arrays have all sort of legitimate uses. Why wouldn't you use them?
¡El diablo está en mis pantalones! ¡Mire, mire! Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog
-
Yeah right, I can see your post below and you are probably not aware (or the guy voting you 5, plenty of those runtime lovers around) most of those Generics still use the hash (and some broken/unchecked runtime comparisons if you prefer), it has nothing to do with 1.1 :) Besides when they initially did that Rotor hack in MSR, many people in languages field (and less broken models) just went: *sigh*. Generics (List and some other bits aside) are so weak in comparison to alternatives by not just C++, it doesn't surprise me to see people believe they are sooo, oh soo 'powerful', or thinking that by default they really eliminate boxing or virtual dispatch (that is the type responsibility and implementing one as complete as MS does for its own, shows you how much bloat is involved to express a simple primitive).
modified on Thursday, January 31, 2008 3:07:44 PM
User of Users Group wrote:
Generics still use the hash
Yes i reacted to
Hashtable
and apparently missed the overall point of the thread, oops :doh:User of Users Group wrote:
it has nothing to do with 1.1
Of course since i missed the point I was talking about this.[^] Generics are the most powerful feature of C# 2.0. Generics allow you to define type-safe data structures, without committing to actual data types. This results in a significant performance boost and higher quality code, because you get to reuse data processing algorithms without duplicating type-specific code. and[^] Collision Resolution in the Dictionary Class
The Dictionary class differs from the Hashtable class in more ways than one. In addition to being strongly-typed, the Dictionary also employs a different collision resolution strategy than the Hashtable class, using a technique referred to as chaining. Recall that with probing, in the event of a collision another slot in the list of buckets is tried. (With rehashing, the hash is recomputed, and that new slot is tried.) With chaining, however, a secondary data structure is utilized to hold any collisions. Specifically, each slot in the Dictionary has an array of elements that map to that bucket. In the event of a collision, the colliding element is prepended to the bucket's list.
User of Users Group wrote:
you are probably not aware
If and when that is true, I don't know nor will I ever know everything, I am the loose nut breaking things. You might have read my initial post as excluding myself as the nut causing the problems, not so.
Last modified: 31mins after originally posted --
-
Yeah right, I can see your post below and you are probably not aware (or the guy voting you 5, plenty of those runtime lovers around) most of those Generics still use the hash (and some broken/unchecked runtime comparisons if you prefer), it has nothing to do with 1.1 :) Besides when they initially did that Rotor hack in MSR, many people in languages field (and less broken models) just went: *sigh*. Generics (List and some other bits aside) are so weak in comparison to alternatives by not just C++, it doesn't surprise me to see people believe they are sooo, oh soo 'powerful', or thinking that by default they really eliminate boxing or virtual dispatch (that is the type responsibility and implementing one as complete as MS does for its own, shows you how much bloat is involved to express a simple primitive).
modified on Thursday, January 31, 2008 3:07:44 PM
User of Users Group wrote:
or the guy voting you 5, plenty of those runtime lovers around)
actually the guy voting him a 5 may support the statement but not the stance... ;) often cases, most models, in mosts languages, are broken by the nut behind the keyboard. The result is often something that works small but doesn't scale, or that needs rewriting consistently over years, or any number of other things that happen to it. supporting that statement neither supports nor refutes the use of generics, lambda operations or any number of newer language features over the years. Almost anything "can" be used for good, but usually the nut behind the keyboard is holding back either C++ or C# or even any other language you or I or the world can invent. :-D :-D
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
-
James R. Twine wrote:
I have seen LOTS of uses of the Hashtable type
In Pre .NET 2.0 code. 2.0 introduced Generics and everything collection wise changed drastically. All old collection code should be migrated to using Generics, well there are exceptions of course but as a rule of thumb, just do it. So stop looking at 1.X code. ;P
led mike
Plenty of loose nuts in ASP.NET source, WPF dragging itself, and default provision of method implementation by CLR in many, many types :-) Go on, look at their source, use shift operator on the bits, all in an idea of runtime that is supposed to abstract blitting and bits.. You'll end up with Java or Java IDE feeling when users stress your app, reasons are outlined in that generic, one that cannot even properly compare value types, and frankly that is a disaster, mass-market, language design, Anders Legend-Lover or not. But you knew that anyway..