Polymorphic question

this is one of the questions for the java exam . i don't seem to understand the answer.
class SuperBase
    void print (SuperBase a)
        System.out.print("Super");
class Base extends SuperBase
    void print (Base b)
        System.out.print("Base");
class Derived extends Base
    static void print (Derived c)
        System.out.print("Derived");
public class Test {
    /** Creates a new instance of Test */
    public static void main (String args[])
        SuperBase a1 = new SuperBase();
        SuperBase b1 = new Base();
        Base c1 = new Derived();
        a1.print(new Base());
        b1.print(new Derived());
        c1.print(new Derived());
}the answer to this is super super base. i compiled and checked it.
I thought the answer would be super base base.
since b1 is a object type base with a reference variable of type superbase when the method is called at runtime i thought it would make a Polymorphic call the base method. therefore printing base for this call b1.print(new Derived());
I hope someone can explain why this is not the case. Thank you for your help.

sorry sujji i still don't get it.
i thought for example if you got a horse class which extends an animal class which both contain for example an eat method ie public void eat()
then
Animal a = new Animal();
Horse b = new Horse();
a.eat(); //runs animal version
b.eat(); // runs horse version
does this mean the base method is not overidding the SuperBase class print method but actually overloading it.
void print (SuperBase a) // in SuperBase class
void print (Base b)// in Base Class
if thats the case i understand, otherwise i am now completely lost.

