Is it advisable to use inheritance when reusing dialogs/frames?

Hi!
While working on a project, I've noticed that there are instances when I could reuse code by creating general forms (as dialogs or windows) and subclassing them. For example, I have this set of dialogs which have a similar function: each dialog has a table (or list) of objects and functions for adding, deleting and editing objects in this table. Do you think that it's good to use inheritance in this case? That is, I create a general AddEditDeleteDialog from which to subclass particular dialogs, AddEditDeleteObject1Dialog, AddEditDeleteObject2Dialog, ...
Thanks!

Yes, of course. But to what extent? Should I include
layouting code, component initialization, event
handling, etc in the superclass (AddEditDeleteDialog),
or should I let the subclasses (AddEditDeleteObject1Dialog)
handle that?Basically, whatever is the same in all the subclasses can be placed in the superclass. If there are differences, then you should place it in the subclasses.
Things like event handling can be placed in the superclass, where each method in the event listener fires an abstract method in the superclass, which each of your subclasses implement to provide custom event handling.
Component initialization can also be used in the superclass for whatever components are used in all of the subclasses. Subclasses can then add any components which are unique to them.
You should also be aware that the purpose of inheritance is to add to the functionality of a class. If your subclass provides no extra abstract functionality then you should just use one class, and change some settings each time you need to use it for a different purpose. E.g. If your dialogs contain the same components, same actions etc but different text, then use just one class, and for each dialog, set the text for each of the components accordingly.
There is no hard/fast rule for using inheritance and how to design an object hierarchy, and as my first programming teacher used to say "every programming problem can usually be solved in loads of different ways."

