• Labasta (unregistered)

    TRWTF is of course using ArrayList and not List, innit.

  • WTFGuy (unregistered)

    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.

  • Naomi (unregistered) in reply to Labasta

    This is C#, so it'd be IList, because I guess Microsoft likes Hungarian notation?

  • Bob (unregistered)

    The error is in the capitalization; they meant ThreadsAFearRay.

  • (nodebb) in reply to Naomi

    There exist the interfaces IList and IList<T>, but I think he was referring to List<T>, which is the implementation.

  • MaxiTB (unregistered) in reply to Naomi

    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.

  • (nodebb)

    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.

  • (nodebb)

    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.

  • (nodebb)

    Wait, how did we get from concurrency to cave diving, exactly?

  • David Mårtensson (unregistered) in reply to Naomi

    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 ;)

Leave a comment on “ThreadSafeArray”

Log In or post as a guest

Replying to comment #:

« Return to Article