tag:blogger.com,1999:blog-4704664917418794835.post741558858676417640..comments2023-07-01T05:41:30.469-07:00Comments on Headius: Interfaces Should Be Modulesheadiushttp://www.blogger.com/profile/15717357218364947795noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-4704664917418794835.post-76500803150834519352006-08-08T06:40:00.000-07:002006-08-08T06:40:00.000-07:00How do you enforce that the methods from the inter...How do you enforce that the methods from the interface are implemented?<br><br>Or is it intentional to not do so?Erik van Oostenhttp://www.blogger.com/profile/00715495495261605782noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-60705850282744386142006-08-08T06:45:00.000-07:002006-08-08T06:45:00.000-07:00It's not necessarily intentional; there's ...It's not necessarily intentional; there's just no way to really enforce it. At the time the interface is extended (or hopefully, included) the class is still "open" as far as Ruby is concerned. We can't determine whether methods will be implemented later.<br><br>Also, interface extension is done using Java's Proxy class, which implictly implements all interface methods right away. When you provide a real body for those methods later in the Ruby code, you're just filling in the blanks.Charles Oliver Nutterhttp://www.blogger.com/profile/06400331959739924670noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-64928015324573894862006-08-08T06:53:00.000-07:002006-08-08T06:53:00.000-07:00Of course, the class is still open. I really progr...Of course, the class is still open. I really program too much in Java.Erik van Oostenhttp://www.blogger.com/profile/00715495495261605782noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-35493320888398131382006-08-11T09:13:00.000-07:002006-08-11T09:13:00.000-07:00I agree with your analysis of how interfaces shoul...I agree with your analysis of how interfaces should be implemented.<br><br>Do you see an<br><br>include_interface<br><br>method alongside include_class, but with Java implementations that are the same behind the scenes?<br><br>BTW I'm really pleased by my explorations into JRuby and think you're really onto something. In particular I've had some success putting together webapps with Spring MVC that don't use any Java code at all!Charles Greerhttp://www.blogger.com/profile/13130920716076379190noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-24068349842163318662006-08-11T09:51:00.000-07:002006-08-11T09:51:00.000-07:00The current thinking is something like this:class ...The current thinking is something like this:<br><br>class MyClass<br> implement ActionListener<br> implement Collection<br> include Enumerable<br>...<br>end<br><br><br>I'm still of two minds whether overloading include is ok or whether we should introduce a new keyword because interfaces are their own beasts. Really it comes down to deciding how "Java" we want the ruby code to be; if we take a purely Ruby view, then mixin inheritance (using include) isn't that much different than multiple inheritance of types and method signatures with interfaces. The only striking difference is that interface inheritance doesn't come with any implementation code. If you take the Java point of view, interfaces are completely different from modules, and we should have a separate keyword and enforce that all methods have been implemented somehow. The Java approach starts to seem really foreign and cumbersome in Ruby, however, so I'm leaning toward the "Ruby way".Charles Oliver Nutterhttp://www.blogger.com/profile/06400331959739924670noreply@blogger.comtag:blogger.com,1999:blog-4704664917418794835.post-54321668947986417412006-08-23T15:43:00.000-07:002006-08-23T15:43:00.000-07:00Interface should be treated like modules? Duh!Interface should be treated like modules? <b><i>Duh!</i></b>Anonymousnoreply@blogger.com