﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Daniel Cazzulino commented on The buddy classes are drowning DRY</title><description>Why don't they just allow you to annotate the interface itself with the contracts rather than having to maintain the "buddy" ?
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment21</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment21</guid><pubDate>Tue, 16 Jun 2009 05:06:34 GMT</pubDate></item><item><title>ReSc commented on The buddy classes are drowning DRY</title><description>@ Daniel
  
To quote the post you link to: "Since interfaces cannot have a method body, we use a ‘buddy’ class to express those contracts".
  
  
So you only need to use a 'buddy' class for interfaces, classes don't need them, because there the contracts can be expressed in the methods directly, no buddy class needed.
  
  
and to top it off
  
 "All implementations of that particular interface will be instrumented with the runtime checks by the rewriter at compile time."
  
  
excellent DRY instead of buddy hell methinks... 
  
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment20</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment20</guid><pubDate>Sun, 31 May 2009 02:44:07 GMT</pubDate></item><item><title>Daniel Cazzulino commented on The buddy classes are drowning DRY</title><description>Want more buddy hell?
  
  
[blog.dotnetwiki.org/.../...odelsWithContracts.aspx](http://blog.dotnetwiki.org/2009/05/02/StubsAsParameterizedModelsWithContracts.aspx)  
  
Code contracts is another official feature coming out of MS that encourages the same practice.
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment19</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment19</guid><pubDate>Tue, 19 May 2009 14:10:23 GMT</pubDate></item><item><title>Brian Henderson commented on The buddy classes are drowning DRY</title><description>It's one thing to be lazy about design in writing application code; HOWEVER being lazy with Framework Design can lead to structural failures across many applications going forward.  Beyond the DRY rot, there is a serious loss in readability and communication of intent, as behavioral abstractions have leaked out of MyClass.
  
  
The CLI team needs to revisit Properties with .NET 5. The issue of tooling (IDE &amp; compiler) for Attributes and ChangeNotification (XAML binding) including wiring up events (particularly with partial classes).
  
  
  
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment18</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment18</guid><pubDate>Wed, 06 May 2009 03:58:50 GMT</pubDate></item><item><title>Peter Morris commented on The buddy classes are drowning DRY</title><description>It's a heap load of connascence, and that's certainly a bad thing!
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment17</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment17</guid><pubDate>Tue, 05 May 2009 20:02:00 GMT</pubDate></item><item><title>Gunnar Liljas commented on The buddy classes are drowning DRY</title><description>It's getting a bit old with these NIH/ their code sucks posts. At least when "there are other ways of doing that" is not followed by any suggestions on how to do it better.
  
  
I certainly agree that the code smells, but it's a working solution to a problem caused by an oversight in the language.
  
  
The MetadataClass is akin to a FNH mapping class, although the relation between the classes is decorated to the primary class. A FNH approach could be better, but the discovery process requires a bit more from the framework.
  
  
public class MyClassMetaData : MetaData
&lt;myclass  
{
  
    Range(x =&gt; x.MyProperty,1,100);
  
}
  
  
&gt;</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment16</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment16</guid><pubDate>Tue, 05 May 2009 16:21:29 GMT</pubDate></item><item><title>Eddie Garmon commented on The buddy classes are drowning DRY</title><description>I have no idea why they didn't do something like the way Design attributes are broken out in WPF, and use something similar to 'IRegisterMetadata'. Insanely simple, very DRY, and doesnt interfere with either the generation tool, or the generated code. it also avoids the double inheritance paradigm, which is also just another 'work around'.
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment15</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment15</guid><pubDate>Tue, 05 May 2009 15:33:48 GMT</pubDate></item><item><title>Stephen commented on The buddy classes are drowning DRY</title><description>@Dave, ok but I'm not sure how that effects what I said- my comment was purely that XML and especially buddy classes are imperfect for attributing data (and I'm not specifically talking about System.Attribute, I'm talking generally about how members can have data attached to them).. 
  
  
The most simplistic example I could give was.. I have this 'fact' about property X.. how do I let people find that? attributes would be a good way, but what if I cannot attribute it.. tons of systems have this requirement but there seems to be three main ways people do this: attributes (not always possible but good), xml/config (great but the compiler won't help you anymore).. or by directly interacting with the related service (such as fluent interfaces) I'm wondering if theres a better way..
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment14</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment14</guid><pubDate>Tue, 05 May 2009 15:19:31 GMT</pubDate></item><item><title>Dave commented on The buddy classes are drowning DRY</title><description>@Stephen: The problem is not the generation of code with or without attributes. If you have ever programmed WinForms in .net  1.x VS generated code in the same file as you was writing your code. Partial classes were introduced into .net 2.0. Using a partial class to separate generated  code from user written code seems a good thing at first. Most problems in 1.x were not related to the generated code, but generated code changed by the user that needs to be parsed back for use with a designer.
  
  
As I wrote earlier, Dynamic Data was probably better off implementing the visitor pattern. And what about keeping to two classes in sync when the data model changes.. Another benefit when using the visitor pattern is that the developer has auto completion and (code) validation at compile time.
  
  
Maybe David Hayden should give a few P&amp;P presentations to some Microsoft architects? 
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment13</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment13</guid><pubDate>Tue, 05 May 2009 13:13:37 GMT</pubDate></item><item><title>Stephen commented on The buddy classes are drowning DRY</title><description>Buddy classes and XML both seem to promote not getting compile time help.. maybe .NET needs a better (consistent) story for 'stood off' data attributing.
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment12</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment12</guid><pubDate>Tue, 05 May 2009 09:03:37 GMT</pubDate></item><item><title>Anon commented on The buddy classes are drowning DRY</title><description>Having an external XML file still violates the DRY principal doesn't it?
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment11</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment11</guid><pubDate>Tue, 05 May 2009 08:01:46 GMT</pubDate></item><item><title>Dave commented on The buddy classes are drowning DRY</title><description>If you're writing a buddy class just to add some behavioral attributes, XML is a much cleaner way. In the example Oren has given (validation) the visitor pattern should have been used. 
  
  
When Microsoft started asp.net MVC, I thought yeah, they are finally gonna start using patterns and practices themselves instead of advocating them to the world. But it was just a fluke.
  
  
Just my 2 cents
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment10</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment10</guid><pubDate>Tue, 05 May 2009 06:59:40 GMT</pubDate></item><item><title>configurator commented on The buddy classes are drowning DRY</title><description>Couldn't agree more.
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment9</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment9</guid><pubDate>Mon, 04 May 2009 23:24:29 GMT</pubDate></item><item><title>James Newton-King commented on The buddy classes are drowning DRY</title><description>I think they are laziness on the part of the tool that is generating the code. The tool should provide hooks to add attributes without a clunky solution like this.
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment8</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment8</guid><pubDate>Mon, 04 May 2009 23:02:45 GMT</pubDate></item><item><title>Ayende Rahien commented on The buddy classes are drowning DRY</title><description>Andrey,
  
I actually really like NH's XML style. 
  
  
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment7</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment7</guid><pubDate>Mon, 04 May 2009 22:43:15 GMT</pubDate></item><item><title>Nigel Sampson commented on The buddy classes are drowning DRY</title><description>Thankfully in Dynamic Data (not sure about RIA Services yet) you can replace the Metadata provider to something else if you'd like (xml, fluent interface etc).
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment6</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment6</guid><pubDate>Mon, 04 May 2009 21:08:14 GMT</pubDate></item><item><title>Andrey Shchekin commented on The buddy classes are drowning DRY</title><description>Well at least there *is* a way to solve the problem (customize the metadata of original classes). I do not like it much, but I can not really criticize the idea (after all, NHibernate was using *XML* for similar task  for years and most people were ok with that).
  
  
What approach would you prefer? I would say use lambda expressions, hopefully they will get to that. Otherwise, double-derived works pretty well, I was always using it for any codegen I did.
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment5</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment5</guid><pubDate>Mon, 04 May 2009 21:04:26 GMT</pubDate></item><item><title>PeteGoo commented on The buddy classes are drowning DRY</title><description>Hi found this one pretty horrible as well when I seen Mikes post. Funny thing is the MS DSL tools have their own, much better, solution to this problem, i.e. the double-derived pattern.
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment4</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment4</guid><pubDate>Mon, 04 May 2009 20:10:26 GMT</pubDate></item><item><title>Kelly Stuard commented on The buddy classes are drowning DRY</title><description>It is a huge mistake taking this "buddy" class approach. If only they had extended the tools to allow the flexibility to add attributes to properties.
  
  
The whole thing sets off a South Park line: "I'm not your buddy, pal. I'm not your pal, friend."
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment3</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment3</guid><pubDate>Mon, 04 May 2009 20:08:55 GMT</pubDate></item><item><title>Mark Nijhof commented on The buddy classes are drowning DRY</title><description>wow buddy classes, I hadn't heard of it yet, but this looks ugly. Hope too never see it again.
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment2</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment2</guid><pubDate>Mon, 04 May 2009 20:08:19 GMT</pubDate></item><item><title>Damien Guard commented on The buddy classes are drowning DRY</title><description>You're not the only one hating buddy classes - an ugly hack that presumably was quicker than doing the proper thing.
  
  
[)amien
</description><link>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment1</link><guid>http://ayende.com/3994/the-buddy-classes-are-drowning-dry#comment1</guid><pubDate>Mon, 04 May 2009 19:55:22 GMT</pubDate></item></channel></rss>