One time parameter use pattern

I'm wondering if the following pattern breaks any convensions or smells of poor design.
I have a complex directed-graph-like object, let's call it MyGraph.
I plan to build them by putting together smaller less complex MyGraph objects which get integrated into the whole.
The problem is that when they are integrated, their nodes are, of course, possibly linked (hence modified) to nodes in the graph they are constructing.
To sum up so far:
MyGraph subGraph1 = new MyGraph(...);
MyGraph subGraph2 = new MyGraph(...);
//WARNING! subGraph1 and subGraph 2 get modified in here!
MyGraph aGraph = new MyGraph(subGraph1, subGraph2);
//ADDITIONAL WARNING! Don't touch subGraph1 or subGraph2
//because doing so will change aGraph.
//ADDITIONAL ADDITIONAL WARNING! Don't use subGraph1 or subGraph2
//as parameters to grate a new MyGraph, because then things get REALLY ugly.So I have at least 2 possible solutions.
1. A complicated, expensive deep copy of a directed (possibly with cycles) MyGraph every time it's used in a constructor. Even though it's very likely never to be used again.
2. In the constructor check/modify a private "used" field in the parameters (ok because I have access to it) so I can't ever inadvertently re-use a MyGraph.
The second option introduces the idea of the "one-time use as parameter" pattern. Where, once used as a parameter, an object becomes invalid for any other use.
In some ways this pattern feels okay, and in others it "rubs me the wrong way".
A final consideration: this code is very generic, and is likely to be used by other developers, and I want to confuse/surprise them as little as possible.
So, finally, is option 2 ok? bad? so-so?
Would you cringe if you saw it?

