Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • No @arunmur. There was a misunderstanding here. By DRY, I meant using (Entities entities = new Entities()) block. I mean, this line of code is repeated 100 times and is getting repeated more and more. Commented Aug 26, 2011 at 12:23
  • DRY primarily comes from the fact that you need to write test cases that many times and a bug at one place means you have to fix it at 100 places. The using(Entities ...) is too simple a code to break. It does not need to be split or put in another class. If you still insist on simplifying it. I would suggest a Yeild call back function from ruby. Commented Aug 26, 2011 at 13:17
  • 1
    @arnumur - using is not always too simple to break. I often have a good bit of logic that determines which options to use on the data context. It is very possible that the wrong connection string could be passed in. Commented Aug 26, 2011 at 13:28
  • 1
    @ironcode - In those situations it makes sense to push it off to a function. But in these examples its pretty tough to break. Even if it does break the fix is often in the definition of the Entities class itself, which should be covered with a separate test case. Commented Aug 26, 2011 at 14:47
  • +1 @arunmur - I agree. I usually do that myself. I write tests for that function, but it does seem a bit over the top to write a test for your using statement. Commented Aug 26, 2011 at 16:49