How to create multiple TYPES of objects from one menu?

Q: How can I create a single class to create objects of multiple 'object classes' in a way that is not a huge switch statement?
Explaination:
Let's say that I have an application that I am building, that manages five hundred object types. A properly-built object subclassing tree is created, and I want to be able to create objects of any 'leaf node' of this subclassing tree using a single 'objectCreate()' method in a 'factory object'. The purpos of this method will be to create an instance of the correct object, pass a handle to a few collections for properly sorting and storing these objects in groups.
Usually, one could create a switch in this function, testing for the type of object that the user wants to create from the menu. But in the case of having hundreds of possible object choices, this becomes harder and harder code to maintain (let alone performance).
Any suggestions?

But if my menu has:
1. German Shepard
2. Doberman Pinscher
3. Malamut
4. Persian Long-hair
5. Siamese
6. Tabby
And my object class tree goes:
                              [ Animal ]
             [ Cat ]                              [ Dog ]
  [ various breeds ]                         [ various breeds ]How do I code the menu class to respond to the input, so that it runs the correct [breed] object's constructor?
The line:
Animal choice = new xxxxxxxx();
I can't use a variable to replace 'xxxxxxxx' in run-time, but having a ton of choices in code sounds/looks unreasonable.
if (choice == "Doberman Pinscher")
Animal choice = new doberman();
else if (choice == "Tabby")
Animal choice = new tabby();
Do you see what I am trying to avoid? I am not experienced enough to instantly realize how to avoid the latter, and instead, do a single instantiation command for the correct constructor.