To satisfy the curious.
Specifically, what I've done is implement "Regular Expressions" over a sequence of arbitrary objects as opposed to characters.
A bit of background:
http://forum.java.sun.com/thread.jsp?forum=4&thread=414189
I call them JOREs (Java Object Regular Expressions)
I was hoping to avoid the need to deep-copy a directed cyclical graph, because:
a. it's a bit of a pain and cpu hog
b. I really want to avoid StackOverflowErrors so all of my "recursive" functions are implemented with iteration and a Stack. That makes the copy even more of a pain and cpu hog.
It works now.
I have made JOREs immutable and have implemented a deep-copy function.
The directed graph is my FA, and I had to "invent" a sensible way of putting together complex JOREs out of simple rules and sub-JOREs. This is what it looks like to put one together:
       Rule anyStringOfLength7 = new Rule("any String of length 7"){
            public boolean accepts(Object o)
                return (o instanceof String && ((String)o).length()==7);
        Rule aNull = new Rule("a null"){
            public boolean accepts(Object o)
                return (o==null);
        Jore nullOrStringOfLength7 = Jore.createNew().or(
                Jore.createNew().then(aNull),
                Jore.createNew().then(anyStringOfLength7)
        //note that the instance methods return a new Jore, and always
        //deep-copy parameters before using them now
        Jore myJore  = Jore.createNew().then(aNull).then(nullOrStringOfLength7).finish();

Similar Messages

  • If i buy an iphone 5s sprint can i use it for CDMA? I ask that because i went out of the country one time and used it on a CDMA network but that was my iphon 5 not an i phone 5s.

    if i buy an iphone 5s sprint can i use it for CDMA? I ask that because i went out of the country one time and used it on a CDMA network but that was my iphon 5 not an i phone 5s.

    Sprint is a CDMA carrier, same as Verizon so it will work on CDMA.

  • What is the best way of creating a one-time backup using DPM 2012R2?

    Hello,
    Due to some severe tape issues, we have lost a lot of our long-term storage data.
    I schedule a recovery point on our servers every Friday, once a week.  We retain this data for the 64 weeks (the maximum amount of versions DPM allows.)
    Management needs me to put one recovery point from each month to tape (preferably from the beginning of each month.)
    From the DPM console, I have been manually searching each server and running a recovery job from each "short term" recovery point we still have in the system.   I am recovering this data to a large disk array that I'm using as a staging
    area.  My intention is to take this data and put it onto tape using DPM and leave it there forever (20 years.)
    Since the space on the array is limited, I can only recover a few months at a time before having to delete the recoevered data to make way for the next group.
    The way DPM works it seems you must have a protection group for every backup job you run;  so if I have to repeat this process 8 times, I'll end up with 8 different protection groups all assigned to the host running the staging array.  NOTE: 
    the host running the staging array will be wiped in the near future.
    What would be the best method to carry this task out ?
    This forum post is similar, but doesn't address all these additional groups created:
    https://social.technet.microsoft.com/Forums/en-US/f379740c-4507-4a82-b275-c95e3e968b57/dpm-2012-r2-perform-one-time-backup?forum=dataprotectionmanager
    Any assistance would be welcome!
    Matthew J. Fazio

    Hi,
    What you can do is protect the staging server by using a single share - lets call it STAGING for simplicity.
    Perform your first set a restores and restore to the staging share, you can create meaningful subdirectories one for each data source you are restoring.  
    Now protect the STAGING share using DPM - protect using long term to tape only, Frequency yearly, and set retention policy for 20 years. 
    Perform an ad-hoc backup (right-click the data source and create recovery point to tape)
    When that completes, delete the sub-directories under the staging share and then repeat the process of restoring more data then backing up the same share.  When you are all done, you can remove the protection group, but maintain the tape backups
    so they will be available for restores. 
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Mike J. [MSFT]
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • How can load properties file for one time and use in entire application

    Hi folks,
    I dont want to read properties file every time , and want to get property value in any servelet or jsp page.(means i want to read only property file only for once and want to get value in any where ) , how to do this.
    Message was edited by:
    RajeshwarReddyT

    means we have to read file every time Know but i dont
    want to be happen that ??? No you don't . You read the file once. You store it in the hashmap. Then you hand that hashmap to whatever class needing the data.
    getProperties() returns the hashmap, doesn't read the file.
    Maybe I should have called the method getMap or something.
    Message was edited by:
    karma-9

  • How to call a stored procedure with only one output parameter using toplink

    Can anybody help me to get out of this exception. I have tried through several ways, but could not find the solution.
    I have a following stored proc : -
    CREATE OR REPLACE PROCEDURE spt_remove_duplicates_pr (outbuffer OUT VARCHAR2)
    IS
    buff VARCHAR2(32000) := ' ';
    BEGIN
    buff := ' Hi From Stored Proc' ;
    outbuffer : = buff;
    END;
    When I am executing it using following code :-
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("spt_remove_duplicates_pr");
    call.addNamedOutputArgument("a","a",String.class);
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    String buff1 = (String) session.executeQuery(query);
    I am getting the exception as : -
    LOCAL EXCEPTION STACK:
    EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.4 (Build 432)): oracle.toplink.exceptions.DatabaseException
    EXCEPTION DESCRIPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    INTERNAL EXCEPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    ERROR CODE: 6550
         at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
         at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
         at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(Unknown Source)
         at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ValueReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
         at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at com.marshmc.eta.reuse.persistent.PersistentService$DuplicateRemovalThread.run(Unknown Source)
    INTERNAL EXCEPTION STACK:
    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1141)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2149)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2032)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2894)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(Unknown Source)
         at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
         at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
         at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(Unknown Source)
         at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ValueReadQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
         at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
         at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
         at com.marshmc.eta.reuse.persistent.PersistentService$DuplicateRemovalThread.run(Unknown Source)

    I got the partial solution. The code is working now, however I am not getting the return value from stored proc.
    The changed code is as :-
    StoredProcedureCall call = new StoredProcedureCall();
    call.setProcedureName("spt_remove_duplicates_pr");
    call.addNamedOutputArgument("outbuffer","outbuffer",StringBuffer.class);
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    StringBuffer buff1 = (StringBuffer) session.executeQuery(query);
    System.err.println("Done ! Output is : " + buff1);
    The result is :-
    Done ! Output is : null
    How can I get the output ?

  • FI doc post (IDoc FIDCCP02 - One Time Vendor entry)

    I am posting an FI document and entering a one time vendor. In segment E1FISEG, field HKONT I enter 'ONETIME' (one time vendor). In segment E1FISEC, I enter the one time vendor info. When I create the IDoc, I get error 'No account specified in item 0000000001'. Any idea where this account comes from? It works fine when I create an FI doc with a one time vendor using trans FB01 manually.

    Hi Ray,
    what's about struc. E1FINBU
    and field E1FINBU-LIFNR ?
    i think you do'nt fill E1FISEG-HKONT for vendor-line!
    regards Andreas

  • Get customer invoice address from one time vendor

    Hi All,
    I am working on cheque printing.
    I have a question with in that.Customer wants if Vendor is one time vendor.
    I can identify the one  time vendor using 'LFA1-XCPDK  is 'X'  then the customer invoice assress priting in screen
    How can identify the custome invoice address from one time vendor
    Please any suggestions are helpful

    Hi Tarangini,
    I hope it is a third party scenario. Get the sales order number from the purchase order created with that vendor. EKPO table contains PO line item with sales order as the reference document.
    From the sales order , get the invoice from VBFA table. Pass this Invoice number to get the customer from (VBRK). Pass this customer to (KNA1) to get the address number. Pass this Address number to ADRC to get the customer address.
    Regards,
    Sai

  • HT1368 how to download my whole wish list at one time

    how to download my whole wish list at one time. Used to be a button that you could click on and buy everything that was in your wish list I dont see that button anymore and it looks like know you have to click on each song one at a time is this right/

    The 'buy all' button has been removed (possibly because people were accidentally clicking on it) so you now have to buy each item individually by clicking on their prices

  • Posting to One time Vendor with SPL GL indicator

    Hi Experts,
    I want to post to a one time vendor using a special GL indicator.
    Standard SAP does not allow this.
    Is this possible through some round about way  without a very big z development.
    if not then is there any other way out.
    Regards,

    Hi trivedy
    You can post with Spl G/l to one time vendorsalso. What you have to do is that, create a Spl G/l for One time vendors. (i.e) In T.Code OBYR, create a Spl G/l for One time vendors and enter the recon a/c for One time vendors specified in One Time Vendors master data ad try to post. Hope this helps.
    Regards
    Rajaram

  • Vendors: One-time Vendor

    Master Data u2013 Vendors: One-time Vendor
    Plz. suggest how To control creation of One-time Vendor by creating authorisation groups and assigning to limited users ids.
    How to cofigure it.....
    Rgds,
    Navin

    Hi Navin,
    One time vendors can only be used for specific vendor account groups. Their is a flag for each account group in configuation for this. If one does not exist you will have to create a new vendor account group.
    To create a One Time Vendor use XK01 and select the OTV account group.
    When creating say a PO use your OTV account the transaction will prompt you for name, address etc (unlike a normal vendor).
    You experienced a problem with OTV's whereby users couldn't be bothered to create permanent vendors and just used the OTV account, so beware of that.
    For further inputs refer the links.
    [SDN Thread|one time vendor]
    [Ont time Vendor|http://www.portal.state.pa.us/portal/server.pt/gateway/PTARGS_0_2_5333_711_208572_43/http%3B/pubcontent.state.pa.us/publishedcontent/publish/global/files/management_directives/financial_management/310_28.pdf]
    Regards,
    Shyamal

  • One time Cus/Ven

    Hi,
    I we have 100 one time vendor, hope we don't have to maintain master record for each vendor but how can we main their account and do payment transactions.
    I read the SAP material it says we have to create collectiv master record, does it mean one master record for all 100 vendor if so where can we provide details for all 100 vendors in one master record.
    Thanks,
    Nivi

    Hi Ram
    i am giving the the small defination about the one time vendor.
    One time vendors can only be used for specific vendor account groups. Their is a flag for each account group in configuation for this. If one does not exist you will have to create a new vendor account group. 
    To create a One Time Vendor use XK01 and select the OTV account group. 
    When creating say a PO use your OTV account the transaction will prompt you for name, address etc (unlike a normal vendor). 
    You experienced a problem with OTV's whereby users couldn't be bothered to create permanent vendors and just used the OTV account, so beware of that. 
    nagesh

  • Regarding advance receipt from one time vendor

    Hai friends,
                    i am trying to receipt advance from one time vendor. while i am posting in f-48 i am getting a error that there is no necessary setting for special gl transactions for one time vendor. can any one help me to sort it out
    thanks
    sam

    Basically for one time vendor, TDS processig is not supported. As one time vendor means that the master data can be changed to post the transaction with different one time parties using the same master.
    And if the TDS is deducted for such master, then while processing the TDS certificae and other reporting the data will not be correct.
    So if you need to do TDS processing, you need to define a regular vendor.
    Regards,
    Gaurav

  • One time customer dunning

    hello experts,
    i wanna know the procedure of assigning our defined dunning procedure to one time customers... after F150 schedule run, i want to assign to 1time customer... where i can get this customer record....
    so, help me out of this problem...
    thanks,
    Regards..
    Suresh

    Hi,
    Good morning and greetings,
    Eventhough you create an one-time account group for the customer and assign a dunning procedure, at the time of running F150 it would display the name of the customer as the present name in the letter.
    For tackling this problem, all you have to do is while creating an invoice for the one-time customer, using Substitution Rule (TCode GGB1) pass on the customer name to the Assignment Field or Text Field and then while printing Dunning Letter, the SAPScript to print the name of the customer from the Assignment Field or Text Field.
    Please reward points if found useful
    Thanking you
    With kindest regards
    Ramesh Padmanabhan

  • How to compile files in package and its subpackages at one time

    I have package A , under A there are files and subpackages B,C,D, How can I complie files in A,B,C D packages with javac at one time besides using make. Thank you very much!
    Qi

    Try something like:javac -d <destination directory> directory1/*.java directory2/*.java directory3/*.java

  • I downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    i downloaded an album on itunes using my new itouch; but it's only allowing me to put three songs at any one time into the music app...how can i get it to just move them all in there?

    hi philly, thanks for getting back to me, especially on such a busy day.
    I don't think that's quite the issue though. I bought an album and it appears in 'my purchases' within the itunes app. Yet, in order to listen to the music, i must use the 'music' app and in this application, there are only three tracks displayed at any one time from my downloaded album.
    I can 'download all' from the 'my purchases' section but that still doesn't help, it just keeps the last three tracks downloaded in the music app.
    I have the 'icloud' enabled and wondered if it had anything to do with that.
    i have successfully downloaded another full album totally into the music app, but this first album is causing me problems.

Maybe you are looking for

  • Java program not updating in correct sequence in applet

    Greetings, I have a java program with interactive graphic components. After completely writing the program, I create two shells ( or handle): an application shell with JFrame and an applet shell with JApplet. The application version of the program wo

  • Update to 10.1 but I'm still on 9.0.28.0

    In english: Hi everybody, First, here is my set: Windows 7 Home Premium 64-bit AMD Athlon X4 630 2.8 GHz 4 GB RAM ATI Radeon HD5700 1 GB RAM Using Firefox, Chrome and Safari It looks like I have some problems like others users: when I try to update F

  • How to update characteristics of DMS document

    Hello, I have a requirement to update characteristics right after document creation. I use BAPI_DOCUMENT_CREATE2 to create the document: CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'      EXPORTING        documentdata    = ls_doc      IMPORTING        docume

  • SOAP Exception from XI to R/3 via RFC

    Hello, We have a scenario where we are mapping SOAP Exception to RFC Exception. Message status is application error in SXI_MONITOR and in payload,it shows correctly mapped RFC Exception (SOAP_EXCEPTION) with name and message. But this message doesn't

  • Oracle Help in RH8, not working as it did before

    We're building Oracle Help in Robohelp & recently upgraded to RH8. When I delivered the files to our dev team, the files won't work. This is what our dev person wrote to me: When I try to load the Oracle Help I get the following error message: oracle