How to add observable behaviour in existing code?

Hi everyone, I'm new to design patterns. I have an existing numerical analysis package that I use to find roots using multiple strategy (bisection, secant, newton, etc). I want to show the process of root finding for every iterations taken by the algorithm (for example, iteration 0: left = 0, mid = 0.5, right = 1; iteration 2: left = 0, mid = 0.25, right = 0.5; ... etc. Its not exactly like that, I want to show it graphically, but you see what I mean). Looks like I need Observer to add event handling to notify the change of state in each initial guess as well as signaling the event when a root is/isn't found. But the solver classes doesn't seem to be implementing Observable, they just give out the answer, or not. How do I add Observer pattern without modifying the original code? I thought about using Decorator and having the real solver do the root finding but it just doesn't make sense to me. Thanx in advance.

endasil wrote:
georgemc wrote:
endasil wrote:
georgemc wrote:
That won't get you intermediate results, though.If the method being observed needs to be firing multiple events per invocation, no, it won't.
@OP, you were on the right track with the decorator pattern (indeed, that could be just as appropriate). What made you think it was wrong?I think that's the OP's tripping point:
I want to show the process of root finding for every iterations taken by the algorithm
...But the solver classes doesn't seem to be implementing Observable, they just give out the answer, or not.
Aha. Bytecode weaving (or plain old decompiling and nicking the source) then.Nope, I didn't. You're just too damned fast!For my own good! I hit "post" and immediately go "I forgot to say X" :-/
@OP: if you want to see some examples of using bytecode weaving to introduce observableness to existing code, have a look at the sources for a test coverage tool like Cobertura. That's basically what they do. If you've never done it before, it'll take you a fair bit of head-scratching and sideways thinking to get your head round it all, but stick with it. Be prepared to learn a bit about opcodes as well. Or maybe just plundering the sources for this library is the way to go, not that I'm advocating that ;)

