Delegation and interface

i m reading Grand's Patterns in java, he says that delegation and interface patterns are often used together, however i wasnot able to find any references, i cant quite see why that is?

GoF discusses delegation. They don't make it a pattern, rather they use it in several of their patterns. Their example of a Window delegating its area operation to a Rectangle and then being able to switch to using a Circle at runtime is dependent on Rectangle and Circle having the same "type", ie implementing the same interface. Here's a Java version of the delegation example on page 20 of "Design Patterns"
public class Window implements TwoD
     TwoD my2D = new Rectangle(1,1);     // we delegate area to this TwoD
     // switch to circular delegate
     void useCircle(double radius)
     {my2D = new Circle(radius);}
     // switch to rectangular delegate
     void useRectangle(double width, double height)
     {my2D = new Rectangle(width,height);}
     // our area method uses the delegate
     public double area()
     {return my2D.area();}
     public static void main(String[] args)
          Window w = new Window();     // construct a window
          w.useRectangle(4.0, 6.0);     // set the shape to a rectangle
          System.out.println("area of rectangular window="+w.area());
          w.useCircle(2.5);               // set the shape to a circle
          System.out.println("area of circular window="+w.area());
// 2 d shape used by Window, Circle and REctangle
interface TwoD
     double area();     // requires an area method
// rectangular shape
class Rectangle implements TwoD
     double width, height;
     Rectangle(double w, double h)
          width = w;
          height = h;
     public double area(){return width*height;}
// circular shape
class Circle implements TwoD
     double radius;
     Circle(double r)
          radius = r;
     public double area(){return Math.PI*radius*radius;}
}

