When to use an interface?

I'm a bit confused about when to make an interface for an object. I hardly make interfaces except when I develop a distributed application. I normally provide an API specification with the program I developed.
Can anyone tell me when it is usefull to make an interface for a class?
Where I work they normally provide an interface for every object that has to interact with the outside world. I thought interfaces were used for inheritance issues.

Thanks for your remarks. I will keep using JavaDoc for documentation. Could you also advise me about a design issue in my program?
In my program, a library for drawing charts, I have a number of charts that all extend the following base class:
import javax.swing.JPanel;
abstract class ChartType extends JPanel
    public abstract DataSet[] getDataSetArray();
    public abstract void setDataSetArray(DataSet[] dataSets);
    protected abstract int getHorizontalScrollBarPolicy();
    protected abstract int getVerticalScrollBarPolicy();
}I want all the charts to have e.g. the getDataSetArray function because I need to call this function in my class Legend which I can use to draw a legend for each chart.
Should I consider writing an Interface for this instead of this abstract super class?
The abstract class extends Panel because then the charts extend Panel too. Should I instead write an interface and let the charts directly extend Panel?

Similar Messages

  • Any Ideas For Sorting Rows When Planning Using Excel Interface

    Greetings Colleagues,
    I have a customer that is using BW-BPS with the Excel-In-Place user interface.  During end-user planning, users have expressed a desire to re-sort their data using a criteria different than that defined in the lead column of the layout.  Unfortunately, once the data is sorted in Excel, this causes errors when saving.
    Any ideas on how a user may be able to re-sort data without adversely impacting the layout?
    Thank you in advance for any ideas you might have.
    -M

    Hi Michael,
    Once you execute the Planning layout in Excel, you still have the Excel Menu options available. If you go to
    "Data Menu" and select the "Sort" option it allows you to sort the dataset based on the criteria you want and allows you to save the data also.
    Hope this is what you were looking for.

  • Using Tunnel interface on Router

    Hi Everyone,
    I see hew Tunnel  interface on Router.
    Router is Running OSPF.
    It has no crypto statemets.
    tunnel configuration
    interface Tunnel1
    ip address 10.4.x.x x.x.x.x
    delay 7
    tunnel source Loopback1
    tunnel destination 10.4.x.x
    My question is when we use Tunnel interface without any crypto statemets?
    Thanks
    MAhesh

    This Tunnel is a plain GRE-Tunnel. These are typically used without crypto when:
    1) The traffic is not sent through an untrusted network and a cryptographic protection is not needed.
    2) The GRE-traffic gets encrypted on a separate device if the GRE-Endpoint is not capable of doing the needed cryptographic protection.
    Sent from Cisco Technical Support iPad App

  • Using interdomain interfaces

    Hi all,
    I'm using WLE 5.01 on Solaris and trying (in vain) to
    have one domain (alfa) use services advertised
    from another domain (beta). We've done this before
    between machines but this particular scenario has both
    domains on one machine.
    We are getting an error saying that the related factory
    cannot be found ( the beta domain gateway reports incoming
    requests from the alfa domain so at least we know that
    the communification seems ok )
    Is there anything in particular we need to do to get this
    configuration to work or even anything in particular we should
    be looking at/debugging
    Thanks in advance for any help,
    cheers,
    Paul Power

    hi, when you used Local interface, you should not use PortableRemoteObject.narrow to get the LocalHomeObj. In fact, the Object which was returned by lookup is already is the LocalHomeObj. You can do as that, ie.
    Object objref = initial.lookup("ReiseTermin");
    ReiseTerminLocalHome home = (ReiseTerminLocalHome) objref;
    I have a problem using an stateless Session Bean
    communicating with an Entity Bean through the local
    interface. Both Beans have remote as well as local
    interfaces. What should I do in method lookup()? When
    I give a remote interface as parameter and afterwards
    use the method narrow(), there is a
    ClassCastException:
    InitialContext ic = new InitialContext();
    Object objRef = ic.lookup("ReiseTermin");
    ReiseTerminLocalHome reiseTermin_home =
    e = (ReiseTerminLocalHome)
    PortableRemoteObject.narrow(objRef,ReiseTerminLocalHom
    .class);
    When the local interface is passed through as
    parameter, it cannot be found:
    InitialContext ic = new InitialContext();
    ReiseTerminLocalHome reiseTermin_home =
    (ReiseTerminLocalHome)ic.lookup("ReiseTermin");
    Thanks for any help

  • No performance gain when using local interfaces

    Hello,
    I'm doing some tests to compare performances between remote ejb interfaces and local ejb interfaces.
    I have two stateless session beans EJB1 and EJB2, EJB1 calls a method on EJB2, this method receives one object as the only parameter and returns it immediately. The parameter is a big object (~700ko). My test consists simply of making 1000 calls from EJB1 to EJB2, one time with remote interfaces, one time with local interface. For both tests, the EJBs run in the same container, same VM.
    The results show absolutely no differences between the remote and the local interface !
    As I found these results a bit surprising, I changed the serialization method of my parameter object this way:
    private void writeObject(java.io.ObjectOutputStream out) throws IOException {
    System.out.println("writeObject(MyBigObject)");
    out.defaultWriteObject();
    just to check if my object is serialized when using remote interface. And the response is no.
    So question is: is there an "undocumented optimization" of the stub/skel generated by weblogic which make local calls when calling a remote method inside the same VM ?
    Some precisions:
    - I'am using weblogic 8.1sp2
    - When calling remotely my EJB2 from an external batch (running in a separate VM), I see the message "writeObject(MyBigObject)" so the serialization is done in this case.

    <Fr?d?ric Chopard> wrote in message news:[email protected]..
    So question is: is there an "undocumented optimization" of the stub/skel generated by weblogic which make local calls when callinga remote method inside the same VM ?
    >
    Some precisions:
    - I'am using weblogic 8.1sp2
    - When calling remotely my EJB2 from an external batch (running in a separate VM), I see the message "writeObject(MyBigObject)" sothe serialization is done in this case.
    WebLogic 5.x, 6.x and 7.x do call by reference for co-located EJBs by default. 8.1 has this behavior turned off by default. You may
    experience call-by-reference optimization in 8.1 only if it has been turned on explicitly in the deployment descriptor.
    Hope this helps.
    Regards,
    Slava Imeshev

  • When to use abstract classes instead of interfaces with extension methods in C#?

    "Abstract class" and "interface" are similar concepts, with interface being the more abstract of the two. One differentiating factor is that abstract classes provide method implementations for derived classes when needed. In C#, however,
    this differentiating factor has been reduced by the recent introduction of extension methods, which enable implementations to be provided for interface methods. Another differentiating factor is that a class can inherit only one abstract class (i.e., there
    is no multiple inheritance), but it can implement multiple interfaces. This makes interfaces less restrictive and more flexible. So, in C#, when should we use abstract classes
    instead of interfaces with extension methods?
    A notable example of the interface + extension method model is LINQ, where query functionality is provided for any type that implements IEnumerable via
    a multitude of extension methods.

    Hi
    Well I believe Interfaces have more uses in software design. You could decouple your component implementing against interfaces so that
    you have more flexibility on changing your code with less risk. Like Inversion of Control patterns where you can use interfaces and then when you decide you can change the concrete implementation that you want to use. Or other uses for interfaces is you could
    use Interceptors using interfaces (Unity
    Interceptor) to do different things where not all of these is feasible or at least as straightforward using abstract classes.
    Regards
    Aram

  • Adobe Reader XI (11.0.08) doesn't create thumbnail (bitmap) using Microsoft Interface IExtractImage -- Extract on Windows Server 2008 R2, when exe to generate thumbnail is launched from Windows service.

    Adobe Reader XI (11.0.08) doesn't create thumbnail (bitmap) using Microsoft Interface IExtractImage --> Extract on Windows Server 2008 R2, when exe to generate thumbnail is launched from Windows service.
    But if exe is launched as standalone, then interface IExtractImage --> Extract, gives Bitmap to generate thumbnail of PDF document.
    Above problem occurs only for PDF documents, if we tried same with other software like CAD -CATIA it works without any problem.
    Is there any security concerns form PDF side, which doesn't allow to generate Bitmaps, if exe to generate it is launched form Windows service.

    It might be deliberate, Acrobat and Reader software is not intended to run in a service environment.

  • When To Use Inbound and Outbound Interfaces?

    I use an Inbound message type when i am receiving some data and outbound message type when i push data out of the XI box??Is this correct..
    And how to decide when to use a Inbound and Outbound Interface?

    Hi Barik,
    <b>I use an Inbound message type when i am receiving some data and outbound message type when i push data out of the XI box??Is this correct..</b>
    WRONG!!!
    outbound message->XI->Inbound message...
    (sender system)->XI->(reciever system)
    remeber: when u r sending some data to XI u send it using outbound interface.
    and when u r sending some data from Xi to other system u use inbound interface...
    Hope ur doubt is clear!!
    regards
    BILL
    Use a Good Subject Line, One Question Per Posting - Award Points

  • When to use abstract class compared to interface

    hi
    can some one plase advise me when to use abstract class compared to interface?
    Example will be appreciated...

    So an abstract class can carry implementation. This can be used to formulate a rule of thumb as to when to use it over an interface.
    If you have a so called type specialization relationship between the subtypes and the supertype then they're likely to benefit from shared implementation provided by the supertype, so use class (abstract or concrete) extension in this case. Type specialization is when the supertype represents a general concept like Fruit and the subtypes are specialized forms of that like Apple and Banana.
    Another common kind of relationship is called type expansion. In this case the subtypes are unlikely to have any use of implementation provided by the supertype, so use interface implementation. Type expansion is when the supertype represents a specific character the subtypes take on. For example Apple and Bicycle ure unrelated in the type specialization sense but still can share a common character like Comparable. The subtypes have been expanded to include the supertype character, namely the ability to be compared.

  • When to use interface and when Abstract Class?

    In a recent interview I was asked "When to use interface and when Abstract Class?" Explain with an example.
    Also in what situations a class should be made final(real time example)

    Interface is a pure contract with no implementation. Typically used to define a communication contract between two different sub-systems. Example EJB home interface. This also allows the design to change as long as the contract is met.
    Abstract class is when there exists a lot of common functionality already known and can be coded. However, a few unknowns exists (typically about data) for which abstract methods need to be defined and implemented by the sub class.
    Example: Consider a workflow engine. A great example for abstract class. The workflow process has lot of common code that is independent of the workflow type (vendor flow, contract flow, payment flow etc). However, certain decisions on the route to take will depend on value of data being submitted. So the base class will define a abstract Data getData() method and proceed assuming data will come. The implementing subclass will provide the actual logic for getting the data.
    Also see the "Template" design pattern.
    Note: To some extent the common code design drives the behavior of the abstract methods. So if the design changes then so "might" the behavior expected from the abstract methods.

  • I have been organizing my bookmarks into folders. There are a bunch of bookmarks that appear on the Bookmarks Menu that do not appear when I used the Organize Bookmarks option. Therefore I can't organize them. How do I get at them and move them to folders

    I used Organize Bookmarks to put some bookmarks in folders. When I had done all the bookmarks that appeared outside of folders in the Organize Bookmarks window, I closed it and looked at my bookmarks menu. Under my folders were some other bookmarks that I hadn't seen in Organize Bookmarks and when I used it again, they still weren't visible. Therefore, I couldn't move them into folders.

    Update - I discovered that the entire list of bookmarks can be accessed in the Organize Bookmarks window by clicking on the icon for Bookmarks Menu.
    This seem like odd interface behaviour to me.
    All the other software I use follows the pattern that an icon with a triangle to the left, which you click on to expand the menu tree downwards, shows the entire contents of the category when you click on the triangle. In other words, you don't get a different response by clicking on the icon from what you get by clicking on the triangle.
    It also seems odd to me that when an unsorted bookmarks folder is automatically provided that unsorted bookmarks would not be placed there by default.
    Anyway, by getting the list of bookmarks displayed this way I was able to simply right-click on items in the list and delete them, as I thought I should be able to do. Problem solved. Organize Bookmarks interface found to be somewhat unintuitive.

  • Illustrator CC 17.1.0 crashes when editing preferences, user interface. Running on MacBook Pro i7 OSX 10.9.5

    Illustrator CC 17.1.0 running on MacBook Pro i7 OSX 10.9.5 - crashes when editing preferences, user interface. Also crashes when quitting application. Anybody any ideas?

    While 2 GB is the absolute minimum to install Mavericks, if you want to do anything with the Mac you need more then that. Upgrade your RAM.
    Until you upgrade the RAM seriously consider shutting down the Mac nightly. You should also seriously review the items in the User Login Items to see if there are any there that you really don't need to have startup with your login to reduce the amount of RAM you are using.

  • When to use which mapping in Scenario

    Hi,
           When to use
    1. ABAP MAPPING
    2. JAVA MAPPING
    3. XSLT MAPPING
    4. GRAPHICAL MAPPING
    When to use these mapping at what type of interfaces we should use them.
    Regards,
    Nissi

    Hi,
    Hope the following link gives you an idea of use case of different mapping techniques
    [Mapping Technique|http://wiki.sdn.sap.com/wiki/display/XI/Mapping+Techniques]
    [ABAP mapping implementation|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/a15a5f77-0c01-0010-cfa1-94ca75306537]
    [XSLT mapping implementation|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/0654b462-0c01-0010-4d9d-d2d5a7fee0d6]
    [Java mapping implementation|http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm]
    To give an example, Usually file content conversion feature of file communication channel does not support the content conversion of structures with deep hierarchy then in that case we can go for XSLT mapping as with graphical mapping we cannot create text file for structure with deep hierarchy.
    You get more understanding on the use case when you develop different scenarios there are too many to list.
    Hope this helps !!!
    Regards,
    Amit

  • In business object what is the use of Interface

    hi ppl,
             In each business object there is a interface what can we do with that. When i used wizards like dynamic parallel processing it asked for wizards what is the actual use of interfaces.

    Hi Dheepak,
    I have an overview on interfaces. Someone pls correct me if i am wrong here.
    Interfaces are generally used to group a set of attributes and methods that can be used across different business objects. You can create your own interfaces in SWO1 and when you include these interfaces in business objects you get all these attributes and methods in the business objects (Inheritance). Its basically for re-usability of the code(Reusability). Apart from that if required you can implement your own code for the methods thus maintaining the same name with a different logic for your BO (Polymorphism).
    For example assume that you have a "Display" method and a few attributes in an interface. The "Display" method is used to display a particular transaction. Now you can include this interface in any BO and all these attributes and methods will be available in that BO with their respective implementation code. Now if you want the method to form a different action in any particular BO you can go ahead and redefine this code in that BO. This redefinition will not affect other BO's that had implemeted this same interface. All other BOs which had implemented this interface will continue to function as per the implementation code defined in the interface. This makes sure that the same method works in different ways in different BO's (Polymorphism)
    Supertype<-->Subtype delegation will allow us to inherit the supertype/subtype methods/attributes but it does not allow us to change the underlying code in individual BOs. Hence polymorphism cant be acheived here
    Thanks,
    Prasath N
    BO - Business Object

  • Using an interface as a parm in a methods

    Greetings I have an interface class that has a bunch of get methods. Then in another class I call the interface as a parameters. But what information do I put in it as I use it? the gets?
    [code
    //interface class
    public interface FillData {
              public String getTrader();
              public String getAccount();
    //Reg class
    public boolean insertData(FillData data){
    return true
    //Where I set the methods
    setTrader((String)table.getValueAt(i,0));
    importit.setAccount((String)table.getValueAt(i,1));
    insertData (//what goes in here???){
    Any more information needed lemme know? Thanks for any help!

    I have an interface public interface FillData {
    public String getTrader();
    public String getAccount();
    }I have a class with the interface as a parameter of a method
    public boolean insertData(FillData data){
    //do stuff
    return true
    }When I call the method what do I put in the parameter part of the method when I implement it?
    insertData(//what information do I put in here?)I guess my question is how do you use an interface??? I read the tutorial about implementing it in a class and all but how about when u use it as a method?
    Message was edited by:
    h2opologirly69

Maybe you are looking for

  • Calendar in List view different from Day and Month view

    When I look at my Calendar in 'List' view all of the Birthdays and Events are in the wrong date but in 'Day' and 'Month' view they are correct.  Has anybody found a fix for this yet?  I have looked at similar discussions but they are all a couple of

  • SD-R6012 1334 DVD-R/RW Drive Not working properly

    Hi all, I was hoping someone could help me. My SD-R6012 DVD drive copies CDs fine, but wont burn any DVDs. Ive tried to install the firmware upgrade for it, but it comes back with the message: "CD-Drive firmware is NOT need to update firmware" Please

  • Consuming Webservices in webdynpro ABAP

    Hello, I want to work with consuming Webservices in Webdynpro ABAP. Can anybody give an example for the same. Any help would be highly appreciated. Thanks.

  • Can I create an email message content type?

    Just want to be able to select me email message from the New Document drop down in the library. It doesn't work.  So I tried a link content type to an email message in a document library and that doesn't work either. Has anyone got any ideas for this

  • XMLParser for PL/SQL - Error

    I am using XML parser for PL/SQL in oracle 8.1.7 DB. When i run the sample xml program, i get error which is as follows. While compiling no errors. But while executing it reports error as given below. SQL> exec domsample('/u01/usr/oracle/sso','family