Similar Messages

  • Polymorphism question

    If I take a class, and cast it to the type of its super class, will the methods called on that class then be the methods of the superclass(or higher)?
    For instance I have a class
    MDIDesktopPane extends JDesktopPane
    public Component add(JInternalFrame frame){}
    Now I get the desktopPane from a method like this on a different class
    JComponent getDesktopPane(){}
    When I do this
    getDesktopPane.add( frame );
    That method is not calling MDIDesktopPane.add(JInternalFrame ) but is going all the way up the family tree to Component.add(Component ). Why? The component I am passing in is a MDIInternalFrame which extends JInternalFrame so I would expect it to like the MDIDesktopPane.add() but it does not.
    It seems like the fact that I am casting the MDIDesktopPane to a JComponent before I call add is causing it to call add on JComponent.
    What is the rule here I am missing??
    Thanks!!

    I think there is nothing wrong with this behavior. Lets take a look in the Java Language Specification (JLS) to see what's going on:
    u1.out(new Supa2());
    Compile-Time:
    Section 15.12.1:
    here the form is Primary.Identifier. Hence the method name ist "out" and the class for the search of the method definition is the type of the Primary "Untitled1".
    Section 15.12.2:
    We have a simple case: Untitled1 hat only one method "out", which is applicable, accessible and therefor most specific.
    Section 15.12.3:
    The method found is appropriate and the information stored for the invocation at run time is: method with name "out" having one parameter of type "Supa1", result type String, invocation mode virtual, qualifying type Untitled1.
    Run time:
    Section 15.12.4.1: Target reference is the value of field u1.
    Section 15.12.4.2: No problems here.
    Section 15.12.4.3: Method is accessible. No linkage problems.
    Section 15.12.4.4: The interesting part:
    Method "out" of class "Untitled1" is the one to be invoked.
    dynamic method lookup (virtual) is used: the run-time class of the target object ist "Untitled3". Initially S is "Untitled3".
    No we take a close look to 1. and we see:
    Untitled3 DOES NOT CONTAIN a method "out" with one parameter of type "Supa1"!!! It has a method "out" with one parameter of type "Supa2". "Supa1" and "Supa2" are two different types.
    Now in 2. S got the superclass of S, namely "Untitled1". There we have a method "out" where everything matches the requirements.
    That's the reason why the output is "Untitled1".
    u1.out(new Supa1());
    Exactly the same.
    Now what happens in the last case:
    u1.out2();
    Compile-Time:
    15.12.1: name "out2", primary "Untitled1"
    15.12.2: applicable, accessible and most specific
    15.12.3: stored for run-time: name "out2", having no parameters, return type String, invocation mode virtual, qualifying type "Untitled1".
    Run-Time:
    15.12.4.1: Target reference is value of field u1.
    15.12.4.2 and 15.12.4.3: No problems here.
    15.12.4.4:
    Method "out2" of class "Untitled1" is the one to be invoked.
    dynamic method lookup is used: run-time type of target object is "Untitled3". S is "Untitled3". The close look to 1. shows:
    S HAS A method with all requirements.
    Therefore the output here is "Untitled3".
    To make a long story short:
    The method "out" in Untitled3 DOES NOT overwrite the method "out" in Untitled1 because they have different parameter types (Yes: a more specific parameter type, but different)
    The method "out2" in Untitled3 DOES overwrite the method "out" in Untitled1.

  • Simple polymorphism question

    Hi,
    I'm trying to get the following behavior in Java. Does anyone have any insight?
    interface Type{}
    class TypeA implements Type{}
    class TypeB implements Type{}
    class TypeC implements Type{}
    class TypeZ implements Type{}
    Class Differentiator
      void method(TypeA a, TypeB b, TypeC c){}
      void method(TypeA a, TypeA a2, TypeC c){}
      void method(TypeA a, TypeB b, TypeZ z){}
    Class MainProgram
      public static void main(String[] args)
        Type obj1 = new TypeA();
        Type obj2 = new TypeF();
        Type obj3 = new TypeZ();
        Differentiator D = new Differentiator();
        D.method(obj1,obj2,obj3);
    }from my main() function. It should call the appropriate method() depending on the types of object that are passed to it. If none of the defined methods fit, it should throw a NotImplemented exception.
    Seems like a pretty straightforward problem. But I can't find a solution.
    Thanks a lot
    Cuppo
    Edited by: CuppoJava on Dec 3, 2007 3:54 AM

    You're basically looking for dynamic/multiple dispatch, which is not something that is part of Java. If you want to simulate that behavior, you will have to use reflection.
    http://www.lshift.net/blog/2006/06/23/multimethods-for-java
    might be a good starting point

  • How to store the data?

    Hi,
    I'm new here, new to java
    I have a java polymorphism question here, I have three classes,
    Bicycle.java
    public class Bicycle {
    public void printClassName() {
    System.out.println("Bicycle");
    MountainBike.java
    public class MountainBike{
    public void printClassName() {
    System.out.println("MountainBike");
    TestBike.java
    public class TestBike {
    public ststic void main(String[] args) {
    String type = "MountainBike";
    Bicycle bike = new "type()";
    bike.printClassName();
    definitely, the type() is not correct here, is there any way to init the bike with a dynamic class without using switch/case?
    Thanks.
    peter

    thanks, everyone, I got it finally.
    actually, MountainBike is a subclass of Bicycle, I had a typo here,
    my code something like that using java reflection,
    TestBike.java
    public class TestBike {
    public ststic void main(String[] args) {
    String type = "MountainBike";
    CLass c = Class.forName(type);
    Method m = c.getDeclareMethod("printClassName", null);
    Object i = c.getnewInstance();
    Object r = m.invoke(i, null);
    I never used newInstance before, don't know the performance, because I may have lots of newInstance called.
    sorry for the misleading of subject, actually, I want to ask another question to store data,
    I had more than 40 files, I'd like to create a big xml to store the info of these files, like
    <A>
    <column>
    <name>AC1</name>
    <size>4</size>
    <name>AC2</name>
    <size>3</size>
    </column>
    </A>
    <A2>
    <column>
    <name>A2C1</name>
    <size>4</size>
    <name>A2C2</name>
    <size>3</size>
    </column>
    </A2>
    because A, A2 is not a constant, I don't know how to parse the xml file with java, or I create seperate xml file like
    A.xml
    <column>
    <name>AC1</name>
    <size>4</size>
    <name>AC2</name>
    <size>3</size>
    </column>
    any idea?
    Thanks.
    peter

  • Question about polymorphism

    hi
    I've got a question regarding polymorphism in java:
    public class Test1 {
        public Test1() {
            Test3 t3=new Test2();
            t3.output();
            t3.value1=9; //not possible
        public static void main(String[] args) {
            new Test1();
    public class Test2 extends Test3 {
        public int value1=5;
        @Override
        public void output() {
            System.out.println("the value is "+value1);
    public class Test3 {
        public void output(){
            System.out.println("class: Test3");
    output of the program:
    the value is 5why do i have no access from "Test1" to the member variable "value1" which is initialized in class "Test2" although i'm calling the constructor "Test2()"?
    and why is the output of the program "the value is 5" although I've got no access to "value1" from "Test1" like i said before?

    becky3 wrote:
    why do i have no access from "Test1" to the member variable "value1" which is initialized in class "Test2" although i'm calling the constructor "Test2()"?Because the type of t3 is reference to Test3, and Test3 does not have a value1 variable. The compiler doesn't know that at runtime that reference is going to point to a subclass of Test3 that does have that variable.
    and why is the output of the program "the value is 5" although I've got no access to "value1" from "Test1" like i said before?Because that's how Java's runtime polymorphism works. When you call an overridden method, it's the runtime class of the object that determines whose version of that method gets called. Since the object is a Test2, it's Test2's implementation of the method that gets called. The caller and type of reference don't have to know about the internal details of that class. Only that it's a subclass of Test3, and therefore exposes all the same public instance members as Test3.

  • Another Question about polymorphism

    If you rewrite a method in your subclass, you could cause a serious problem. I just rewrote a coupl of methods in swing and all hell broke lose?
    jPanelBidBox = new JPanel(){
    private boolean visible;
    setLayout(new GridBagLayout());
    setBorder(new TitledBorder(new CompoundBorder(new MatteBorder(new Insets(2, 2, 2, 2), new Color(0, 51, 255)), new LineBorder(new Color(0, 0, 0), 2)), "Bidding Box"));
    setToolTipText("Bidding Box");
    setVisible(false);
    public void setVisible ( boolean test ) {
    super.setVisible (test);
    public boolean isVisible () {
    return visible;
    If you rewrite some methods from the superclass, you better hope nobody above you is using the code for anything meaningful.
    So I dont quite understand what the polymorphism is all about. It is nice to define a toString for your subclass, you just better hope nobody is using it in your super classes.

    I had a line missing in th code, the correct code i tried is
    jPanelBidBox = new JPanel(){
    private boolean visible;
    setLayout(new GridBagLayout());
    setBorder(new TitledBorder(new CompoundBorder(new MatteBorder(new Insets(2, 2, 2, 2), new Color(0, 51, 255)), new LineBorder(new Color(0, 0, 0), 2)), "Bidding Box"));
    setToolTipText("Bidding Box");
    setVisible(false);
    public void setVisible ( boolean test ) {
    visible = test;
    super.setVisible (test);
    public boolean isVisible () {
    return visible;
    But still didnt help. I looked in the API, and somehow I missed the isVisible method, so I tried to define it for my class. That is what i was trying to do. But it just broke everything.

  • Question regarding Polymorphic VIs

    Let's use Read Key as an example (from the Configuration File VIs).
    I want to wrap Read Key (which is Polymorphic) so that some other code always runs right before Read Key. However, to do this, it seems I have to make an instance of the wrapper VI for each output type that Read Key supports if I want it to support all the types. This is disappointing since in C++ or Java you'd just use a template or generic and you wouldn't need to do all this extra work. Is there a way around this when working with Polymorphic VIs?
    The alternative is to always remember to put this code right before Read Key. Another less than optimal solution. If I want tightly connected and cohesive code, I want one VI and not a half dozen of them!
    Anyways, this is almost certainly not possible so I guess this is more of a complaint haha.
    Solved!
    Go to Solution.

    Vote up this idea in the LabVIEW Idea Exchange:http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Provide-a-better-way-to-implement-a-polymorphic-VI/idi...
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Polymorphism - basic question

    Let's say I have three classes:
    public class Pet
        private Integer id;
        private String name;
        private Double weight;
        public Integer getId() {
            return id;
        public void setId(Integer id) {
            this.id = id;
        public String getName() {
            return name;
        public void setName(String name) {
            this.name = name;
        public Double getWeight() {
            return weight;
        public void setWeight(Double weight) {
            this.weight = weight;
    public class Cat extends Pet
        private Integer lives;
        public Integer getLives() {
            return lives;
        public void setLives(Integer lives) {
            this.lives = lives;
    public class Dog extends Pet
        private Integer numBones;
        public Integer getNumBones() {
            return numBones;
        public void setNumBones(Integer numBones) {
            this.numBones = numBones;
    }Now do the following:
        Pet pet1 = new Cat();
        Pet pet2 = new Dog();The problem is as Java is strongly typed language, therefore I can't invoke:
         pet1.setLives(9);although I know that pet1 actually wraps the instance of type Cat.
    I'm not sure if this is even possible to do this or not. Maybe there is some design pattern as this is a very common problem. I know about the "strategy pattern" but it doesn't seem to solve this problem.

    Thanks for reply!
    I don't know the instance type at the compile time (it be set to Cat or Dog at runtime). Here is my situation.
    I have a JSF page with references to the object in question (for the sake of consistency let's say it's an object of type Pet).
    <h:inputText value="#{BackingBean.pet.lives}" rendered="..." /> // this is rendered only if the Pet is of type Cat
    <h:inputText value="#{BackingBean.pet.numBones}" rendered="..." /> // this is rendered only if the Pet is of type Dog... where BackingBean.pet returns object of type Pet (which can be either Cat or Dog).
    What I want to do here is to populate the Cat's/Dog's property directly but I can't do that as Cat instances don't have setNumBones and Dog instances don't have setLives.
    This could probably be solved by declaring Pet as an abstract class with abstract methods setLives, getLives, setNumBones, getNumBones an then implement those methods only in relevant subclasses and leave others empty, but I think this approach is not the "cleanest".
    I know there is other option to do what I want but as this is pretty common scenario I am asking for help.

  • Question about Polymorphism And L&F

    I'm working on developing my own custom look and feel. I am somewhat new to java but have a somewhat extensive knowledge of the language for how long I have been studying it(about 2 years). I'm just getting into the idea of polymorphism while working on my L&F. I'm having some trouble with abstract methods and sublasses.
    This is what I have so far...
    public class EdgeLookAndFeel extends LookAndFeel
         //These methods describe the look and feel
         public abstract String getName();
         public abstract String getDescription();
         public abstract String getID();
         class definingMethods
              public String getName()
                   String lookAndFeelName = "Edge";
                   return lookAndFeelName;     
              public String getDescription()
                   String lookAndFeelDescription = "Edge Look And Feel - (c)2005 Java Edge Studios Inc. All Rights Reserved";
                   return lookAndFeelDescription;     
              public String getID()
                   String lookAndFeelID = "(c)2005 Java Edge Studios Inc.";
                   return lookAndFeelID;
                         ...I'm getting an error saying that my because my main class isn't abstract that I can't overide the abstract methods the define my look and feel.
    So... do I need to define my main class as abstract? Also, am I doing good on applying the concept of polymorphism?

    I feel you should have your code look something like this:
    public abstract class EdgeLookAndFeel extends LookAndFeel
         //These methods describe the look and feel
         public abstract String getName();
         public abstract String getDescription();
         public abstract String getID();
    public class EdgeLFImpl extends EdgeLookAndFeel {
         public String getName() {
                   String lookAndFeelName = "Edge";
                   return lookAndFeelName;     
         public String getDescription() {
                   String lookAndFeelDescription = "Edge Look And Feel - (c)2005 Java Edge Studios Inc. All Rights Reserved";
                   return lookAndFeelDescription;     
         public String getID() {
                   String lookAndFeelID = "(c)2005 Java Edge Studios Inc.";
                   return lookAndFeelID;
    }

  • How to create ADF UI based on polymorphic view objects

    Hi,
    I'm using JDeveloper build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660. I created a simple application based on Steve's example #10 [url http://blogs.oracle.com/smuenchadf/examples/]ViewRow and EntityObject Polymorphism.
    I added a men-only attribute "Age" to the "Men" VO and filled it with an arbitrary value in MenRowImpl.java:
    public String getAge() {
         return (String) "45";//getAttributeInternal(AGE);
    }Running the TestModule works perfectly - a row of type "Men" displays the "Age" attribute whereas a row of type "Women" doesn't.
    Afterwards, I setup an ADF ViewController Project and created a JSPX with a read-only form based on the "People" datacontrol with navigation buttons. Running that page always shows the same set of attributes independent of the row type. That's expected behaviour because the binding is defined at design time.
    So my question is: can I somehow achieve the same behaviour for polymorphic VOs as the business component tester shows?
    Kind regards,
    Markus

    Andrejus' example shows how to calculate different values for the same attribute based on overridden view objects. That's not exactly what I'm looking for. I need to display a (at least partly) different set of attributes that changes while the user scrolls through the records of the result set.

  • List of Questions on BAPI and OOPs

    Hi All,
       I am new to the OOPs and BAPI's.can any one gives me complete idea on below questions by providing good examples.
    1) Importance of the class, Interface type, Object and Instance ?
    2) Why we need oops concepts since we are using normal process successfully, i mean with out oops also ?
    3) functionality of BAPI ?
    4) Difference between COMMIT WORK and BAPI_TRANSACTION_COMMIT ?
    5) Why COMMIT WORK wont useful for BAPI's ?
    6) If you give me good source code to understand the concepts of class, Interface type, Object and Instance?
    7) In real time situations, do we need to create classes or in SAP we will use only existed bapis?
    8) The process of creating customized BAPI's [entire scenario]
    Since i asked lot of questions in one thread, i decided to give rewards even if you provide me solution for any of the above.
    Thanks
    Jaya

    Hi Jaya,
    Answer 1. Class is a template for creating objects. Object can also be called as instance.
    Interfaces allow you to use different classes in a uniform way (polymorphism).
    Answer 2. Normal abap is a procedural programming where as by using abap objects we can achieve object oriented programing.
    Answer 6. Source code:
    In below code i have created a interface and a class which is implementing the interface. I have declared a reference variable of type interface and created a object. Then i have called a method.
    REPORT  ZABAPOBJECTS_INTERF.
          INTERFACE I1
    INTERFACE I1.
      METHODS METH1.
    ENDINTERFACE.                    "I1
          CLASS C1 DEFINITION
    CLASS C1 DEFINITION.
      PUBLIC SECTION.
        METHODS: METH2.
        INTERFACES: I1.
    ENDCLASS.                    "C1 DEFINITION
          CLASS C1 IMPLEMENTATION
    CLASS C1 IMPLEMENTATION.
      METHOD I1~METH1.
        WRITE: / 'This is a method one'.
      ENDMETHOD.                                                "I1~METH1
      METHOD METH2.
        WRITE: / 'This is a method two'.
      ENDMETHOD.                                                "METH2
    ENDCLASS.                    "C1 IMPLEMENTATION
    START-OF-SELECTION.
      DATA : REF1 TYPE REF TO I1.
      CREATE OBJECT REF1 TYPE C1.
      CALL METHOD REF1->METH1.
    Question 7: Yes we need to create a class but most probably we use the existing classes.
    Regarding BAPi's go through the below links,
    http://www.sapgenie.com/abap/bapi/example.htm
    http://www.sapdevelopment.co.uk/bapirfc/bapirfchome.htm
    Regards,
    Azaz Ali.

  • General questions on IDOCs and IDOCs for 2 Accounting Interface BAPIs

    This post involves several questions pertaining to the topic of IDOC creation. I downloaded a couple of PDFs and tried googling for material on that, but things are far from being clear in my mind.
    I tried to put my questions in some order, so we can follow a line of reasoning. Here we go, then:
    I have one code where I there are calls to 2 BAPIs:
    - BAPI_ACC_ACT_POSTINGS_REVERSE and
    - BAPI_ACC_GL_POSTING_REV_POST
    I am supposed to prepare/create an IDOC to perform the activities these BAPIs are responsible for, for the sole purpose of providing us much more details on the activities being executed in the system - this is one of the IDOC's features, if I got it right, its highly detailed logging of everything that is going on behind.
    Now, the 1st question arises:
    From the material I read, I understood that IDOCs are nothing more than data containers, whose sole purpose is to provide a means of communication between two different systems/parties - one of them would usually be SAP. If this is right, than what sort of IDOC would be this one I am supposed to build - if there's not going to be any inter-system communication ? Doesn't it sound strange that pure "data containers" can work as "logging functions" ? Please share some light here.
    The 2nd question - after I understand what an IDOC really is - is
    then connected to the job I have to do. I found 2 IDOCs which I think have the proper/correspondent basic types for the 2 aforementioned BAPIs. They are, respectively:
    - ACC_DOCUMENT_REVERSE01 and
    - ACC_GL_POSTING_REVERSE01
    Getting back to my understanding of IDOCs, I got that every IDOC is generally made of one control record, data record(s), and status record(s). 3rd question: Where do the segments fit in ? Are the segments definitions of the Data Records ? And why is it that some IDOC types have header segments only and others doesn't have one ? (header segments are not the same as control records, right ?)
    Finally, what is the general process flow for creating/preparing an IDOC ? I looked over a couple of forum posts about this but some of them differ one from another in the order of the steps, some don't mention this or that step, so I am still confused.
    4th and last question: what comes first ? The definition of a partner, the bonding of a message type with an IDOC basic type, definitions of the inbound/outbound interfaces ?
    Any help here would be highly appreciated.
    Thanks in advance,
    Avraham

    Hi Jaya,
    Answer 1. Class is a template for creating objects. Object can also be called as instance.
    Interfaces allow you to use different classes in a uniform way (polymorphism).
    Answer 2. Normal abap is a procedural programming where as by using abap objects we can achieve object oriented programing.
    Answer 6. Source code:
    In below code i have created a interface and a class which is implementing the interface. I have declared a reference variable of type interface and created a object. Then i have called a method.
    REPORT  ZABAPOBJECTS_INTERF.
          INTERFACE I1
    INTERFACE I1.
      METHODS METH1.
    ENDINTERFACE.                    "I1
          CLASS C1 DEFINITION
    CLASS C1 DEFINITION.
      PUBLIC SECTION.
        METHODS: METH2.
        INTERFACES: I1.
    ENDCLASS.                    "C1 DEFINITION
          CLASS C1 IMPLEMENTATION
    CLASS C1 IMPLEMENTATION.
      METHOD I1~METH1.
        WRITE: / 'This is a method one'.
      ENDMETHOD.                                                "I1~METH1
      METHOD METH2.
        WRITE: / 'This is a method two'.
      ENDMETHOD.                                                "METH2
    ENDCLASS.                    "C1 IMPLEMENTATION
    START-OF-SELECTION.
      DATA : REF1 TYPE REF TO I1.
      CREATE OBJECT REF1 TYPE C1.
      CALL METHOD REF1->METH1.
    Question 7: Yes we need to create a class but most probably we use the existing classes.
    Regarding BAPi's go through the below links,
    http://www.sapgenie.com/abap/bapi/example.htm
    http://www.sapdevelopment.co.uk/bapirfc/bapirfchome.htm
    Regards,
    Azaz Ali.

  • RE: Polymorphism - retrieving type information from thedatabase or how

    Don,
    Ok but if I was to model a real restaurant, I would then have a head chef
    that can then delegate to other chefs. This head chef would have the
    additional task of coordinating the completion of subservient chefs. This
    does not and would not mean that the head chef is stuck (or partitioned) in
    one part of the kitchen. Further a head chef would most likely also be a
    chef so that he would be running around the kitchen using and interacting
    with different objects to get his part of the recipe completed. Then once
    all chefs have completed their part of the recipe the head chef could return
    the meal.
    I would also point out that it does not make sense to me to be talking about
    the chef and its ability to scale. I would look that the resource limited
    devices that must be used to prepare meals to see scalability. In this case
    the grill, the stove and the microwave. Scalability of the restaurant is a
    function of the amount of resource limited devices versus the number of
    process (i.e. chefs) that need to use those devices concurrently and the
    amount of time they require access to those devices. By talking about chefs
    as if they are the scalability limiting factor seems to bring us back to the
    notion that the chef is a manager object that is shared. And again I come
    back to the question, why?
    You may now think that in a real restaurant, there are only so many chefs so
    why not make it a shared service? Well in a real restaurant there are only
    so many of any object, but this is not a consideration in our restaurant
    model. In our "virtual" restaurant hiring a chef is as easy as:
    Chef = new;
    And of course chefs are of zero mass so there can be a whole lot in the
    kitchen. Now assuming the Grill, Stove and Microwave map to physical
    objects in our computing environment, then that is the limiting factor and
    are therefore partitioned. Whenever communication has to go through a
    single source, then scalability breaks down. I fear that too many people
    make shared objects and create communication bottlenecks where they simply
    don't exist. The only place your scalability bottlenecks should exist is in
    the actual resource limited objects of your computing environment. Simply
    said, if something isn't a resource limited object, then why is it shared?
    If anyone is not clear how to architect an application independently of the
    business model, then I would suggest looking at various framework products
    and reading some technical architecture white papers to get a different, and
    possibly enlightening, point of view.
    Mark Perreira
    Sage IT Partners.
    -----Original Message-----
    From: Don Nelson [mailto:[email protected]]
    Sent: Wednesday, June 17, 1998 9:04 AM
    To: Mark Perreira
    Cc: [email protected]
    Subject: RE: Polymorphism - retrieving type information from the
    database
    Mark,
    First, I completely agree about the naming. I purposely used rather
    euphamistic names for these "managers", since I see many convoluted names
    for common things in various applications. But that is a topic for another
    thread...
    Simply because there is a "manager" of some type, does not imply that it is
    chained to a particular duty. However, let's look at a real life case. In
    a large restaurant, you would rarely see a chef chopping carrots or serving
    dishes to customers. Those are the responsibilities of the sous-chef and
    the waiter. So, we see that the chef does not really follow the food
    around. Why not? Because it simply doesn't scale. When scalability isn't
    a problem, (the restaurant isn't that popular, for example) the chef has
    some lattitude to accept more responsibility, and might even get involved
    with purchasing, etc.
    In the real world, the more scalable something has to be, the narrower the
    responsibilities are for each of the participating members.
    Don
    At 12:59 AM 6/17/98 -0700, Mark Perreira wrote:
    Don,
    One thing that always baffles me is when should an Object get the moniker
    "Manager." This practice seems to tell me a couple of things about these
    objects. In general when someone makes reference to a "Manager" objectthat
    it is probably a service object and probably contains no or very little
    attribution. The question is why? If I am developing an object model why
    am I thinking about such implementation issues.
    Surely if you are trying to model cooking an egg I would not see
    "SustenancePreparationManager" in your model. Using a more common term I
    would still be alarmed to see "CookManager" in your model. What does the
    CookManager manage? Does it manage other cooks or eggs. Maybe it shouldbe
    called an EggManager, but that doesn't make sense. How about just Cook.
    There that seems like the real world. And this brings me to a problem in
    the analogy. Conjuring up managers in a model can sometimes make you missa
    container. For example, I would say that if we wanted to model the real
    world, then eggs is a specialization of ingredient that is contained by
    recipe that can be given to a cook to be prepared.
    I may have many cooks (objects) that can prepare recipes and my application
    architecture not the object model needs to deal with how to best let those
    cooks utilize the grill, stove and microwave that sits on different
    partitions on my server. My cooks can move around and when they do they
    take their ability to know how to cook with them. In the real world Iwould
    expect a cook to use the right appliance to prepare the recipe based on its
    contents. I would not chain every cook to its appliance and them make me
    responsible for giving the right cook the right recipe. This is what
    managers can cause. They cause the consumer of cooks to know which cookcan
    prepare what recipes based on where they are chained. This then makes me
    know something about cooking. And if I don't know anything about cooking I
    can only image what my egg would look like if I accidentally gave therecipe
    to the cook stationed at the microwave.
    Ok Ok, I have seen many architectures use facades to hide the fact that I
    like to chain my cooks to their appliance. But what is that. I have gone
    to restaurants and I don't know what a cook facade is. If I ask themanager
    to present the cook facade manager employee I would probably be met by the
    bouncer employee.
    So what is the answer? Well for a start keep the application architecture
    out of the model. The model should stand alone in describing the
    interactions required to satisfy use cases. Second find an architecture
    that describes a more responsibility driven design and how that design and
    can map your business object behavior to a physical implementation with
    appliances and cooking rules. And lastly, don't be so quick to chain your
    cooks to their appliances. Give them some control over where they cook
    their recipes, after all that is what they do.
    Mark Perreira
    Sage IT Partners.
    -----Original Message-----
    From: [email protected]
    [<a href="mailto:[email protected]">mailto:[email protected]]On</a> Behalf Of Don Nelson
    Sent: Tuesday, June 16, 1998 2:07 PM
    To: Nick Willson
    Cc: [email protected]
    Subject: Re: Polymorphism - retrieving type information from the
    database
    This thread is switching context a bit, but I would add one thought tothe
    idea of encapsulating behavior. One of the advantages to OO is that it
    helps us model real world behavior. In the real world, I would not askan
    invoice to stuff itself into an envelope and mail itself to its
    customer; I
    would not ask my vehicle to fuel itself or change its own oil; I wouldnot
    tell an egg carton to ask one of its eggs to fry itself. Even if these
    things were physically feasible, I could list a number of reasons why I
    still wouldn't want to do them. That is why we haveVehicleRepairManagers
    and SustenancePreparationManagers (aka, "Mechanics" and "Cooks").
    Don
    At 11:28 PM 6/15/98 -0700, Nick Willson wrote:
    Tim,
    You've had lots of good suggestions so I hope you won't mind an attempt
    at another one. The consensus seems to be for your option (1) for the
    Vehicle table, and Steve's example of a GenericConstraint (taking the
    place of your Vehicle) is probably how most people would go about
    answering your question. I don't have much to add to that, just wanted
    to offer something about where the persistence mechanism lives and how
    things look to clients that depend on it.
    Suppose for a moment you think about the Vehicle classes' persistence as
    being just one aspect of their behavior. In addition to persistence,
    you might have to implement security, or locking for concurrent access,
    or caching of vehicle objects to improve performance, and of course you
    want to calculate the vehicle tax and probably do other things with
    Vehicles too.
    You can put the persistence aspect of Vehicles into a
    PersistenceObjectManager, but then the others need somewhere too. If
    you use a bunch of Managers (one for security, one for locking...) then
    each class's behavior is scattered across these various Manager classes,
    each of which has to know about many classes. Or if you use one Manager
    class, it's going to know still more, plus you are forced to implement
    all the behavior in (or at least via) that manager's partition.
    An alternative would be to keep all the Vehicle classes' behavior
    encapsulated together, so a client always makes requests to a Vehicle,
    and the Vehicle delegates the implementation of requests to a chain of
    handler objects that hang off the vehicle object (a handler for
    security, another for persistence, and so on).
    One of the nice things about this is, the handlers can be responsible
    for going to another partition (if necessary), e.g. to perform
    persistence operations, or for more business-specific operations like
    tax calculations. And because the handlers are smart, you don't have to
    put a lot of code into service objects, the SOs can stay pretty simple.
    This isn't an approach you'll see in Express, so I hope of it's of some
    interest.
    General wrote:
    Part 1.1 Type: Plain Text (text/plain)
    Encoding: quoted-printable--
    Nick Willson
    SCAFFOLDS Consultant,
    Sage IT Partners, Inc.
    (415) 392 7243 x 373
    [email protected]
    The Leaders in Internet Enabled Enterprise Computing
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>>
    >>>
    >>
    >>
    ============================================
    Don Nelson
    Regional Consulting Manager - Rocky Mountain Region
    Forte Software, Inc.
    Denver, CO
    Phone: 303-265-7709
    Corporate voice mail: 510-986-3810
    aka: [email protected]
    ============================================
    "When you deal with higher numbers, you need higher math." - Hobbes
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>
    >
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >
    >
    ============================================
    Don Nelson
    Regional Consulting Manager - Rocky Mountain Region
    Forte Software, Inc.
    Denver, CO
    Phone: 303-265-7709
    Corporate voice mail: 510-986-3810
    aka: [email protected]
    ============================================
    "When you deal with higher numbers, you need higher math." - Hobbes
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>

    Don,
    You are absolutely correct. But this is where I honestly think you are
    missing the point. While the mail program sends the mail, my mail message
    has an interface (i.e. send button) which can delegate that to the mail
    program. This makes it nice and simple for me the consumer of the mail
    program. It also means I can think of mailing by focusing on the interface
    (i.e. the button). It would suck if every time I wanted to mail something I
    had to identify the correct pop server to send it to (i.e the MailManager).
    Mailing something is the collaboration of the setup information of the mail
    program and my mail message. If I were to model this my mail object would
    indeed have a send method that could delegate to the correct mail servers.
    This is just simplicity of interface and it is a good practice in UI
    development just as it is in business model development. A simpler
    interface, I think we can all agree, provides for a better and quicker
    understanding.
    Mark Perreira
    Sage IT Partners.
    -----Original Message-----
    From: [email protected]
    [<a href="mailto:[email protected]">mailto:[email protected]]On</a> Behalf Of Don Nelson
    Sent: Thursday, June 18, 1998 9:22 AM
    To: Nick Willson
    Cc: [email protected]
    Subject: Re: Polymorphism - retrieving type information from the
    database
    Nick,
    It turns out that your message does not, indeed send itself. Your mailing
    program does that.
    Don
    At 11:54 PM 6/17/98 -0700, Nick Willson wrote:
    Hey Don,
    In the real world, no, you can't tell an invoice to put itself into anenvelope
    and mail itself. You have to know about stamps and post boxes and wherethey
    are located. But isn't it nice that in software you don't have to followthe
    real world very closely if you don't want to?
    Above the top left hand corner of this message I'm typing right now, thereis a
    send button which lets me tell the message to 'stuff itself into anenvelope
    and mail itself'. Why wouldn't you want to do that?
    Don Nelson wrote:
    This thread is switching context a bit, but I would add one thought to
    the
    idea of encapsulating behavior. One of the advantages to OO is that it
    helps us model real world behavior. In the real world, I would not askan
    invoice to stuff itself into an envelope and mail itself to its customer;I
    would not ask my vehicle to fuel itself or change its own oil; I wouldnot
    tell an egg carton to ask one of its eggs to fry itself. Even if these
    things were physically feasible, I could list a number of reasons why I
    still wouldn't want to do them. That is why we haveVehicleRepairManagers
    and SustenancePreparationManagers (aka, "Mechanics" and "Cooks").
    Don
    At 11:28 PM 6/15/98 -0700, Nick Willson wrote:
    Tim,
    You've had lots of good suggestions so I hope you won't mind an attempt
    at another one. The consensus seems to be for your option (1) for the
    Vehicle table, and Steve's example of a GenericConstraint (taking the
    place of your Vehicle) is probably how most people would go about
    answering your question. I don't have much to add to that, just wanted
    to offer something about where the persistence mechanism lives and how
    things look to clients that depend on it.
    Suppose for a moment you think about the Vehicle classes' persistence as
    being just one aspect of their behavior. In addition to persistence,
    you might have to implement security, or locking for concurrent access,
    or caching of vehicle objects to improve performance, and of course you
    want to calculate the vehicle tax and probably do other things with
    Vehicles too.
    You can put the persistence aspect of Vehicles into a
    PersistenceObjectManager, but then the others need somewhere too. If
    you use a bunch of Managers (one for security, one for locking...) then
    each class's behavior is scattered across these various Manager classes,
    each of which has to know about many classes. Or if you use one Manager
    class, it's going to know still more, plus you are forced to implement
    all the behavior in (or at least via) that manager's partition.
    An alternative would be to keep all the Vehicle classes' behavior
    encapsulated together, so a client always makes requests to a Vehicle,
    and the Vehicle delegates the implementation of requests to a chain of
    handler objects that hang off the vehicle object (a handler for
    security, another for persistence, and so on).
    One of the nice things about this is, the handlers can be responsible
    for going to another partition (if necessary), e.g. to perform
    persistence operations, or for more business-specific operations like
    tax calculations. And because the handlers are smart, you don't have to
    put a lot of code into service objects, the SOs can stay pretty simple.
    This isn't an approach you'll see in Express, so I hope of it's of some
    interest.
    General wrote:
    Part 1.1 Type: Plain Text (text/plain)
    Encoding: quoted-printable--
    Nick Willson
    SCAFFOLDS Consultant,
    Sage IT Partners, Inc.
    (415) 392 7243 x 373
    [email protected]
    The Leaders in Internet Enabled Enterprise Computing
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >>>
    >>>
    >>
    ============================================
    Don Nelson
    Regional Consulting Manager - Rocky Mountain Region
    Forte Software, Inc.
    Denver, CO
    Phone: 303-265-7709
    Corporate voice mail: 510-986-3810
    aka: [email protected]
    ============================================
    "When you deal with higher numbers, you need higher math." - Hobbes--
    Nick
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href="http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    >
    >
    ============================================
    Don Nelson
    Regional Consulting Manager - Rocky Mountain Region
    Forte Software, Inc.
    Denver, CO
    Phone: 303-265-7709
    Corporate voice mail: 510-986-3810
    aka: [email protected]
    ============================================
    "When you deal with higher numbers, you need higher math." - Hobbes
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:<a href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>>

  • Interview questions?plz answer

    hi
    i have some interview questions;can anybody share with me?
    1.what is meant by static variable and static method with an example?what r the uses?;
    2.what r the uses of Interfaces over abstract class?
    3.Name two interfaces without method?
    4.what is meant by polymorphism?explain with an example?
    5.what is meant by deadlock?
    6.what is meant by time-slicing?
    7.how can u set input and output parameters using Callablestatement with an example?
    8.what is difference between throw and throws?

    hi
    i have some interview questions;can anybody share with
    me?
    1.what is meant by static variable and static method
    with an example?what r the uses?;A static variable changes rapidly. A static method changes methodically.
    2.what r the uses of Interfaces over abstract class?Interfaces used over abstract classes form a protective layer, insulating and encapsulating them from synchronization problems.
    3.Name two interfaces without method?Trick question. No interfaces have methods.
    4.what is meant by polymorphism?explain with an
    example?Men in Hawaii can marry more than one woman. Each wife does something different when the man asks her to give him some poi.
    5.what is meant by deadlock?Bob Marley's hair.
    6.what is meant by time-slicing?Time slicing is a technique for delaying an unpleasant task. A process can continue to put it off until later by slicing the remaining time in half.
    7.how can u set input and output parameters using
    Callablestatement with an example?You ought to know that. I'm not going to help you.
    8.what is difference between throw and throws?"Throw" is singular and used with one argument. "Throws" is plural and used with multiple arguments.
    Good luck.

  • Using a polymorphic view object with binding

    Hi,
    I'm hoping there's something simple I'm missing when trying to setup up the bindings for a ADF/struts page using a polymorphic view object.
    I'm using Entity and VO polymorphism to create a Question which has different types - boolean, multi-choice, likert, etc. I have the various question types created as sub type entity and view objects and added to the app module - when added to the app module the question types are subtypes of QuestionView so they don't actually appear in the Data Controls palette. This setup is like that used in Steve Muench's examples (blog at http://radio.weblogs.com/0118231/stories/2003/02/06/constructingTheDesiredEntityInAPolymorphicViewObject.html and the related undocumented one)
    My question is, how do I get to the data and have jdev create the necessary bindings for the extra attributes the subtype questions have? Since they don't appear as available data controls I can't create a binding iterator or anything for them - short of adding them as spearate view objects (which destroys the whole point of using polymorphism in this case) is there a way to do this?
    Really, the only reason I want to use the polymorphism is so I can have different types of entity validation depending on the type. Should I just simplify this to be one entity object with one VO and put all the validation into "if else's" based on a discriminator?
    Assistance appreciated...
    - Nathaniel

    How else are you planning to associate a JUTableBinding to the 'common' iterator containing all four types of rows and then selectively display them? Perhaps you'd need a custom model over the JUTabelModel that'd filter the rows out.
    I'm not sure if all that trouble is worth it given that your datasets (as far as mentioned in this post) are not large. If these tables/data has to be refreshed/executed a number of times, then you may see the overhead of four queries otherwise it should be fine as database is always faster in filtering rows than doing that in memory.

Maybe you are looking for

  • Problem with camera after updating z1 to 14.5.A.0.270

    Hello I'm facing a problem after updating my Xperia Z1 to 14.5.A.0.27, I.e. Lollipop 5.0.2.. problem is with the camera, when I tried to capture a picture with auto flash/flash on, a bright light is appearing on the lower portion of the image. Plz he

  • Integrating windows AD with cisco ACS

    hi all i am looking for the requirements and any documents in setting up the acs with windows AD for user authentication. i am basically testing this. i am having a cisco switch a switch acs serevr 4.1 and windows xp host and windows 2003 server. can

  • Digital Camera compatability!

    So far...I love the computer, it just won't acknowledge my Sony Cyber-Shot Digital Camera. The problem is that I am running a Logitech Wireless Keyboard & Mouse and every time I plug in the USB cable for the camera to download pictures onto the compu

  • Terminal command for setting software update to defaults

    terminal command for setting software update to defaults?

  • Lost video on i cloud

    When I plugged my new I phone 5 into my computer for the first time, it ask me if I wanted to restore to an older phone or restore as a new phone.  I hit older phone, and lost all my video and pictures.  I did find the pictures in icloud, but can't f