- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
TRWTF is of course using ArrayList and not List, innit.
Admin
Depends on when this code was written. I've been doing .Net from v1.1 which did not have List<T>. ArrayList was the "approved" solution for generic-ish handling of not completely homogenous collections. And of dynamically sized cpllections.
Should all that stuff have been updated sometime in the intervening 20 years? Sure. Has it been? Nope. Heck, this code may very well be "updated" in the sense that it's still in their source control (hah!), but is now called from nearly nowhere as all the newer code uses different .Net objects and / or different homebrew utility functions / classes. No doubt those are WTFs of their own, just different more modern WTFs.
Admin
This is C#, so it'd be
IList
, because I guess Microsoft likes Hungarian notation?Admin
The error is in the capitalization; they meant ThreadsAFearRay.
Admin
There exist the interfaces IList and IList<T>, but I think he was referring to List<T>, which is the implementation.
Admin
It has nothing to do with hungarian notation actually. The .net language designers back then saw the chaos in Java with the complete lack of naming conventions which pretty much exist to this day and they decided on strict naming rules from the beginning. Generally special types got a fully spelled out postfix like Exception or Attribute, in case of intrface this would be highly redundant so they went for the COM+ naming scheme, the only cross platform open standard for oo packages available back then.
Admin
This is good enough to usually work. It probably passed whatever testing was involved.
I suspect cargo cult programming--the code would be legit if you obtained a lock first. They didn't understand the lock and didn't copy it.
Admin
There is the weird idea floating around that eager locking makes code thread-safe, while the opposite is true - it makes it more prone to deadlocks and that is especially true in high concurrent environments. Proper modern concurrency handling is always done by optimistic approaches, as in assuming no conflict will happen, monitoring the results and rollback after a conflict actually happened. Eager locking is also super expensive resource-wise in comparison. Obviously the downside is that proper concurrency management is not hard, it is more complex and more effort - two things a lot of developers-in-name-only really hate because they chose the job for a quick, easy paycheck only.
Admin
Wait, how did we get from concurrency to cave diving, exactly?
Admin
Well, Microsoft invented Hungarian notation :)
Alltho it was the office team that invented it and they never intended it to be based on actual data types in the code but rather context types as in "outer margin pixes" or "inner margin pixel", other teams missinterpreted it and that version is the one that got spread to the rest of the world.
So "real" hungarian notation would be ompxWidth for outer margin width in pixels and not iWidth for intgeger Width ;)