Similar Messages

  • How to create multiple reports and dashboards from one dataset?

    Hi there,
    I've centralized the data to an excel workbook from multiple data sources and added as a dataset to my new Power BI site. How can I build multiple reports and dashboards out of one dataset?

    Hi Kuber,
    In the Datasets section on the Navigation pane (left side of your Dashboards page), you can click "..." next to each dataset. One of the options in the contextual menu is Explore. When you explore a dataset, you can create reports and save
    them.
    You can find more about this and other topics in our Getting Started content:
    https://go.microsoft.com/fwlink/?LinkID=512054
    Thanks,
    M.

  • How to generate multiple output pdf's from one oracle reports

    how to generate multiple output pdf's from one oracle reports.
    I have a report where I have to generate more than one output files from the same report based on a parameter.
    Each output file is for each parameter.
    Is this possible in oracle reports, is so how ?

    You can better post your question in the reports forum instead of this pl/sql forum.

  • How to change multiple commands label text from default "Menu" to "Go to"

    I m new in J2me and J2me polish and having problems in label of command.
    Here I code that add multiple commands
    Command chPinCom = new Command("Change Pin", Command.SCREEN, 2);
    Command accCom = new Command("Account", Command.SCREEN, 2);
                        Command favCom = new Command("Favourites", Command.SCREEN, 2);
    the code that add commands in list
    listScr.addCommand(chPinCom);
    listScr.addCommand(accCom);
    listScr.addCommand(favNumCom);
    listScr is the type of LIst
    Please help that hoe I change commands label text from default "Menu" to "Go to" that showed in right bottom on the screen

    It's possible see book "Pro J2ME Polish Open Source Wireless Java Tools Suite" on page 90 ....see Localizing the J2ME Polish GUI
    I just change my build.xml file and add one more variable like
    <variable name="polish.command.options" value="Go To"/>
    and it's working fine..

  • How do I copy an art object from one document to another using illustrator API(C  )

    Hi, I'm trying to copy text and graphic elements from one document into another, does anybody has an idea how to do it using Illustrator SDK(C++)?
    Thanks in advance.

    If you call AIArtSuite::ReorderArt() giving the layer group handle from the target document and using art from the source document, it will move art between documents. That said, there are all sorts of caveats that come along with that -- some things move over automatically (graphic styles, symbols) while others cause problems. E.g. copying art that contains a swatch can cause a crash when you shut down the source document because it may keep the style reference to the swatch in the source document -- which goes away when the document is closed. Gradients in particular are a problem I believe. Straight up colours are (I think) fine. I've had to write a lot of workarounds for various headaches caused by moving art between documents.
    Bottom line: its very doable, but there are a lot of edge cases. This was clearly not an intended use of the SDK, though it is possible.

  • How do you create multiple events (different dates) from one large event?

    I recently downloaded a large number of photos from my iphone to iphoto. All of the photos are now under event 4/9/2011 (the date and times are correct, just all in one event). How do I change/break up photos and add/change event dates? I don't want to scroll up hundreds (half a year) of photos to see photos I took yesterday.

    Select the Event and go Events -> Autosplit
    Regards
    TD

  • How to select multiple pages to export from one document to another

    Have a 200 + page doc, would like to select about half to place in another doc.
    An earlier post advised selecting the required pages in thumbnail view and copy and paste into second doc. No problem with single page that way but how to select the multiple pages.
    Would appreciate some guidance please.
    Am using Pages Maverick.

    Thanks fruhulda.
    This is what I found,
    make a section around the consective pages to be copied,
    in thumbnail view, hold down shift key, right click on first page in section of interest, select copy,
    in thumbnail view of second document, right click and select paste.
    transfer complete.
    Found clicking in body of second document, ie not the thumbnail view, paste will only transfer text and not images.
    I do have difficulty in splitting sections - will search forum

  • How to create multiple ship to parties to one sold to party.

    Hi  ALL,
    Presently we are working with one sold to party having one ship to party.Now the same customer have placed the order with two different delivery points.For this existing customer, how i can create one more ship to party with different delivery address.Can anybody guide me where to start doing the configuration for this along with T codes.
    Thanks in advance
    kumar

    Hi Ramesh,
    As you said I have created one more SH and assinged to existing customer master record.When I am creating the sales order Popup is showing SH party with selection option of one SH.Here I am not able to create one sales order with two ship to parties.Can you come clear on this.Is it possible to create one sales order with two SH?
    Thanks in advance
    kumar

  • Creating an arrays of objects from a class

    I was wondering does any one know how to create an array of objects from a class?
    I am trying to create an array of objects of a class.
    class name ---> Class objectArray[100] = new Class;
    I cant seem to make a single class but i need to figure out how to create an array of objects.
    I can make a normal class with Class object = new Class

    There are four lines of code in your for-loop that actually do something:
    for(index = 0; index < rooms.length; index++) {
    /*1*/  assignWidth.setWidth(Double.parseDouble(in.readLine()));
    /*2*/  rooms[index] = assignWidth;
    /*3*/  assignLength.setWidth(Double.parseDouble(in.readLine());
    /*4*/  rooms[index] = assignLength;
    }1.) Sets the width of an object, that has been instantiated outside the loop.
    2.) assigns that object to the current position in the array
    3.) Sets the width of a second object that has been instantiated outside the loop
    4.) assigns that other object to the current position in the array
    btw.: I bet you meant "assignLength.setLength(Double.parseDouble(in.readLine());" in line 3 ;)
    Since each position in an array can only hold one value, the first assignment (line 2) is overwritten by the second assignment (line 4)
    When I said "construct a new room-object and assign it to rooms[index]" I meant something like this:
    for(index = 0; index < rooms.length; index++) {
        Room aNewRoom = new Room();
        aNewRoom.setWidth(Double.parseDouble(in.readLine()));
        aNewRoom.setLength(Double.parseDouble(in.readLine());
        rooms[index] = aNewRoom;
    }1.) Constructs a new Object in every iteration of the for-loop. (btw: I don't know what kind of objects you're using, so this needs most likely modification!!)
    2.) set the width of the newly created object
    3.) set the length of the newly created object
    4.) assign the newly created object to the current position in the array
    -T-
    btw. this would do the same:
    for(index = 0; index < rooms.length; index++) {
        rooms[index] = new Room();
        rooms[index].setWidth(Double.parseDouble(in.readLine()));
        rooms[index].setLength(Double.parseDouble(in.readLine());
    }but be sure you understand it. Your teacher most likely wants you to explain it ;)

  • Moving field object from one section to another programatically

    How do I move text/field objects from one section to another at run time. The ReportObjects collection in the section is readonly and setting the left, top property of the ReportObject only seems to move object within the same section.
    I'm using Crystal Reports version 10.5 that comes with VS 2008 professional.
    Edited by: iyounus on May 26, 2009 9:41 PM

    Hi;
    The trial version will offer this capability. You can either use RAS (which is available with Crystal Reports, or Business Objects Enterprise), or the Crystal Reports engine. Which you use will depend on the target for your application, see this for some tips on that:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f006a5e6-7e64-2b10-8a84-8b15ca5cacfc
    And, some links to samples that add fields:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20300f17-c566-2b10-b586-b8e8a23e6668
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3085841e-c566-2b10-238c-9f7c3f85d816
    https://www.sdn.sap.com/irj/boc/sdklibrary
    Regards,
    Jonathan

  • How to create multiple associated record types in a single batch

    I know that when inserting records in a batch, if one of the records fail, the entire batch is rolled back. But is there a similar feature when inserting records of different types that are associated with each other?
    E.g.
    From a web application, the user fills in a form for Contracts and Contract Products and submits to CRM.
    The form will first create the parent object (Contract). After this has been created and the rowID for this new Contract object obtained, it can proceed to create multiple Contract Product objects, all tied to that Contract rowID.
    But if one of the Contract Products fails during insertion, the batch will only rollback the Contract Products. It will not rollback the main Contract parent. Is there any way to accomplish this?

    Well think of it I believe the scenario is too bird viewed hence the solution can't be exact.
    But thinking of a possible solution every time a child operation fails have a catch block where you you go back to system if the parent needs to be deleted if yes, call Delete Method on the parent.
    Note: Make sure that the decision on whether or not the parent record needs to be deleted will depends on the question "Does Parent Record already has several other children associated to it or not"
    Hope this clarifies.
    Regards,
    Messer

  • How to create multiple Tree Type Region In Tabular Form ?

    Dear Friends,
    i have to design tabular form to Distribute User Rioght to emp to access application
    eg if i have Three module in application
    1.Administration
    2.Attendance
    3.Accounts
    Module
    1 Administration have 5 Pages A,B,C,D,E.
    Module
    2 Attendance HAVE 4 Pages F,G,H,I
    Module
    3 Accounts HAVE 7 Pages J,K,L,M,N,O,P
    I need these three module divided into three section in tabular form as a tree Type like
    Module 1 Tree Open in Tabular Form like
    - (Tree Mark Open )
    =======================================================
    PAGE_ID-------------SUBPAGE_ID-------VIEW-------------------MODIFY-------------------CREATE----------------------------TABLE COLUMN NAME
    ========================================================          
    Administration-----------A------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Administration-----------B------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Administration-----------C------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Administration-----------D------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Administration-----------E------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    - (Tree Mark Open )
    Module 2 Tree Open in Tabular Form like
    Attendance-----------F------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Attendance-----------G------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Attendance-----------H------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Attendance-----------I------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    - (Tree Mark Open )
    Module 3 Tree Open in Tabular Form like
    Accounts-------------J------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------K------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------L------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------M------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------N------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------O------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
    Accounts-------------P------------------CHECK bOX------------CHECK BOX-------------CHECK BOXi need divided these three Module in Tabular form in three region as tree.
    Table APPLICATION_PAGE_DETAILS
    ID                   NUMBER
    PAGE_ID             NUMBER
    SUB_PAGE_ID          NUMBER
    ========================
    TABLE USER_RIGHT
    ======================
    ID                  NUMBER
    EMP_ID            NUMBER
    PAGE_ID            NUMBER
    SUB_PAGE_ID        NUMBER
    VIEW                    VARCHAR2(1)
    MODIFY                VARCHAR2(1)
    CREATE                VARCHAR2(1)How to create multiple Tree Type Region In Tabular Form ?
    How can i do this ?
    Thanks
    Edited by: Vedant on Oct 4, 2011 3:21 AM
    Edited by: Vedant on Oct 4, 2011 9:09 PM
    Edited by: Vedant on Oct 13, 2011 8:57 PM

    Well think of it I believe the scenario is too bird viewed hence the solution can't be exact.
    But thinking of a possible solution every time a child operation fails have a catch block where you you go back to system if the parent needs to be deleted if yes, call Delete Method on the parent.
    Note: Make sure that the decision on whether or not the parent record needs to be deleted will depends on the question "Does Parent Record already has several other children associated to it or not"
    Hope this clarifies.
    Regards,
    Messer

  • How can you move the objects from one server to another?

    how can you move the objects from one server to another?

    Hi,
    Collecting objects for Transporting
    1. rsa1->transport connection
    2. left panel choose 'object type', middle panel choose 'infocube' and 'select objects'
    3. then choose your infocube and 'transfer'
    4. will go to right panel, choose collection mode 'manual' and grouping only 'necessary objects'
    5. after objects collection finished, create request
    6. If they are $TMP, then change the package.
    7. When you click the Save on the change package, it will prompt for transport. Here you can provide an existing open transport request number, or if you like here itself you can create a new one.
    8. You can check the request in SE09 to confirm.
    Releasing Transport Request  
    Lets say you are transporting from BWD to BWQ
    Step 1: In BWD go to TCode SE10
    Step 2: Find the request and release it (Truck Icon or option can be found by right click on request #)
    Note: First release the child request and then the parent request
    Steps below are to import transport (generally done by basis )
    Step 1: In BWQ go to Tcode STMS
    Step 2: Click on Import queue button
    Step 3: Double Click on the line which says BWQ (or the system into which transport has to be imported)
    Step 4: Click on refresh button
    Step 5: High light the trasnport request and import it (using the truck icon)
    Transport
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b5/1d733b73a8f706e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/0b/5ee7377a98c17fe10000009b38f842/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/224381ad-0701-0010-dcb5-d74236082bff
    Hope this helps.
    thanks,
    JituK

  • How to create multiple BOM of same parent item?

    Hi All,
    Please guide me, How to create multiple BOM of same parent item? I tried but system throws a message as same Parent Item already exist in the table. I am afraid if system supports this functionality or not?

    Hi,
    You are welcome.......
    Well the exact process would be as I mentioned in my previous post.
    1. Create the BOM for an item
    2. Choose this item in the Production Order
    3. Then in this Production order you can change/ delete/ add whichever item you want .
    OR
    If all the child items are completely different from the original BOM then you can use the Special Type BOM in which you can always create the BOM while creating the Production Order itself. There is no standard BOM here.
    J Nagesh

  • How do I move all my files from one User Profile (account) into another? I needed to create a new account and want all of my files accessible in the new one.

    How do I move all my files from one User Profile (account) into another?
    I needed to create a new account and want all of my files accessible in the new one.

    ok, what you're learning right now is 101 unix, which is good. Unix is a good thing
    now: the way unix works, and macos (which uses unix underneath) the files and folders work like a hierarchy.
    the start of that tree is /
    so, if you were to do:
    cd /
    (cd means change directory)
    it will bring you at the highest branch of the file system.
    cd /Users
    will bring you to where all the users are.
    to see whats in /Users you can use your friend ls command
    ls means list files/directories
    so:
    cd /Users
    ls -la
    (the -la here means show all (even hidden) and long format (very verbose))  this flag is very optional.
    you will see
    fred
    user2
    for example.
    if you want to see the desktop of user2 you would change directory to it then list the files.
    for example:
    cd /Users/user2/Desktop
    Note that the files and directory are case sensitive, so, desktop is NOT the same as Desktop, or DESKTOP
    ls -la
    you should then be able to see everything in users2 desktop
    you could have done as well the same thing in smaller steps, for example:
    cd /
    cd Users
    cd user2
    cd Desktop
    this is the equivalent of cd /Users/user2/Desktop
    So, for your file, i don't know where it was, but know that if you log in as user2, it will directly put you in
    /Users/user2
    which most likely the file you had created from the other user was in /Users/user1
    if you copied all the files from /Users/original_user to /Users/secondUser
    most likely yes, all your mail, bookmarks etc would be copied over.
    so in your case.
    sudo chown -R seconduser:staff /Users/secondUser
    should work
    Remember that if you start a path with the character /  it means start from the root of the file system, at the highest top you can ever get.
    so
    cd /Users/fred
    is not the same as
    cd Users/fred
    unless you were in / already
    i know it may be confusing at first but it's actually very logical if you play with it.
    to simplify, think of it that / means C:\  on windows
    you can't go any higher than C:\  (in a way)
    if you're unsure which directory you're currently in, you can always type:
    pwd
    it will tell you where you are.
    for example:
    cd /
    pwd
    this shows  /
    cd Users
    pwd
    this now shows /Users
    cd /System/Library
    pwd will show /System/Library
    cd /
    cd /Users
    cd fred
    cd Library
    pwd will show /Users/fred/Library
    unix can look very scary but it's actually vital and very necessary to do tasks sometimes that would take for ever to do via the windows. This is good learning.
    so for the myfile you had created, i can't tell you where it is, at the time you created, if you can do a pwd command you'll know the path,
    ls -la  (this shows all the files where you are)
    if you see myfile in the list
    do a pwd
    whatever is return, the real location of the file would be:
    whatever pwd returned / myfile
    I hope that makes sense.

Maybe you are looking for