Similar Messages

  • Difference between abstract classes and interfaces

    I actually wonder about what are the differences between abstract classes and interfaces may somebody give an example code about it?
    and i have one more question how can i use interfaces like multiple inheritance ? i mean when i implement an interface like
    class a extends b implements c,di have to use all c and d methods but what that methods means?
    I mean as i know we cannot make implementations of methods in interfaces
    but for example in runnable interface there is a method like run() and it has been defined somewhere because it knows what to do(i mean when it will run), i just write my code into that method .

    Once you get past the starting point (I am referring to the OP here), there are a few salient differences:
    You can only extend (or generalize) a single superclass; however, you can implement (or realize) multiple interfaces. As such, all things being equal, using an interface in lieu of an abstract class 'frees' your design. Later, if you want the implementor of an interface to inherit from another class, there is not issue.
    Any abstract method specifies a contract. However, abstract classes allow you to also add common behavior to subclasses. This is an overused justification for abstract classes, IMO. You can achieve the same effect using delegation and still having interfaces.
    Always program to interfaces wherever possible. This means that you define an interface and have an implementing class (usually at a minimum). Do not do this for all your classes, but rather the ones that make your system unique (the domain model or M in MVC architecture). This allows you to later change implementation with a minimal amount of refactoring. This is a core precept from the Group of Four and any number of decent programming books.Best of luck.
    - Saish

  • Diff b/w msg mapping and interface mapping

    hi
      i have some doubt's:
       1. diff b/w msg mapping and interface mapping
       2. What is product in SLD? usually who creates the product,technical,business system??
    thx in advance..

    hI Smartsoft General User  ,
    The following r excellent websites on mapping which differentiate msg mapping and interface mapping in detail:
    Excellent PDF Document on Mapping
    http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf
    Mapping Development with the ABAP Workbench
    http://help.sap.com/saphelp_nw04/helpdata/en/10/5abb2d9df242f6a62e22e027a6c382/content.htm
    ABAP Mappings
    http://help.sap.com/saphelp_nw04/helpdata/en/ba/e18b1a0fc14f1faf884ae50cece51b/content.htm
    how to create a flat file out of an IDoc-XML by means of an ABAP mapping program and the J2EE File Adapter.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a
    How to Use ABAP Mapping in XI 3.0
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e3ead790-0201-0010-64bb-9e4d67a466b4
    These r excellent websites in SLD:
    How To…Handle the SLD for SAP XI
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9e76e511-0d01-0010-5c9d-9f768d644808
    How To…Handle Caches in SAP XI 3.0
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1a69ea11-0d01-0010-fa80-b47a79301290
    http://www.sap-press.de/download/dateien/751/sap_press_exchange_infra_engl.pdf
    cheers!
    gyanaraj
    ****Pls reward points if u find this helpful

  • What is diff b/w abstarct and interface

    what is diff b/w abstarct and interface in real time where we come across, give a best real time example

    I think there have been lots of threads in this forum discussing interfaces and abstract classes.
    http://forum.java.sun.com/thread.jspa?forumID=256&threadID=389830
    http://forum.java.sun.com/thread.jspa?forumID=54&threadID=5120074
    http://forum.java.sun.com/thread.jspa?forumID=54&threadID=499077
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=546668
    Interfaces define a contract for what an implementing class should provide. Abstract classes do the same but they can also provide some common part of the implementation.

  • Names of interface tables and interface programs of oracle modules

    Hi all,
    i need urgent and accurate information about the names of interface tables and interface programs of the following oracle modules,R12, or either ther are custom made. Any accurate link refering to the desire information would be much appreciated.
    Plus i need a clear and simple definition and purpose of interface tables and interface program and by what other names are they known in industry.
    Data Object,Oracle Module
    Chart of Accounts,Oracle General Ledger
    Trial Balance,Oracle General Ledger
    Supplier Master,Oracle Payables
    Open Supplier Invoices,Oracle Payables
    Open Supplier Credit/ Debit Memos,Oracle Payables
    Open Supplier Advances,Oracle Payables
    Bank Master,Oracle Cash Management
    Customer Master,Oracle Receivable
    Asset Categories,Oracle Assets
    Asset Master,Oracle Assets
    Item Master,Oracle Inventory
    Item Categories,Oracle Inventory
    Sub Inventory and Locators,Oracle Inventory
    Item On Hand Balances,Oracle Inventory
    Item wise Per unit Cost,Oracle Inventory
    Bill of Material,Oracle Discrete Manufacturing
    Departments,Oracle Discrete Manufacturing
    Operations,Oracle Discrete Manufacturing
    Routings,Oracle Discrete Manufacturing
    Resources,Oracle Discrete Manufacturing
    Overheads,Oracle Discrete Manufacturing
    Employee Master,Approval Hierarchy
    Approval Hierarchy,Approval Hierarchy
    Open Customer Invoices,Oracle Receivables
    Open Customer Credit/ Debit Memos,Oracle Receivables
    Open Customer Advances,Oracle Receivables
    Pending Requisitions,Oracle Purchasing
    Pending Purchase Orders,Oracle Purchasing
    Open Sales Orders,Oracle Order Management
    Price List,Oracle Order Management

    Hi;
    Its metalink note you need to login metalink wiht valid CSI(customer Support Identifier) number to can se note via using note number.
    Please see:
    Oracle EBS Based and Interface tables
    Oracle EBS Based and Interface tables
    Regard
    Helios

  • Receiver Determination and Interface Determination Condition conflict in ICO

    Hi,
    I found a strange issue today while configuring two receivers using the Receiver and Interface Determination conditions.
    Sender - Proxy Service
    Receiver1 - ReceiverA
    Receiver2 - ReceiverB
    Receiver Determination Condition : When Field1 = 100, message should flow to ReceiverA and ReceiverB
    Interface Determination Condition (ReceiverA) : When Field1=100 and Field2=50 message should flow to a specific interface in ReceiverA
    There is no Interface Determination condition for ReceiverB, for all messages having Field1=100, it should go to ReceiverB.
    Test Scenarios:
    1) Field1=100, Field2=50 : Message flows successfully to ReceiverA and ReceiverB
    2) Field1=100, Field2=89 : Message fails to process from ECC itself throwing Interface Determination not found error. Ideally this is a positive scenario for ReceiverB and it should send the message to ReceiverB without any errors. But, this did not happen in this case
    I tried the same by configuring the conditions completely in Receiver Determination itself without using the Interface Determination, it worked perfectly fine. But, just wanted to understand that if this is an expected behavior.

    Hi Sherin,
    As there are two receivers Receiver A and Receiver B.You need to create two bussiness components and two communcication channels for two receivers and one Reciver Determination, two Interface Determination,two Receiver Agreement.In Receiver Determination you need to keep the below and condition.
    In the above screenshot the two receiver are Receiver B and Receiver C and Field 1 is Key_Value and Field2 is Emp_ID.
    If the Key_Value=100 and Emp_ID =22 then the message should go to both the receivers B & C by keeping the following AND condition
    If the Key_Value=100 and Emp_ID is not equal to 22 then the message should go only to Receiver B by keeping the following condition
    You need not keep any condition in Interface Determination just create 2 Interface determination for two receivers.
    Hope this helps you.
    Thanks,
    Durga.

  • I have installed succesfully a PCI cards seen by windows but it does not appears in the device and interfaces tools of the Measurement and automation manager?

    Cannot install new objects in device and interface to use the ni-imaq library and to take image from my camera.

    Which PCI card did you install? The PCI-8252 and PXI-8252 will not appear in MAX. Does your card appear in the Windows Device Manager?

  • Compiling Nested Classes and Interfaces

    I am looking for documentation about compiling nested classes and interfaces. I have found something in the JVM Specification, but there does not explain how a nested class is compiled and what is included in the top level class to mark a "place holder" to the nested class. The JVM Specification in this topic cite the web page http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses/spec/innerclasses.doc.html that does not exists any more.
    My root problem is that: I am compiling a class with a private nested class, but in the class file generated TopLevelClass$NestedClass.class the class does not have the private modifier. So I am not understanding why the "private" modifier was removed during compilation.
    I performed the same test with a protected nested class and the result was the nested class with the public modifier. So I am not understanding why the "protected" modifier was changed to "public".
    Thanks in advance,
    Mardoqueu.

    This should not be happening. What compiler are you using? If it's a reasonably recent Sun compiler, could you post a minimal example?

  • I want to edit properties of the interface windows opened while "Open File", "Save Page As" and interface opened during Downloading of any file.

    I am doing a small project on dedicated web client where in user automatically logs in non-root user and Firefox automatically starts.
    I am using Fedora 14 kernel 2.6.35.12-88.fc14.i686 and Firefox 3.6.16.
    I have installed only Gnome in my computer with no Nautilus or other file browser on it.
    I want to edit properties of the interface windows opened while "Open File", "Save Page As" and interface opened during Downloading of any file.
    Please guide me for this.

    First, I sent an email to the author of PhotoME to inform him of the serious issues his addon caused with Firefox latest versions.
    Now, for those of you who do not have the PhotoME addon and yet experience the same problem that I had and that I described above, I suggest the following strategy.
    As PhotoME did cause these problems with Firefox latest versions, I am pretty covinved other addons probably might cause these problems too. Therefore, adopt the following method.
    Test one addon at a time to see if this particular addon is behind your Firefox issues like the ones I had.
    So, disable one addon only at a time. Then close your Firefox and restart it from scratch and see if you still have your Firefox problems. You must restart the Firefox browser from scratch. If you still have these Firefox problems, re-enable the disabled addon, restart your Firefox (again!) and repeat the same method for every single addon that you have.
    Try to be selective by choosing first addons that are more likely to cause your Firefox problems such as not very well-known or not very popular addons (like it was the case for the PhotoME addon).
    If this method works or if it does not work, report it on this web page so that others can be helped with your comments.
    I hope this method will help you because I was really upset that I had these Firefox problems and I first thought it was the fault of Firefox, only to discover later that this PhotoME addon was the culprit and had caused me such upset.

  • Extended Receiver Determinatipon and Interface Determination?

    Hi,
    Where exactly (In which business cases) we can implement or required Extended Receiver Determination and Interface Determination?
    Thanks,
    Naidu.

    Hi,
    There are only two modes standard and Extended, Enhanced receiver determinatrion is Extended receiver determination only.
    Enhanced(Extended) receiver determination  -->
    Whenever list of receivers is determined dynamically at runtime, using a message mapping then it is called enhanced.
    Enhanced Interface Determination--> It is when you want the target interfaces to be defined dynamically based on the multimapping, that is called enhanced interface determination.
    Refre SAP help for more detail
    http://help.sap.com/saphelp_nw04s/helpdata/en/42/ed364cf8593eebe10000000a1553f7/frameset.htm
    Thanks!
    Edited by: Sudhir Tiwari on Dec 5, 2008 6:34 AM

  • Receiver Determination and Interface Determination

    Hi,
    Please, can anyone explain what is the concept of 'Receiver determination' and 'Interface Determination'?
    Thanks,
    Harikumar. S

    Hi,
    >>>>Receiver determination
    its about finding the receiver system for particular source system and outbound interface.
    Suppose,you want to send data from file->XI->SAP and CRM based on some condition
    in this scenario you need to determine whether to send file data to SAP or CRM system,this decision you will do in Receiver determination
    in Receiver determination screen you need to provide the following details
    1.Source system(ex: File system)
    2.Outbound Interface(File Message Interface)
    3.condition and receiving system(ex:if some x field value in source payload is 1 go to SAP elseif '0' go to CRM system)
    >>>>>>Interface Determination
    suppose in above scenario you determined the receiver i.e SAP,you will have number of IDOCs (Inbound Interfaces)in SAP.
    so to which IDOC you will send file data?This decision you will make in Interface determination(we can it as Inbound Interface determination).if you find the IDOC is CREMAS then how will transfer file structure data to IDOC structure? answer is Message Mapping
    From all the above decisions you need to provide following details in Interface determination screen
    1.Source System
    2.Outbound Interface
    3.Receiver System
    4.Inbound Interface(IDOC type)
    5.Message Mapping(i.e file to IDOC)
    Even in Interface determination you can specify the condition to select Inbound Interfaces(ex.IDOCs)
    if you have any doubts please lets know.
    Cheers,
    Jag

  • No Devices and Interface in MAX

    Hi all,
    I recently installed the evaluation version of LabVIEW and I am trying to communicate with a Mark-10 Series 5 force gauge. The problem, however, is that MAX does not seem to detect the instrument or any other instrument. There isn't even a Device and Interface tree.
    I am running Windows 7 and the Mark-10 drivers are installed (and is detected by the device manager as a USB device).
    Anyone have any idea what could be wrong?
    Solved!
    Go to Solution.

    I recently went through this problem. You have to register a USB instrument to use the VISA driver. There is an NI tutuorial on how to do this. You can find the tutorial here.
    This allows 3rd party instruments to show in MAX and be used in LabVIEW.
    Rob

  • Oracle EBS Based and Interface tables

    Hi,
    Where can I find the list of all Based and Interface tables used in Oracle EBS R12 Applications. OM, INV, AR, AP, GL, & PO (Purchasing).
    I have been told that they are available in "My Oracle Support" please send me the path.
    Thanks,
    Amorsolo.

    Please see old threads, it should answer your question -- http://forums.oracle.com/forums/search.jspa?threadID=&q=Interface+AND+Tables&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • Message Mapping And Interface Mapping

    Hi,
    I have 2 software components.
    One is for sender and one is for receiver.I have created all the Data types,Message type and Message Interface fro sender in the first Software component and data types ,message type ,message interface for the receiver in the second software component .
    Now, in which Software component should i create Message Mapping and Interface Mapping?
    Thanks in Advance,
    mvk

    Hi,
    You could use the created Message type and Message interfaces in Sender as well as receiver software components for creating message mapping, interface mapping and integration scenario.
    Generally it makes sense to maintain the message mapping, interface mapping and integration scenario in receiver software component. The message mapping and Integration scenario is specifically based on the receiver end requirments, so its preffered on receiver software component.
    The sender side details could be reusable in case if you need those for another new receiver software component. If you maintain it in sender component, then that will lead to mix-up all the things on sender side even though its based on receiver end.
    I think this could help you.
    In PI7.1 now there is concept of Folders to maintain all the interfaces appropriatly and leads for reusability of existing objects.
    Please refer below links for more details,
    /people/thorsten.nordholmsbirk/blog/2006/07/25/structuring-integration-repository-content--part-1-software-component-versions
    http://help.sap.com/saphelp_nw04/helpdata/en/42/ed903cf6c4492ce10000000a114084/frameset.htm
    Thanks
    Swarup
    Edited by: Swarup Sawant on Jan 26, 2008 8:33 AM

  • How to copy the predeliverd XI Scenarios and interfaces to our SWCV ?

    Hi friends,
    How to copy the predeliverd XI Scenarios and interfaces to our SWCV ?
    Will all the relevant objects will be copied ? or we need to copy one by one ?
    Do we need to create separate SWCV ?

    Thanks , Then the namespaces defined in copying object will automaticaly change  to copied object namespace?
    do we need to do anthing in SLD ?
    Normally , predeliverd contents are uneditable right ? when we are copying all , will they allow to change the scenarios and BPM  objects , like message type and interface type , mapping etc ?

