Design Question: Creating One Object Type From Multiple Inputs

Hi,
I'm attempting to expand my brain a bit and come up with a more elegant solution to a design I created a few years ago. In simple terms, I have a data object (Request) which can be created based on data in a text file or from data previously persisted in a database record using the Request object and associated DAO. Typically, the text file is initiating a "new" Request object to be persisted, and reading from the database is done to update or view previously submitted Request objects. Note that I have no ability to change the original input method of the text file.
In my original design I basically lumped everything into the Request class using multiple constructors which made for a messy jumble and a very long class. Different parsing routines were needed when data was read from the file vs. reading it from the database. I was considering refactoring the code to use a factory class but this doesn't seem to follow the typical Abstract Factory or Factory Method design patterns. In my design I keep ending up with something like:
public class RequestFactory {
    public Request createRequestFromFile(File file) {...build up the request object...}
    public Request createRequestFromDbRecord(int recordId) {...build up the request object...}
}And I would change the constructor in my Request class to private and remove all of the parsing and construction methods.
Now, I can definitely make this work but I'm not sure I'm really doing much except taking the creation garbage (there's a lot of parsing of multiple-value fields that needs to be done) out of the actual Request class. So my question is basically, do I have a better approach I'm not seeing or is this type of factory "appropriate"? I mean, would someone come along later and look at my code and think I was crazy? I'm still trying to wrap my head around some ways to use factories in my own projects so I'm probably not thinking clearly.
Thanks!
Pablo

Thanks for the feedback. About your suggestions on dealing with the different loading methods, I think that's where I keep getting disconnected, at least as far as using an abstract factory is concerned.
Extending your example code a bit using option one, I would guess I end up with something like this:
public interface RequestFactory {
  Request createRequest(RequestSource source) throws RequestCreationException;
public class DatabaseRequestFactory implements RequestFactory {
  public Request createRequest(RequestSource source) throws RequestCreationException {
    // do some stuff
}The part I can't figure out is how to define the RequestSource (or RequestId in your example). It would seem that if I'm going to define member variables in RequestSource like SourceFile or RecordId it would be just as correct to skip the interface and just use two concrete classes like this:
public class FileRequestFactory {
  Request createRequest(File file) throws RequestCreationException {
    // process file and create request
public class DatabaseRequestFactory {
  public Request createRequest(int recordId) throws RequestCreationException {
    // load record and create request
}I guess where I keep stumbling is a) the value of the interface and b) if I do use an interface, how to have a generic object passed to createRequest() that can refer to either a file location or a record ID. This concept is pretty clear when the creation requirements for each concrete factory are the same, but when the construction uses such disparate data sources for creation I can't seem to wrap my head around the differences.
Your third suggestion is probably the easiest for me to understand but it seems like it would be a bit contrived. In the end it may make the most sense if I am going to go with that type of approach since I still don't really understand how to implement the first two options.
Thanks again for your input.
Pablo
Edited by: Pablo_Vadear on Dec 15, 2009 6:11 AM

Similar Messages

  • Creating one Sales Order from Multiple Quotes

    Hello
    We are using SAP CRM 2007.
    I believe in CRM we can create one sales order from multiple quotes. We have a requirement where we need to create one Third party sales order from multiple Quotations.
    I have Item cat for Quotations and Sales Document maintained correctly.
    I also have copy control where ZQUO and ZSAL are maintained correctly. Where I have maintained settings for copying Transactions as well as Item Category.
    But when I go to CRMD_ORDER and retrieve quotes and try to do a follow on doc for sales doc , only the first Quote gets added into follow on document.
    Can someone tell me if I am missing any config?
    Thanks

    hello,
    in sap ui we use control button and select multiple quotes and then
    create the sales order as follow up as we have follow up button.
    Regards,
    Deepa

  • Create object type from multiple tables for select statement

    Hi there,
    I have 3 tables as given below and I wish to create an object type to group selected columns as 'attribute' from multiple tables. 
    I need to create 2 input parameters to pass in - 'attribute' and 'attribute value'  in PL/SQL and these 2 parameters will be
    passing in with 'column name' and 'column value'.  e.g. 'configuration' - the column name, 'eval' - the column value.
    Then, the PL/SQL will execute the select statement with the column and column value provided to output the record. 
    Pls advise and thank you.
    table ccitemnumber
    name                           null     type                                                                                                   
    ccitemnumber                   not null varchar2(20)                                                                                                                                                                                    
    configuration                           varchar2(20)
    item_type                               varchar2(30)
    table productmodel
    productmodelnumber             not null varchar2(6)                                                                                            
    description                             varchar2(60)  
    accesstimems                            number                                                                                                 
    numberofheads                           varchar2(2)
    generation                              varchar2(10)
    numberofdiscs                           varchar2(2)
    factoryapplication                      varchar2(150)
    table topmodel
    stmodelnumber                  not null varchar2(30)                                                                                           
    productfamily                           varchar2(60
    formfactor                              varchar2(10)                                                                                           
    modelheight                             varchar2(10)                                                                                           
    formattedcapacity                       number                                                                                                 
    formattedcapacity_uom                   varchar2(20)
    object type in database
    configuration                           varchar2(20)
    item_type                               varchar2(30)
    numberofheads                           varchar2(2)
    generation                              varchar2(10)
    numberofdiscs                           varchar2(2)
    factoryapplication                      varchar2(150)
    modelheight                             varchar2(10)
    formattedcapacity                       number                                                                                                 
    formattedcapac

    user12043838 wrote:
    Reason to do this as these fields are required to be grouped together as they are created in different tables. They are treated as 'attribute' (consists of many columns) of the part number. So, the PL/SQL is requested to design in a way able for user to pass in the column name and column value or part number, then the select statement should be able to query for the records. Another reason is a new column can be added easily without keep modifying those effected programs. Reuseable too.This basically equates to ... hard to code, hard to maintain, and poor performance.
    Are you really sure you want to do this? This isn't going to be easy-street as you seem to think it is, but it's a one way street to a poorly performing system with security vulnerabilities (google SQL Injection).
    I would highly recommend you reconsider your design decision here.

  • How to create one clean image from multiple shots?

    I tried searching, but I really don't know how to search for this so I came up empty.
    I have multiple pictures of the same product but had to focus on different parts to get those parts in focus. As you can imagine, this meant other parts were out of focus.
    I seem to remember during one of the "CS3 is cool" seminars I attended that something along the lines of what I'm hoping to do is possible.
    I would like to merge these images together to form one image with everything in focus. Exposure is the same on each of them.
    Is this possible (and if so, how) or am I dreaming?
    Using PS Extended.

    Thanks for all the suggestions, guys. I'll give those a shot and see if they work enough. If it looks like it'll take too long right now, I'll just try to find a better angle where I can get it "good enough" as I have many more pictures I need to take of cables and wires.
    Super fun.
    To answer some of the questions posed to me:
    I looked at photomerge, but that looked to me like more of a way to make panaramic (sp?) pictures from multiple shots. I may tinker with that a bit though as it's something I'd like to use for other things as well.
    I don't need this very often so this would not be a common practice, but if I knew how to do it, that would open some more options for me and I'd likely do it more often but still not regularly.
    It's not a super closeup, though I've had need of this operation on those in the past; wound up just shooting differently and settling for second or third best.
    I don't use what anyone would call a photo studio. It's a 4x8' piece of styrene tacked to the wall and a fold-up 6' table in a room with flourescent lighting (please try to restrain your laughter). The company's camera, while decent, is very old: Sony DSC-D770. This is why I bought my own Sony DSC-F828 2-3 years ago. Not the best but much better (the tiny-to-sometimes-larger purple haze around most edges is what bugs me the most). And my setup is just my camera on a tripod. I'm not fooling myself about my skills at photography; I'm very small-time, but I still need my shots to look good.
    (Out of respect for actual photgraphers, I don't even call myself a photographer. I "shoot product photos" or "do product photography" which still sounds a bit too lofty, but....)
    The product itself is the Velleman TLM12, a test tweezer for SMD devices. I'd like to get a "long" shot of it but that angle makes the tip and leads get out of focus in most shots and they're tiny so it's really noticable. I can get every part in sharp focus in 3-4 shots, but not in one at the angle I'm hoping to get.
    I use a macro lense when I need to get big pictures of 1" connectors and the sort, but this is way too big for that and the macro has a very small area of what would be in focus so this problem would be compounded far more than I'm experiencing now.
    I think layer masks might be the quickest way to achieve what I'm trying for here. Like I said, I don't need this often but if I knew how, I'd do it more frequently and might even create an action to do this faster.
    Thanks again, everybody. HUGE help. :)

  • Create View Object programattically from XML input

    Hi,
    I have requirement to create view object from xml at run time in ADF application. is there any way to create view object dynamically in java program from xml?
    My requirement is to call a webservice and generate view object from the response of the web service call.
    Thanks

    I want to create view objects from different web services and the same will be available to the developer at the time of development. I don't want to create web service proxies for each of the web service. this will simplify the developers task to create proxy and data controls. the one thing developer has to do is select the service and base on the service the view objects will be created to develop pages accordingly.

  • How to create a Sales order from multiple quotations?

    Hi All,
    Please tell me how to create one sales order from multiple quotations?
    Regards,
    Maddy

    Hello Maddy,
    To create the sales order from multiple quotation, you should put the value "F - Only at item level: Always with selection option" under Quotation determination in your sales transaction type.
    It will give you a pop-up to choose your quotations item while creating the sales order.
    Some per-requisites are there:
    1. Copy control should be maintained between your quotation and sales order.
    2. Quotation should be error free and should have the status "Released"
    3. Sold to party and Organization should be same in both transaction.
    For more information you can check the below link:
    Processing Quotations - Sales Transactions - SAP Library
    Best Regards,
    Dinesh

  • Creation of one Excise invoice from multiple commercial invoice

    Hi
    Can it possible to create one excise invoice from multiple commercial invoice
    regards,
    K.S.Rao

    hi,
    I am trying in another way - creating one proforma invoice for multiple deliveries. and with that proforma invoice trying to create excise invoice.
    But i am facing problem in creating proforma with multiple deliveries because of DIFFERENT NUMBER RANGE IN HEADER (delivery)AT FOREIGN TRADE --- UNDER ORGANIZATION --- NUMBER OF FOREIGN TRADE DATA - ( which is internally assigned by the system)
    If i can get where this number is assign my problem is solved
    K.S.Rao

  • How to create a pdf file from multiple images ?

    Dear All,
    I want to create a SINGLE page pdf file from two or more page size images that are combined to make a single page pdf. Again, this question is on pdfs that are made out of several, atleast  two color images and a black-and-white mask for one of them.
    I have such pdf files from an unknown source (the producer is edited out) whereby there are three tiff images, obtained using the well known pdfimages extractor.
    When I want to make a pdf out of tiff or png or other image formats, I right click and tell Adobe Acrobat to make a pdf.
    However, I dont know how I can give a command to select say,  three tif images and specify which is the mask for which and then join  them in a way that I get the pdf from the composite of the two color images and a mask for one of them.
    Please help me out.
    I am a little familiar with the pdf structure skeleton and when necessary, fixed xref tables in one of my favorite editors. A few years ago, I also wrote a bunch of javascripts to make some annotations and needed some automation and used some itext type libraries. However, I need your help in this problem as I am now rusty and forgot some of what I studied to solve my earlier problems. This is a new problem for me. Gentle hints from you would be very nice to help me in this problem. Please specify if necessary what manual and pages to read. in the pdfspec.
    Best Regards
    Disabled Veteran [physically handicapped]

    Hello Again.
    On Fri, May 11, 2012 at 12:20 PM, lrosenth <[email protected]> wrote:
    >
    > Re: How to create a pdf file from multiple images ?
    >
    > created by lrosenth in PDF Language and Specifications - View the full
    > discussion
    > ________________________________
    >
    > No clue who Irving is…
    >
    I was hoping to have your first name so its easy for me to address you.
    > I have no clue what OS platform, programming language, etc. you use so
    > can’t really narrow things down.
    I would gladly mention that I am working on windows platform, preferably XP.
    I can also work on linux for free products that come with it.
    >  Also, as this is an Adobe forum, we only
    > recommend Adobe products – so there may be other options that even my list
    > wouldn’t include.
    But adding other products, for the help of an adobe products user,
    even if it outside adobe, shall add greater prestige to your company
    and give impression of user-centeredness.
    > If you read ISO 32000-1:2008 (aka the PDF standard), you will find the
    > information about Images and Image Masks well described.  I didn’t think I
    > needed to repeat any of that information.
    Well, just add the few pdf stanzas since you are proficient on it and
    I am presently a little rusty as I mentioned. Just asking a little
    extra yard, not even to go an extra mile.
    > And, if you read that same document, you will see that there is NO SUCH
    > THING as a “text only PDF”.   All PDF documents are structured binary files.
    Well, ascii format or uncompressed format that is human readable. I
    know its a binary file, but human readable ascii version of it.
    I hope you can give me some stanza and various other approaches
    possible so I can select or combine things for myself. I see only a
    miniscule number of posts claiming to have written masks in this forum
    and then with no details.
    Regards
    Roger
    Message was edited by: dying veteran
    because the adobe posting system went crazy and truncated all except the first line ... dunno why

  • How to use an Object Type from Another Database

    Hi,
    I have this requirement that I need to call a stored procedure from another DB (db1) but I am having a problem with this because one of the input parameters uses an object type defined in that DB (db1). Is it possible to use an object type from another database? TIA!

    Sven W. wrote:
    At least for queries, but I think also for procedure arguments..You (both) probably missed my post?
    We can't use a remote type as procedure argument, even with the same OID.
    It's OK for query on a remote object column though :
    SQL> conn remote_user@remote_db
    Entrez le mot de passe :
    Connecté.
    SQL> create type mytype oid '19A57209ECB73F91E03400400B40BBE3'
      2  as object (att1 number);
      3  /
    Type créé.
    SQL> create table mytable (col1 mytype);
    Table créée.
    SQL> insert into mytable values (mytype(777));
    1 ligne créée.
    SQL> create or replace function myfunc (p_in in mytype) return number
      2  is
      3  begin
      4   return p_in.att1;
      5  end;
      6  /
    Fonction créée.
    SQL> disconn
    Déconnecté de Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    SQL>
    SQL>
    SQL>
    SQL>
    SQL> conn my_user@local_db
    Entrez le mot de passe :
    Connecté.
    SQL> create type mytype oid '19A57209ECB73F91E03400400B40BBE3'
      2  as object (att1 number);
      3  /
    Type créé.
    SQL> select * from mytable@test_dbl;
    COL1(ATT1)
    MYTYPE(777)
    SQL> declare
      2   res number;
      3  begin
      4   res := myfunc@test_dbl(mytype@test_dbl(777));
      5  end;
      6  /
    res := myfunc@test_dbl(mytype@test_dbl(777));
    ERREUR à la ligne 4 :
    ORA-06550: Ligne 4, colonne 26 :
    PLS-00331: référence non valide à REMOTE_USER.MYTYPE@TEST_DBL.WORLD
    ORA-06550: Ligne 4, colonne 2 :
    PL/SQL: Statement ignored
    SQL> declare
      2   res number;
      3  begin
      4   res := myfunc@test_dbl(mytype(777));
      5  end;
      6  /
    res := myfunc@test_dbl(mytype(777));
    ERREUR à la ligne 4 :
    ORA-06550: Ligne 4, colonne 9 :
    PLS-00306: numéro ou types d'arguments erronés dans appel à 'MYFUNC'
    ORA-06550: Ligne 4, colonne 2 :
    PL/SQL: Statement ignored

  • How to create one inbound delivery for multiple purchase order?

    Hi Experts,
    Please let me know how can I create one inbound delivery for multiple purchasing documents(PO or SA)? 
    Is there a configuration needed for this?  If yes, please let me know the configuration to make this happen.
    Appreciate your help on this.  Right answers will be rewarded.
    Thank you.
    with regards,
    Muthu Ganapathy.

    Hi,
    my situation is:
    - a WM managed warehouse, society A;
    - a HU managed warehouse (without WM), society B;
    - a purchasing process of HU from society A towards society B.
    Society B have a scheduling agreement; when a delivery schedule appears, in society A born a sales order and a delivery. After the registration of the delivery good issue, an idoc transfer information for inbound delivery creation.
    This process is ok without WM, but with a WM managed warehouse the idoc has the following problem:
    "V51VP - item was not found - process cancelled".
    Can you help me to transfer these HU?

  • How can I create a single order from multiple quotations?

    How can I create a single order from multiple quotations that I have created by the transaction VA21 ?
    Thanks in advance for the answers.

    hi
    Go to transaction: /nva01
    Enter order type : ZOR
    Sale org :xxxx
    Dist.channel:xx
    Division :xx
    Press enter
    Click on “Sale document” and select Create with reference
    Then enter 1st quotation number & click on “COPY” or “Selection list”. Then click on “Copy “.Then all line items which belong to quoation1 copy to order.
    Then,
    Click on “Sale document” and select Create with reference
    Then enter 2nd quotation number & click on “COPY” or “Selection list”. Then click on “Copy “.Then all line items which belong to quoation2 copy to order.
    Then,
    Click on “Sale document” and select Create with reference
    Then enter 3rd quotation number & click on “COPY” or “Selection list”. Then click on “Copy “.Then all line items which belong to quoation3 copy to order.
    Now save the sale document.
    Kindly give reward points
    Edited by: WISH on Mar 19, 2008 2:25 PM

  • How to create plant wise STO from multiple requisition through Me59N

    How to create plant wise STO from multiple requisition through Me59N

    Due to the different supply plants the system does not know which one
    to use and therefore throws the error message.
    The only workaround would be to create the PO's seperatly per PR item.
    Hoep this helps you

  • Can i create a single image from multiple images in lightroom?

    Can i create a single image from multiple images in lightroom?

    Like a panorama, a composite or focus stack? Have you tried the Lightroom forum?
    Photoshop Lightroom

  • Object type for multiple/text/unrestricted property

              Hi,
              Does anybody know what's the object type for multiple/text/unrestricted property.
              I tried to use um:setproperty tag to set the value of a multiple/text/unrestricted
              type property in jsp. I got the following error if the object type I use is ArrayList:
              javax.transaction.TransactionRolledbackException: Transaction: '995540362044_8798'
              rolled back due to EJB exception:
              java.rmi.RemoteException: EntityPropertyManagerImpl.insertTypeSpecificValue():
              caught ClassCastException. The reason might be because the type of the passed
              value does not mismatch the property type stored in schema information. Expected
              object type is: 3 and the object type was: java.util.ArrayList
              Does anybody know what's this type 3 object?
              Br,
              -Niyue Chen
              

    Hi All,
    I need to convert the amount value in comma to dot say 1000,00 to 1000.00.Any function module is there to convert it.After converting it i need to pass this value as exporting parameter to a function module having data type as character(lenght 13).
    Thnks
    Deb

  • Running a SQL Script to Create an Object Type

    When I do Database Development with JDeveloper and fellow the instruction at
    http://www.oracle.com/technology/obe/obe1013jdev/dbdevelopment/obe_%20dbasedevmt.htm
    and try to Running a SQL Script to Create an Object Type by Right-clicking emp_rec.sql in the editor and
    choose Run in SQL*Plus > hrconn, the new Obuect type can not created. The screen flashs and I only got the
    message
    "Invoking SQL*Plus...
    D:\oracle\product\10.2.0\db_1\BIN\cemutls.exe
    hr@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SID=ORCL)))
    @emp_rec.sql" and nothing else (No error like JBO-XXXXX).
    Can anybody Help Me? Thanks a lot!
    SID: ORCL

    Hi Simon,
    Having had a closer look at your original message it seems that rather than selecting the SQL*Plus executable in the directory you have managed to select the file 'D:\oracle\product\10.2.0\db_1\BIN\cemutls.exe'.
    If you go to 'Tools | Preferences' and select the 'Database Connections' node and alter the 'SQL*Plus Executable' field to 'D:\oracle\product\10.2.0\db_1\BIN\sqlplus.exe' and then try again, this should then work.
    Regards,
    Lisa

Maybe you are looking for