From: Dean Wampler Date: 2006-06-07T01:41:02+09:00 Subject: Re: Ruby and the Open-Closed Principle Yes, you're exactly right! I forgot that the most precise and "conservative" meaning of the OCP is that you don't modify the original source code. That's more important than the broader restriction that you shouldn't modify the class in any away, e.g., by re-opening it the Ruby way. Certainly this should be done with great "deliberation". For example, you risk breaking libraries when they are changed in subsequent releases, as others have remarked. However, I don't believe that re-opening classes violates the OCP, "a priori". Note that byte-code modification frameworks have become very popular in the Java world, where they are used to "modify classes", but in very specific and controlled ways. Thanks for the clarification on the OCP. dean On 6/6/06, Jim Weirich wrote: > [snip...] > > But isn't this the essence of OCP? The ability to extend a class (open > for extensions) without modifying the original code? (which remains > closed). > > -- Jim Weirich > > -- > Posted via http://www.ruby-forum.com/. > > -- Dean Wampler http://www.aspectassoc.com http://www.aspectprogramming.com http://www.contract4j.org