Tuesday, October 2, 2007

Anonymous methods and maintainability

Anonymous methods are a cool language feature in C# 2.0. I'm not a big fan of using them but they are certainly useful in many scenarios. After reading some articles (here, here, here and here) I realized that even if you can write very elegant code using them, there is a real danger hiding behind the corner. The code might seem clear and obvious but subtle differences can have a huge effect on behavior. This is not always a problem but in some cases it will be. Somebody else will have to maintain your code. If the new guy is not aware of all those subtleties he will have hard time maintaining your code. A small change could break your code and it might be very difficult to find out why it's broken. Keep those unit tests up to date. Without them you are asking for trouble.  

 

Technorati Tags:

No comments:

Post a Comment