Similar Messages

  • How to add blank page to existing Document In Adobe Dc

    how to add blank page to existing Document In Adobe Dc Pro

    Hi thashrifs16749461,
    You can add a blank page using Adobe Acrobat DC by following the below instructions :-
    1) Open your existing pdf document in Acrobat DC.
    2) Choose the 'Organize Page' option form the Tools pane on the right as shown below in the screen shoot.
    3) Now at the top you will see all the tools to Organize the page, Click on 'Insert' & select 'Blank Page' from the drop-down to insert blank pages.
    *Shortcut : If you are using windows computer you can use ' Shift+Ctrl+T ' key to insert blank pages.
    In case if you experience any issue or have any query please let us know. We will be happy to help you.
    Regards,
    Aadesh

  • How to add one column in existing search help.

    Hi Folks,
    My quesion is
    How to add one column in existing search help and also Now search help on that field is not an explicit search help. It should be implement using check table.
    Shivam

    Hi,
    If you want to add a field in Elementary search help, get the search help name for the and go to change mode and add the field in it.
    If you want to add a field in collective search help, go to included search helps tab and a new search help name and add the fields to it.
    I think this should help you to certain extent.
    Regards,
    Kranthi
    Edited by: Kranthi on Jan 14, 2010 11:15 AM

  • REG: How to add new fields to existing Infospoke

    Hi All,
    We have an existing Infospoke, It has ODS as a Source and some fields are being pulled.
    But here is the scenario....
    I need some extra fields that are available in other ODS. How to add that fields ?
    By some research came to know that.. I need to lookup on the ODS and populate into existing Infospoke.How to add these fields to InfoSpoke using BAdi implementaion.
    Note: already BAdi is active in the infospoke.
    Please help me in this regard

    Hi Chase,
    As you mentioned that BADI is already implemented then I guess you should be able to extend the existing BADI itself.
    For doing lookup first you should know the key fields of source DSO then by using the existing field of Infospoke you will have to read data from DSO.
    DATA: it_data type standard table of 'DSO Name'.
    select Key1 key2 etc...
              Field1 Field2 Field3 Field4
              from DSO
              into table it_data
              for all entries of infospoke
             where key1 = infospoke1-key1
                         key2 = infospoke2-key2.
    This will give you all the required records from source DSO into internal table it_data. Now you using this table you can populate the original table of Infospoke.
    Regards,
    Durgesh.

  • How to add a new character in code page

    Hi,
    I need to add a new character to existing code page in the upgraded system.
    The character is latin small s with caron (u0161 ).
    The character ID is 000161.
    What is the byte sequence of the same?
    Thanks and Regards
    Shraddha

    Use tranaction SCP .
    Under segment , take the character sequence and include your new id value . Byte sequence in my opinion will be confirmed from the client .
    Br,
    Vijay.

  • How to add abap stack to existing NW Java engine- for XI installation

    Hi All,
    I am having a netweaver Java Stack installed on my system. I would like to install XI - in order to install Xi ,I guess the system should be ABAP + Java. But since I am having java based engine, I would like to add ABAP stack to it. So, my question how to add an ABAP stack to already existing JAVA/J2ee engine.
    So what this process is known as-- Is it upgrading or New Installation. Because I need the guide and CD's for it.
    Can any one tell me which Guide(Install/upgrade/Master) wud help me.
    Thanks
    S

    Hi
    check the link www.service.sap.com/instguides>SAP Netweaver 7.0>installation guides there you can find what is the process which involves in installing ABAP+JAVA with PI
    Regards
    Uday

  • How to add a column in existing DTW template

    Dear Expert,
    I want to add a column which is in table structure of JDT1 but in DTW template that column is not there...
    In my JDT1 table that column has some value and i want that value to be enter thru DTW ..
    Give me step because at some stage i m making mistake....i know..
    please help me
    Thanks
    Kevin

    In JE DTW there is not proficode column, but i want that column to be loaded ?
    even i try by "target table" but still nt able to load of "profitcode" in that way
    How to add an existing column which is there in JDT1 table but not in JE DTW template ?
    Thanks
    Kevin

  • How to add id to the existing Authorization Object

    Hi,
    I want to add one id to the existing Authorization Object,How to add this?
    Here is my Object and existing ID's
    authority-check object 'Z_W2WALL' for user sy-uname
              id 'ZFREEZE' field r_freeze
              id 'ZLI01' field r_li01
              id 'ZLI11' field r_li11
              id 'ZLI14' field r_li14
              id 'ZLI11R' field r_li11n
              id 'ZLI20' field r_li20
              id 'ZMI10' field r_mi10
              id 'ZUPLOAD' field r_upload
              id 'Z_ARTFRZ' field r_artfrz.
    Now for this i want to add
      id 'Z_BIN' field r_frz.
    How to do this?
    Thanks

    Hi Sai,
    as there are already defined other id's have been added, you could also do the same way
    but this will also done through your basis end, where for this id your basis team will provide the
    authority to this id for the same purpose..
    authority-check object 'Z_W2WALL' for user sy-uname
              id 'ZFREEZE' field r_freeze
              id 'ZLI01' field r_li01
              id 'ZLI11' field r_li11
              id 'ZLI14' field r_li14
              id 'ZLI11R' field r_li11n
              id 'ZLI20' field r_li20
              id 'ZMI10' field r_mi10
              id 'Z_BIN' field r_frz
              id 'ZUPLOAD' field r_upload
              id 'Z_ARTFRZ' field r_artfrz.

  • How to add a Journal Entry - Error "Code undefined"

    Hi, i want to add a simple journal entry by using DI-Api. The problem is, i always get the error message "Code undefined" when I use the Debitor-AccountCode.
    My code is like that:
    oJ.TaxDate=dTaxDate;
    oJ.AutoVat=BoYesNoEnum.tNO;
    oJ.Lines.AccountCode="2000";    //Customer
    oJ.Lines.ContraAccount="4020";
    oJ.Lines.Credit=dCredit;
    oJ.Lines.Debit=dDebit;
    oJ.Lines.TaxDate=odTaxDate;
    oJ.Lines.ShortName="23121089";
    oJ.Lines.LineMemo="Ausgangsrechnung";
    oJ.Lines.Add();
    oJ.Lines.AccountCode="3500";   //VAT
    oJ.Lines.ContraAccount="23121089";
    oJ.Lines.Credit=dCredit;
    oJ.Lines.Debit=dDebit;
    oJ.Lines.TaxDate=odTaxDate;
    oJ.Lines.ShortName="23121089";
    oJ.Lines.LineMemo="Ausgangsrechnung";
    oJ.Lines.Add();
    oJ.Lines.AccountCode="4020";
    oJ.Lines.ContraAccount="23121089";
    oJ.Lines.Credit=dCredit;
    oJ.Lines.Debit=dDebit;
    oJ.Lines.TaxDate=odTaxDate;
    oJ.Lines.ShortName="23121089";
    oJ.Lines.LineMemo="Ausgangsrechnung";
    oJ.Add();

    Hi,
    Here is the code to find the BP account number:
    oRecordset = ((SAPbobsCOM.Recordset)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)));
                        oRecordset.DoQuery("SELECT [LinkAct_3] FROM [dbo].[OACP]");
                        oRecordset.MoveFirst();
                        if (oRecordset.EoF == true) // We have a Error
                            oCompany.GetLastError(out vmp_B1_Error_Code_int, out vmp_B1_Error_Message_string);
                            SBO_Application.MessageBox("Add-On Error (Forgestik Inc.): ERR-789 \n " + "Cash Account does not Exist "+ vmp_B1_Error_Message_string, 1, "Ok", "", ""); // My Error Code
                        else
                            vm_CachAccountNumber_string = Convert.ToString(oRecordset.Fields.Item("LinkAct_3").Value);
    ...Then you have to use the system account number "_SYS00000000353" not the displayed account number in B1...
    Thank you,
    Rune

  • How to add a custom PL/SQL code for a button event handler

    Hi All,
    I am a toddler in using Oracle Portal. So please forgive me for my ignorance.
    Q : How do I add a custom PL/SQL code for a button event handler?
    Basically, I would like to write MY PL/SQL function and call it. I could see that we can write "CUSTOM" code as "PL/SQL button event handler" in the form design window. But the question is that it expects only a "call" to procedure. But where do I define the procedure then? If I insert the procedure from the backend, it gets flushed the next time I compile my form.
    Hope I am able to explain my point.
    Thanks in advance,
    Abbas.

    Hi All,
    I am a toddler in using Oracle Portal. So please forgive me for my ignorance.
    Q : How do I add a custom PL/SQL code for a button event handler?
    Basically, I would like to write MY PL/SQL function and call it. I could see that we can write "CUSTOM" code as "PL/SQL button event handler" in the form design window. But the question is that it expects only a "call" to procedure. But where do I define the procedure then? If I insert the procedure from the backend, it gets flushed the next time I compile my form.
    Hope I am able to explain my point.
    Thanks in advance,
    Abbas.

  • OpenScript/How to add .jar file to Java Code in relative path

    Hi all,
    I want to add a .jar file which can be executed separately (like "java -jar A.jar") to my recorded Java Code.I've read this wiki http://everest2.us.oracle.com/wiki/Generic_JAR_Project about how to add a .jar file to "Assets", however, I cannot figure out how to use the .jarr file in Java code,I mean , how to get this .jar file like the method the databank added in "Assets"?
    Things I did are as followed:
    1.Execute my .jar file in OpenScript Java code with absolute path like this:
    String cmd = "C:\Users\A.jar";
    Runtime.getRuntime().exec(cmd);
    This does work, but must set a absolute path in Java code like "C:\User\A.jar" ,which is not the workaround I want (I need my scripts can be run on other machines).
    2.Try to get its current path with following codes:
    File directory = new File(".");
    String currentPath=directory.getCanonicalPath();
    However,though this can get its absolute path (which is the the project path) in Eclipse like "C:\Users\Workspace\testProject", this only gets "C:\OracleATS\openScript" in OpenScript.
    I thought to copy my .jar file to the project path , got its current path in java code first,then can know the path of .jar file, but this workaround failed because of the above reason.
    I notice that in the "Assets" there are "Databanks","Object Libraries","JAR Files","Scripts". Since the databanks and scripts that added to "Databanks" and "Scripts" can be got or run in Java Code like:
    *getDatabank("DatabankName").getNextDatabankRecord(); String data = eval("{{db.DatabankName.data}}");*
    *or getScript("ScriptName").run();*
    *Is there a method to get and run the jar file added to "Assets\JAR Files" like the above?*
    Thank you very much!
    Regards,
    Angyoung

    Hi DM,
    Thanks for your reply!
    I've found a workaround,which is calling OpenScript's APIs ,such as this.getScriptPackage().getRepository() and this.getScriptPackage().getWorkspace(),etc to locate the .jar file.
    And this workaround can still work even though the script is run on other machine.
    Sorry to reply you so late!
    Regards,
    Angyoung

  • How to add subpartitions to the existing subpartition template

    Hi All,
    My Question is ,how to add Subpartition to the exiting subpartition template. e
    like i have created a table with subpartition template with with 5 subpartitions like
    subpartiton one_1 value (121)
    subpartition two_2 value(122)
    and now i one to add one more subpartitin to the existing subpartition template(Like modify the existing subpartition templete).
    subpartition three_3 value(123)
    Could any suggest me.
    Thanks
    Sree

    >
    My Question is ,how to add Subpartition to the exiting subpartition template.
    >
    Follow the example in the section for 'Modifying a Subpartition Template' in the VLDB and Partitioning Guide
    http://docs.oracle.com/cd/E11882_01/server.112/e25523/part_admin002.htm#i1007904
    >
    You can modify a subpartition template of a composite partitioned table by replacing it with a new subpartition template. Any subsequent operations that use the subpartition template (such as ADD PARTITION or MERGE PARTITIONS) now use the new subpartition template. Existing subpartitions remain unchanged.
    If you modify a subpartition template of an interval-* composite partitioned table, then interval partitions that have not yet been created use the new subpartition template.
    Use the ALTER TABLE ... SET SUBPARTITION TEMPLATE statement to specify a new subpartition template. For example:
    ALTER TABLE emp_sub_template
    SET SUBPARTITION TEMPLATE
    (SUBPARTITION e TABLESPACE ts1,
    SUBPARTITION f TABLESPACE ts2,
    SUBPARTITION g TABLESPACE ts3,
    SUBPARTITION h TABLESPACE ts4

  • How to add Document group  in t code S_ALR_87012082 for dynamic selection.

    Hi Gurus,
    I Need to add  Document group  in t code S_ALR_87012082  for dynamic selection.
    Currently here two groups are showing , Vender and Comp Code. i need to add Document group  there. Kindly guide me in this.
    Thanks in advance.

    Hi
    Pls follow below report
    *S_ALR_87012103 - List of Vendor Line Items *
    In dynamic selections you can find Document number, there you can give the range
    Reg
    Vishnu

  • How to add an icon for ok code at the bottom of the screen.

    hi,
    I have designed a screen with a table control.
    I want to have at the end of the screen a ok and a cancel button.
    For example in menu painter on top we have a icon for going back, exit etc.
    At the same way at the bottom of the screen i need to have a tick icon. How to add it at the end of the screen.

    Hi Josephine
    Please proceed as below:
    1. SE51.
    2. Change the layout.
    3. Add 2 pushbuttons at your desired location.
    4. Double click on each button for Attributes.
    5. In the attributes, give the Name, Text.
    6. Select the Icon Name from the list: Eg: ICON_OKAY and ICON_CANCEL.
    7. Go back to layout.
    8. Save & Activate
    9. Now you can test the screen to check the icons displayed in the screen.
    Hope this helps.
    Kind Regards
    Eswar

  • How to understand the logic of existing code

    Hi friends
    I am new to java and I got the job in a company. Now they give me task to complete which use existing api developed by sr developers. Now my question is how can i understant such a large project with almost 200000 line of code.
    It is web based project and using jsp and java mainly
    Can anybody suggest me how can I understand it so that I can use this api and develop new code
    Thanks

    Use the javadoc tool to create documentation for the code.
    Read the resulting documentation. Even if the senior developers didn't add any Javadoc comments (in which case, they're morons, despite being "senior"), it would be helpful just to see what the methods and classes are. In particular, look at the interfaces in the code. In well-crafted code, you get a good bird's-eye-view of the structure by looking at the interfaces and the relationships between them (in my opinion).
    It's possible that the code is simply crap, in which case, you're in for a long hard slog my friend.

