tag:blogger.com,1999:blog-4548789926995192649.post1397988353454057731..comments2024-03-11T10:37:42.281+00:00Comments on Paul Grenyer: Review of Effective C# Item 15: Utilize using and try-finally for Resource Clean-upPaul Grenyerhttp://www.blogger.com/profile/18212226926099615757noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-4548789926995192649.post-9275065649924242912011-11-20T02:27:27.282+00:002011-11-20T02:27:27.282+00:00Also, Dispose is allowed to throw, so the hand-rol...Also, Dispose is allowed to throw, so the hand-rolled try finally is technically, as well as aestetically inferior...<br /><br />This is one area where Java actually kind of wins, well, if you count lombok as part of Java:<br /><br />@Cleanup Connection connection = foo;<br />@Cleanup Command comm = bar;<br /><br />Nice and clean :) Doesn't deal with scoping, but hey, your methods are small enough that that doesn't matter, right? ;)dwhhttps://www.blogger.com/profile/12332997327400801002noreply@blogger.comtag:blogger.com,1999:blog-4548789926995192649.post-46492871032041465632011-11-17T19:53:43.232+00:002011-11-17T19:53:43.232+00:00Yes, Steve Love also suggested it and I thought I&...Yes, Steve Love also suggested it and I thought I'd made reference to that. I don't like the clumsy way I feel it looks.Paul Grenyerhttps://www.blogger.com/profile/18212226926099615757noreply@blogger.comtag:blogger.com,1999:blog-4548789926995192649.post-63290534339486123772011-11-17T18:06:11.197+00:002011-11-17T18:06:11.197+00:00I know I've directed you to one of my older bl...I know I've directed you to one of my older blog posts on this matter before - on more than one occasion - I feel I should bring it up again since you missed my preferred way to handle the nesting problem with multiple using blocks - which is to just drop the nesting (and outer braces):<br /><br />Nuances here:<br />http://www.levelofindirection.com/journal/2009/9/24/raii-and-readability-in-c.htmlPhil Nashhttp://www.levelofindirection.comnoreply@blogger.com