Similar Messages

  • Why to use inheritance when import is sufficient

    The import directive tells the compiler where to look for the class definitions when it comes upon a class that it cannot find in the default java.lang package. After an import statement has been included in our program we can use the methods related to that class as required and we are not required to give the fully qualified names.
    In inheritance we extend a base class into a derived class so that the features and methods of the base class are available in the derived class which facilitates reusability. As per my understanding the same thing is facilitated by import statements. If it is so, why are we using inheritance if it can be done with the use of import statements?

    Import statements and inheritance are completely different things.
    Import statements tell the compiler how to expand brief class names into fully-qualified class names. It has nothing to do with the functionality of the code.
    Inheritance changes the identification and functionality of the classes, and thus the functionality of the code.
    Maybe you're really thinking about composition/delegation vs. inheritance. Composition is when a class has another class as a part of it, and delegation is when the class sends some of its work to the other class. You can have an object-oriented system without inheritance of implementations, using composition instead.

  • When to use inheritance and When to use Composition

    java support both inheratiance and composition .I also know "is a" and
    "has a realitionship" but there is always a problem with me to understanding whethere i have to use extends or having a object of a class has a member of othere class.
    and also "A pure OOP must support polimorphisim,inheretiance,encapluction,Abstraction and Composition" correct me if i am wrong
    thank you and have a nice day.

    Bruce Eckel, author of Thinking In Java, has this to say about composition vs. inheritance:
    When deciding between inheritance and composition, ask if you need to upcast to the base type. If not, prefer composition (member objects) to inheritance. This can eliminate the perceived need for multiple base types. If you inherit, users will think they are supposed to upcast.
    Choose composition first when creating new classes from existing classes. You should only used inheritance if it is required by your design. If you use inheritance where composition will work, your designs will become needlessly complicated.
    Bill Venners: Composition versus Inheritance
    Use inheritance (of implementation) only when the class satisfies the following criteria:
    1) "Is a special kind of," not "is a role played by a";
    2) Never needs to transmute to be an object in some other class;
    3) Extends rather than overrides or nullifies superclass;
    4) Does not subclass what is merely a utility class (useful functionality you'd like to reuse); and
    5) Within PD: expresses special kinds of roles, transactions, or things.
    -- from Java Design: Building Better Apps and Applets (2nd Edition), by Peter Coad and Mark Mayfield

  • When to use inheritance and when not to?

    I've just been trying find out when to use inheritance and when not to use inheritance? I know that inheritance gives advantages such as code reuse and maintainability. But when are their times not to use inheritance that may effect the design of a project?
    Also when should one consider aggregation over inheritance(is-a relationship)?
    thanks,
    plandis

    Hi
    Answering this question usually requires a few books, so, I'm sorry, it's not really as simple as choosing between using a screwdriver vs. a hammer.
    But, very short, inheritance should ideally only be used when there exist a strict 'is-a' relationship. However, sometimes it may be clever to inherit when you have a 'is-almost-a' relationship... And sometimes this is a stupid move. This depends on the context/circumstances.
    Aggregation is normally considered a 'has-a' relationship, thereby differing clearly from inheritance. The old 'car' model says "a car is-a vehicle and has-some (at least) wheels."
    The wheels are aggregated to the car class, that itself is inherited from vehicle.
    However, this is just a good rule-of-thumb and there may be circumstantial reasons for not following these guidelines.

  • We have iPad2 and Macbook Pro. Both are registered to iTunes acct (same email address). We want to be able to use Facetime when she goes off to college. Any advise greatly appreciated!

    We have iPad2 and Macbook Pro. Both are registered to iTunes acct (same email address). We want to be able to use Facetime when she goes off to college.  Any advise greatly appreciated!

    On your Mac, launch FaceTime and then go to the menubar for FaceTime->Preferences.
    Within Preferences for FaceTime, look for the entries under "You can be reached for calls at:" and click on "Add Another Email..."
    Add another email address.
    The iPad can now be used to "call" the Mac by trying to start a FaceTime connection to the alternate email address you just entered. The Mac can be used to call the iPad by trying to start a FaceTime connection to the primary email address associated with the iPad.

  • Advise on using DBMS_XA with multiple branches under one global transaction

    Dear all
    I need some advise on using DBMS_XA from PL/SQL with tightly coupled multiple branches under one global transaction. Basically, I've successfully written some PL/SQL code that in 3 different sessions attaches to 3 different branches of one global transaction and before ending each branch they can see each others uncommitted data. So far so good.
    However, I'm not sure I completely understand how each branch must call xa_end, xa_prepare and xa_commit correctly using two phase commit and my calls result in errors like:
    ORA-24767: transaction branch prepare returns read-only (XA error code 3 = Transaction was read-only and has been committed)
    ORA-24756: transaction does not exist (XA error code -4 = XID is not valid)
    ORA-02051: another session or branch in same transaction failed or finalized
    This is the structure of my programs (3 SQL*Plus sessions):
    main: Uses xid 123|0 (branch 0 of global transaction 123). This should be the coordinator that commits using two phase commit across the 3 branches
    m1.xa_start tmnoflags
    m2.DML
    m3.Wait for thread A + B to manually be started and run xa_end
    m4.xa_end tmsuccess
    m5.xa_prepare
    m6.xa_commit false
    thread A: Uses xid 123|A (branch A of global transaction 123)
    a1.xa_start tmnoflags
    a2.DML -- thread A can see main and thread B's data
    a3.xa_end tmsuccess
    a4.xa_prepare -- required?
    a5.Should we also call xa_commit false?
    thread B: Uses xid 123|B (branch B of global transaction 123)
    b1.xa_start tmnoflags
    b2.DML -- thread B can see main and thread A's data
    b3.xa_end tmsuccess
    b4.xa_prepare -- required?
    b5.Should we also call xa_commit false?
    The failing steps are:
    m5
    m6
    a4
    a5
    b4
    b5
    Before starting calling xa_end I see 3 rows in V$GLOBAL_TRANSACTION, eg (hex 7B = decimal 123):
    FORMATID GLOBALID BRANCHID BRANCHES REFCOUNT PREPARECOUNT STATE FLAGS COUPLING
    203348753 0000007B 00000000000000000000000000000000 3 3 0 ACTIVE 0 TIGHTLY COUPLED
    203348753 0000007B 0000000000000000000000000000000A 3 3 0 ACTIVE 0 TIGHTLY COUPLED
    203348753 0000007B 0000000000000000000000000000000B 3 3 0 ACTIVE 0 TIGHTLY COUPLED
    Thanks a lot in advance.
    Cheers
    Finn

    OK, I've figured it out. This is poorly documented as it's not well explained how to handle the various return codes. Turns out that all but the last xa_prepare calls return dbms_xa.xa_rdonly (tightly coupled branches are combined -- "read only" optimization), the last one returns dbms_xa.xa_ok and this is when you should call xa_commit.
    Now my next problem is that DBMS_XA doesn't work from within jobs (DBMS_JOB and DBMS_SCHEDULER), which makes it very difficult to use DBMS_XA. My purpose of using DBMS_XA is to coordinate work across multiple sessions in one transaction but if I can't easily create the multiple sessions, I'm stuck.
    When called from a job, xa_start throws:
    ORA-24789: start not allowed in recursive call
    on Oracle 11.2. In Oracle 11.1 it works, but xa_end fails with
    ORA-25352: no current transaction
    so I guess in fact the xa_start call didn't really work either, even though it returned tm_ok.
    I'm now trying to find a workaround on how to use DBMS_XA from within jobs, please comment if you have any suggestions. Or if you have any suggestions on other means of establishing the concurrent sessions (I wouldn't like to resort to external programs that need username/password to connect as password management would be a security issue).
    Thanks in advance.
    Cheers
    Finn

  • Is it advisable to use your i Pad plugged into an electrical outlet rather than the Battery in use?

    Is it advisable to use your iPad plugged into and electrical outlet rather than using the battery all the time?

    I use my iPad while it is plugged in and I use it on battery power as well.
    I use my iPad all day long at work on battery power and then come home and plug it to recharge. Typically I will use it the rest of the night while its plugged in. When the battery is fully charged, the charging process stops and you can continue to use it while it is plugged in and it will not overcharge.
    It will not hurt to use it while it is plugged in, but the beauty of having a better powered device is that it is mobile and you don't have to plug it in to be able to use it virtually all day long.

  • Is it advisable to use the charcter "&" in customer numbers and in business

    Is it advisable to use the charcter "&" in customer numbers and in business partner naming?
    Are there any restrictions in using wild characters for customer numbers. KNA1-KUNNR field.

    Dear Chandramouli,
    In the name you can use but in the no. not advisable I believe. When you are defining the no range, it is as following:
    Intervals can only contain either letters or numbers, as sorting can differ between platforms (Code page):
    Allowed:  000001 to 999999
      AAAAAA to ZZZZZZ
    Not allowed:  AAAAAA to 999999
    Please find the SAP help on this.
    Thanks,
    Atin

  • Using Express when the database schema does not match theclass model

    We are working on a large pay/personnel management system and are
    evaluating Forté Express and Sage Scaffolds. We need to answer some big
    questions in the near future, and I was hoping that there may be someone
    out there with the answers.
    1. How different can the database schema and the class model be, before
    Express becomes a bad choice of framework? What solutions exist for cases
    where Express is still a viable option?
    2. Assuming that we can get around the problem in question 1, will the
    Application Model features still work afterwards? (i.e. how sensitive are
    the client-side services to changes in the database services?)
    3. Express seems to use domain classes everywhere, whereas we are always
    being advised to use scalar attributes wherever possible. How badly does
    this affect the performance of Express applications?
    4. Has anybody out there used Sage Scaffolds on a large project recently?
    How did it go? What problems should we watch out for? Doesn't its 'Chain
    of Responsibility' pattern tend to produce a lot of unnecessary objects at
    run-time?
    5. Has anybody used the Born collection classes? How do they compare with
    Brahma's Fortify?
    Thanks to those who have already helped - all input gratefully received!
    Tim Kimber
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    I did all that before posting the orignial post..
    declare
      v_schema_exists varchar2(1) := 'N';
      res             boolean;
      schemaURL       varchar2(100) := 'T0090.xsd';
      schemaPath      varchar2(100) :=  '/prmt/xsd/T0090.xsd'; --'/public/T0090.xsd';
      xmlSchema xmlType := XMLTYPE(bfilename('DIR_PRMT_OUT_CVIEW','T0090.xsd'),NLS_CHARSET_ID('AL32UTF8'));
    begin
      begin
        select 'Y'
          into v_schema_exists
          from sys.all_xml_schemas  -- changed from user_xml_schemas
         where schema_url = schemaURL;
        dbms_xmlSchema.deleteSchema(schemaURL,4);
        exception
          when NO_DATA_FOUND then
            null;
      end;
      if (dbms_xdb.existsResource(schemaPath)) then
        dbms_xdb.deleteResource(schemaPath);
      end if;
      res := dbms_xdb.createResource(schemaPath,xmlSchema);   
      dbms_xmlschema.registerSchema ( schemaURL, xdbURIType(schemaPath).getClob(), TRUE, TRUE, FALSE, TRUE );
    end;
    / I guess my understanding was that I could grant another oracle user access to my registered schema just like I can grant a single user access to a table. Evidently I only have two options. Only the schema owner can use the schema or everyone can use the schema and I cannot grant access to a single user other than myself.
    Edited by: Mark Reichman on Jul 2, 2010 9:08 AM
    Edited by: Mark Reichman on Jul 2, 2010 9:09 AM

  • What ADSL modem do you advise to use with my new airport extreme? I have tried a basic TP-Link ADSL2  modem and I can't get the configuration working. What modem does Apple recommend?

    I am having problems setting up airport extreme.
    What ADSL modem do you advise to use with my new airport extreme? I have tried a basic TP-Link ADSL2+  modem and I can't get the configuration working. What modem does Apple recommend?

    Ok well I have looked around some more and have found this to be the most up to date official response to my question as seen at this link here:
    http://www.actiontec.com/support/product_details.php?pid=41#q27
    Can I Bridge the Actiontec MI424WR router that Verizon provided, when I signed up for FiOS service?
    The MI424WR does not have a bridging option, and neither Verizon nor Actiontec support attempting to bridge it.
    The desire to bridge the MI424WR is based on a misunderstanding that it is a modem as well as a router. Actiontec does produce DSL Gateways that have a Transparent-Bridging option, which bypasses or disables the router function and allows the Gateway to act simply as a DSL modem, when it is enabled. Many consumers do not realize that with FiOS, the ONT (typically outside the home) is the device that handles changing the FiOS signal from Fiber to either Ethernet or Coax, and that the Router is just a Router, and if it was bridged or bypassed, it would be a device without a function. For most Verizon FiOS customers their service would completely stop if the MI424WR was bridged, because the Video on Demand service is dependent on it to work.
    If your ONT is connected to the Actiontec MI424WR router via Coax, the MI424WR is required due to the Coax connection. But if the ONT is connected to the MI424WR via Ethernet, then in most cases some other router can be substituted for the MI424WR, and it can be removed."
    So it looks like I will be calling Verizon support to see about getting the Ethernet connection installed and getting another modem...

  • Who uses inheritance?

    I had a conversation with Tom Kyte on PL/SQL and OO (see thread http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:63942113457534#642059000346437745 ).
    When I program in C#, I use a lot of inheritance and polymorphism, why not in PL/SQL?
    Do you readers have good examples that show how you can use inheritance and polymorphism?
    I hope that there will come support for encapsulation in Oracle Objects.

    I like both, I like PL/SQL and I like C# (very OO).Like you, I like PL/SQL and I like OOPL's.
    I don't know C# - I know C++, Java and Eiffel, but I'm not an expert.
    In my opinion, Eiffel is the best OOPL (Eiffel was designed in 1985, commercialy released in 1986, ISO-standardized in 2006).
    But mostly I like relational databases (relational DBMS's).
    My motto is: “Thou shall not do in the Middle Tier, what thou could have done in the Data Tier”
    (Toon Koppelaars in "A first JDeveloper project: Choices made, lessons learned", Oracle World 2002).
    I think that the current object types in Oracle aren't practical for transient objects in PL/SQL,
    first because a "true" OOPL must have references between transient objects (and then, perhaps, even a garbage collector).
    Between the way, I sent my PL/SQL "wish list" to Steven Feuerstein’s site "21st Century PL/SQL"
    (Add advanced O-O features like those found in Eiffel)
    http://www.oracleplsqlprogramming.com/IC/ideas/data_structures_and_datatypes/object_types/index.php
    Here are my attempts to use PL/SQL as OOPL ( PL/SQL++ :) :
    Dynamic Method Dispatch and Method Overloading in a Subtype (May 2003)
    http://www.quest-pipelines.com/newsletter-v4/0503_C.htm
    Calling the Parent Object's Version of an Overridden Method
    http://www.quest-pipelines.com/pipelines/plsql/tips03.htm#JUNE
    (note: Oracle 11g has Generalized Invocation)
    How to Get the Text Name of an Object's Type
    http://www.quest-pipelines.com/pipelines/plsql/tips06.htm#JULY
    The Template Design Pattern in PL/SQL
    http://www.quest-pipelines.com/pipelines/plsql/tips06.htm#OCTOBER
    Design by Contract (DBC) and PL/SQL
    http://www.quest-pipelines.com/pipelines/plsql/tips.htm#JUNE
    But, I think that Oracle object types are OK for persistent objects (for “column objects”, not for “row objects”).
    C.J.Date in An introduction to Database Systems (2004, page 885) says:
    "... object/relational systems ... are, or should be, basically just relational systems that support the relational domain concept (i.e., types) properly
    - in other words, true relational systems, meaning in particular systems that allow users to define their own types".
    Here is an attempt to use Oracle "object-relational" features "in the proper way" (in Date's sense) - to use object type as domain:
    “OR(DBMS) or R(DBMS), That is the Question”
    http://www.quest-pipelines.com/pipelines/plsql/tips.htm#OCTOBER
    Regards,
    Zlatko

  • Using Inheritance,dose child class have father 's inner class?

    using Inheritance,dose child class have father 's inner class?

    as near as I can tell, the conversation so far has been:
    When I extend a class, does the subclass inherit the parent class's inner classes?
    followed by
    Never mind, i ran a test and found out the answer, sorry for my English.
    hope that helped.
    Lee

  • How do I find a previously passcode to link a wireless keyboard (Model A101urs6) to a Mac Power Book G4 running 10.5.8.  The keyboard was linked at one point in the past, but then not used.  When I am trying to hook it up now, it requires the passcode.

    How do I find a previously passcode to link a wireless keyboard (Model A101urs6) to a Mac Power Book G4 running 10.5.8.  The keyboard was linked at one point in the past, but then not used.  When I am trying to hook it up now, it requires the passcode.  Where can I find this, or is there a general number I can use?

    Hello, and welcome to Apple Support Communities!
    Try entering four zeroes.

  • My iPhone 5 won't use 3G when 4G isn't available. I live in the middle of nowhere, but with my iPhone 4 I could use the Internet on 3G just fine. Now I don't get anything unless I'm on wifi. I have AT

    My iPhone 5 won't use 3G when 4G isn't available. I live in the middle of nowhere, but with my iPhone 4 I could use the Internet on 3G just fine without needing wifi. Now I don't get anything unless I'm on wifi. My phone says '4G' but then says 'could not activate cellular data' or gives me the gray google failed because you dont have internet page. I have AT&amp;T if that matters. I just want to get Internet and my email like I used to be able to. Slow 3G is fine with me, but I need it to work on my iPhone 5. Can anyone help me?

    Oh ok, thank you! So I just got a bum SIM card when I bought this phone or something?

  • How do I troubleshoot installation/distribution of a LabVIEW .exe which processes data using Matlab when it works on some computers but not others?

    I've been given the unenviable task of troubleshooting and installing/distributing software written by a former co-worker. I've modified the LabVIEW code and built an .exe file. I've successfully installed the Labview .exe file on several computers, but it won't work on some others. What's more baffling is that I installed it successfully on one computer, uninstalled it, and tried reinstalling it with no success. In fact, it's a new error (Dr. Watson for Windows NT application error). It doesn't help that I have different versions of LabVIEW and Matlab on the target computers. Some have LabVIEW 5.1, some
    have 5.0, and some don't have it at all. Some have Matlab 5.2, some have 5.3 (R11) and some have 6.0 (R12). It's also not clear to me where the Matlab m files should be located. I'm not sure if it's a LabVIEW Runtime Engine problem, or if it's a Matlab problem. I've also wondered how LabVIEW and Matlab talk to each other. When LabVIEW calls Matlab, it seems that Matlab is running in the background. In other words, clicking on the Matlab Command Window and typing "whos" or any other command/variable doesn't work.

    Jay del Rosario wrote:
    >
    > How do I troubleshoot installation/distribution of a LabVIEW .exe
    > which processes data using Matlab when it works on some computers but
    > not others?
    Poke around zone.ni.com and
    http://digital.natinst.com/public.nsf/$$Search/ .
    Good luck, Mark

Maybe you are looking for

  • TS1717 Itunes re-installed but not opening

    Itunes was running on my Windows 7, 64 bit, Core I7 laptop, but it stopped recognizing my ipod touch.  WIndows would see the device, but not Itunes.  So I checked the Apple support site and it suggested totally uninstalling Itunes and Quick Time and

  • Very slow wake up and two log in screens

    Hello. I've been experiencing this issue for months and would appreciate suggestions since I haven't seen other entries related to this specifically. When my MacBook Pro (2012), OS X 10.10.2 wakes from sleep, it shows a sort of "progress bar" over a

  • How to debug the function separately which is added in the package

    Hi Friends, I want to know how to debug the function separately, by taking it from package,. and i dont no where to add begin and end. and dont no how to give input to the function. ANd how to find the error which is detected from production, so i wa

  • PS CS3 and Mac OS 10.6 problems

    I recently upgraded my mac OS from 10.4.8 to 10.6 and now my PS CS3 won't open, why?

  • Use NAC Web Agent login with Ipad

    Hello Guys, I'm using NAC 4.8, and I'd like to login using NAC Web Agent on Ipad. When I'm trying to do that, I'm receiving a message on Ipad that I need to install Java Plug-In, but there is no JavaPlug-in available for Ipad. Does anyone know if the