Maybe you are looking for

  • My iPhone 5 is getting very hot and battery drains quickly.. normal?

    I've been having a variety of signal related problems with my iPhone 5 and I'm wondering if anyone can offer any advice.  From day 1 I have observed that my phone will have poor signal strength or will switch from 4G or LTE into Edge mode, even if my

  • Windows Vista + iTunes 7.6.0.29 = disaster

    I installed iTunes 7.6.0.29 on my new Vista machine and now when I try to launch iTunes it just hangs - shows as "not responding" in the Task Manager and I cannot kill the process. It prevents proper shutdown of the machine as well - I have never had

  • I can't boot from the windows cd with boot camp

    I got Vista up and running via boot camp but now I have a problem that could cause some issues. How the **** do you boot from a windows cd with boot camp!?!? When I stick in the windows based CD (could be the vista install CD -after vista's been inst

  • Duplicate records in Internal table

    Hi All, I want to find out the duplicate entry in the internal table. I have used, Delete Adjacent duplicates from itab. It is straight away deleting the record. I want the user to correct that duplicate record. May be some error message. I have trie

  • IsValid('xml', myXML) BUG!

    isValid('xml' should return a boolean true/false, but if the xml is bad it throws an error instead. Anyone else have this issue or find a workaround other than using isXML which works? <cfsavecontent variable="myXML"> <parent> <child>A&L</child> </pa