On the evilness of parameterless default properties…

Apropos of the previous entry, I should add that I agree wholeheartedly with Eric’s contention that parameterless default properties were almost entirely evil. They did make working with some objects much easier, but they came at such a cost of understandability that I don’t believe that, in the end, they were worth it. When I started working on the VB compiler as we were porting to .NET, I tried to get a coherent explanation of exactly how parameterless default properties worked, especially in situations like functions that returned objects that had parameterless default properties that returned objects that had parameterless default properties, etc. Although there was a document that purported to show how it was all supposed to work, I believe the document was demonstrably wrong. In fact, I think the only real “documentation” for the behavior was the code itself. (I’m not even sure the developer working on the code could explain how it really worked in practice.) I wasn’t sad to see them go.

I part ways with Eric, though, on default properties with parameters. I think they’re incredibly useful and don’t agree with the C# philosophy of only allowing a single “indexer.” Maybe the C# brainwashing has already begun… <g>

3 thoughts on “On the evilness of parameterless default properties…

    1. Julius

      It does, but you can only use a specific set and order of parameters once. That is, you can’t have two C# indexers that take a string, but you can have one that takes a string and one that takes an integer.

      Reply

Leave a Reply to Julius Cancel reply

Your email address will not be published. Required fields are marked *