Re: Programming to interfaces with beans?



l-EE wrote:
If I'm writting a bean - and I mean just a plain old Java Bean not an EJB or anything like that - is there any merit to seperating the interface out of the class? I do this with pretty much every other kind of class I write but Beans...

Just like any class, if you separate out the interface you can have other developers implement the interface in order to extend your JavaBean ideas. Of course you might also want to provide an empty implementation of the interface as a convenience class of those who just want to extend the interface with just a subset of changes from the default.

Another advantage of separating out an interface, as a common idea, is that you can have collections of the interface quite easily, and this sort of collection will extend to other developers building JavaBeans from your interface.
.



Relevant Pages

  • Re: Learning Lisp design techniques (not just the language itself)?
    ... maximum compile-time checking of the usage of the API? ... How to define a package interface? ... Should you extend CLOS? ... objects with property lists? ...
    (comp.lang.lisp)
  • Re: [perfmon] Re: [perfmon2] perfmon2 merge news
    ... criticism of the current set of perfmon2 system calls, ... opposition to the goal of having strong typing of the interface. ... extend but that is at the expense of losing strong typing. ...
    (Linux-Kernel)
  • Re: Inheritance versus Composition
    ... you really need some poking around and see for yourself some examples of the trouble you run into by naively extending base classes which you can of course only do once. ... Its considered legacy today because IF you choose to use this mechanism, you can forget about having your data model extend anything else. ... Let the interface describe a notify mechanism and let your concrete class implement this. ...
    (comp.lang.java.help)
  • Design Aesthetics & Working With Portals
    ... room in one of the margins for a flag type of icon if I extend the ... within the portal's comfort zone. ... but they strain the intuitiveness of the interface. ...
    (comp.databases.filemaker)
  • Re: Interface binary compatible but type mismatch error
    ... > class by adding a new method then all would be cool but why if I extend ... > an interface I get a 'Type mismatch' error? ... From MSDN, Visual Basic Concepts, Maintaining Binary Compatiblility: ... An interface, on the other hand, is just an interface, and has but one GUID to ...
    (comp.lang.basic.visual.misc)