Maybe you are looking for

  • I tried to invoke WS from BPEL process

    I tried to invoke WS from BPEL process. And error occurred when I deployed the process. Error: [ERROR ORABPEL-10902]: COMPILING FAILED. [NOTE]: IN "bpel.xml", XML syntax analysis failed. The reason is "Part Element not defined". In "http://192.168.0.

  • Firefox opens a GEDCOM file instead of invoking the proper software

    When Firefox encounters hyperlinks in webpages to files which are NOT html sometimes it will ask for a chooser application, but sometimes not. In the case of a GEDCOM file it simply opens a tab with all the text in it. I want Firefox to ask me to ide

  • Error frm-41213

    Hi all i have install orcle 10 datbase and devloperSuite 10 on new machine every this is working fine but when i call the report from the form it will show me the UNABLE TO CONNECT THE REPort SERVER REPSERVER90 FRM-41213 The report is saved in .rdf a

  • DataTransfer Error

    I have written following lines of code, but when TransferData() method is called, it generates error "Property LoginSecure cannot be changed or read after a connection string has been set."  Can anybody help me? Thanks in advance.... Code: //1. Creat

  • How to edit web.xml deployment descriptor from console in weblogic 8.1?

    In weblogic 7.0, deployment descriptor such as web.xml can be edited from the admin console, but on weblogic 8.1 I can't find a way to do so. Is this function taken out? Why is it taken out? Do I have an alternative to edit it without unpacking and p