I was also a bit surprised by that statement (read it in Juval's excellent
"Programming .NET Components").
Having said that, I do put a massive number of assertions in my code
compared to my peers (though not as much as 20% of lines!). The bottom line
is that many bugs in my code get caught and pinpointed very quickly, and it
serves to make my code generally far more reliable than that of my peers
IMHO. Also, combined with genuinely meaningful error messages, it means that
when other developers use my components and have not RTFM (OK, RTF C#
XML/NDoc documentation) it tells them precisely what they have done wrong
and they don't come to me telling me that my component has a "bug".
It does clutter source code, but #region/#endregion is your friend.
"Jefffff" <A@B.COM> wrote in message
news:u5r$dceUGHA.5044@TK2MSFTNGP09.phx.gbl...[color=blue]
> Regarding the use of assertions:
> According to Juval Lowy's excellent coding standards document (PDF
> download available at
www.idesign.net), every assumption in your code
> should have an assertion... and on average, every 5th line is an
> assertion.
>
> My question:
> Do any of you include that many assertions? I agree in principle that we
> should code defensively, but his recommendation just seems to go
> "overboard" and would result in a lot of bloated code. If followed, the
> recommendation would result in something like 20% more code.
>
> Thoughts? Opionions? Perspective?
>
> Thanks!
>[/color]