Code refactoring

Hell code refactoring!
I inhirite a Java application that was written 15 years ago with millions lines of code
The code has many problems, including some very basic stuff like comparing object using ==. But somehow, it works and the company keeps using it
The problem we are facing is the code doesn't support debugging. ALL of the methods have very limited number of variables. The coders writting something like this all over places
if(getA().getB().getC().getD().getE().getM().equals(getA().getB().getC().getD().getE().getN()){
     getA().getB().getC().getD().getE().getM().setZ(getA().getB().getC().getD().getE().getN().getZ());
int num = getA().getB().getC().getD().getE().getM().getList().size();
for(int i = 0; i<num; i++){
    getA().getB().getC().getD().getE().getM().getList().get(i).setSomething();;
It is unbelievable but it is real. Some of them have more than 10 get() on the same line
I try to refactor it, adding local variables into the methods, so we can resuse the objects instead of using lines of get()
It also help debugging the code possible because there are many recursive calls plus the above style make it almost impossible now. Whenever something happens, it took me days to figure out what is wrong
I am going to break the get() chains but since the code base is huge, I don't know if we have some tools availble.
If someone has solved similar problem, please give me some advice.
Thank you very much

2/ The code has many problems, not a single one. but I feel most important is debuggable.
Well so far you haven't mentioned a single problem with the code. Further, the code sample you posted is 'debuggable'. But, again, you don't need to 'debug' code that works correctly.
The below is a real function of the code that I renamed all the terms
What is it about that code that makes you think it is not 'debuggable'?
You have to pick your battles. You can't try to rewrite/refactor code just because you don't like the way it was written. That is NOT productive.
Assuming you even have a need to refactor anything the first step is to identify the CRITICAL code sections/elements/classes/methods. Critical either because they are performance issues or critical because they are what keeps breaking.
There are almost no comments in the code,
Then, as I already mentioned, the FIRST step is to analyze the code and DOCUMENT IT. You posted a code snippet and said ABSOLUTELY NOTHING about what that method is supposed to be doing. Why not? Why didn't you post a comment? Have you 'analyzed' that code you posted? If not, why not?
Your analysis should START with the method signature; the parameters and return type. Have you look at that for the sample you posted? If not, why not?
Do you see anything unusual about it? I do.
private Double returnCRValue(TsTRatingOperation aetnRatingOperation, String id) throws Exception {  
Throws Exception? Almost any coded might throw an exception so why does this method just mention a generic exception instead of a specific one.
The signature declares that the method returns an instance of Double. Does it actually do that?
BigDecimal dbvalue = null;
return dbvalue == null ? null : new Double(dbvalue.doubleValue());  
Why does the method use BigDecimal in the body but then convert the value to a Double for the return? What if that BigDecimal value can't be converted properly to a Double without losing precision? Why isn't the method returning a BigDecimal? Then the caller can perform any conversions that might be necessary.
The SECOND place to look for issues is the logic flow of the method. Does every IF statement have an ELSE? If not then why not. A common source of bugs is missing ELSE statements that cause code to fall through and work wrong when the IF condition isn't met. Same with CASE/SWITCH statements; big problem with fall through execution if a BREAK statement is missing when it is needed.
Do you see any logic issues with that code you posted? I do.
        int nPolModTotal = 0;  
        if (aetnRatingOperation.getTsTRatingPASOperationTerm().get(0).getOperationCRs() != null) {  
            nPolModTotal = aetnRatingOperation.getTsTRatingPASOperationTerm().get(0).getOperationCRs().size();  
        //loop CRs  
        for (int n = 0; n < nPolModTotal; n++) {  
            String sid = aetnRatingOperation.getTsTRatingPASOperationTerm().get(0).getOperationCRs().get(n).getCRTypeReferenceCode().trim();  
            if (sid.equals(id.trim())) {  
                dbvalue = aetnRatingOperation.getTsTRatingPASOperationTerm().get(0).getOperationCRs().get(n).getModFactorValue();  
.. even more, possibly disastrous processing follows
The value of 'nPolModTotal' is set to zero.
Then there is an IF statement that MIGHT SET it to a real non-zero value.
But WHAT IF IT DOESN'T? The rest of the code in the method will still execute. That for loop will escape ok because of its initialization statements but the next FOR loop will still execute. Is that the correct behaviour? I have no way of knowing. But it is certainly suspicious code for the second part to execute and compute a return value when the first part failed to execute.
I would want to know why the code works that way and if it is correct or a bug waiting to happen.
Loops of all kinds are also problematic: wrong initialization, wrong termination, unnecessary code within the loop instead of before the loop. Do you see any of the problems in the method you posted? I do.
//loop CRs    
        for (int n = 0; n < nPolModTotal; n++) {  
            String sid = aetnRatingOperation.getTsTRatingPASOperationTerm().get(0).getOperationCRs().get(n).getCRTypeReferenceCode().trim();  
            if (sid.equals(id.trim())) {  
                dbvalue = aetnRatingOperation.getTsTRatingPASOperationTerm().get(0).getOperationCRs().get(n).getModFactorValue();  
Why does EVERY iteration potentially set (and overwrite) the value of 'dbvalue'?
If the code is looking for a single match then it should EXIT the loop when it finds it. Why iterate through hundreds or thousands of entries (depending on the value of 'nPolModTotal') if you found your 'sid' on the very first match?
What if there are two matches for that IF statement above? The value of 'dbvalue' will be set to the LAST ONE found. Is that the correct behaviour?
There is nothing inherently wrong with those concatenated 'get' operations.  I'm assuming by your comments that you want to 'refactor' this line of code
aetnRatingOperation.getTsTRatingPASOperationTerm().get(0).getOperationCRs()
by creating an instance variable and capturing that value and then using that instance variable in the following loop?
myOperationsCRs = aetnRatingOperation.getTsTRatingPASOperationTerm().get(0).getOperationCRs() ;
for (int n = 0; n < nPolModTotal; n++) {    
            String sid = myOperationsCRs.get(n).getCRTypeReferenceCode().trim();
  Why? Why do you think you should 'refactor' that code and use an instance variable for the intermediate result?
As I said before if I were you I would forget refactoring the code and focus on:
1. analyzing what it does
2. adding appropriate comments and annotations (e.g. for the parameters and return type
3. identifying any logic issues (as I did above)
4. researching those logic issues with a possible plan to fix them

Similar Messages

  • Code refactoring / Indenting

    Are there any code refactoring tools available in the new code editor for Flash Professional CC? Sometimes I like to write in pure actionscript, in which case I'll use FlashBuilder. But a lot of times when I work with an artist who makes layouts and assets in Flash Professional, it would be nice to just be able to just work completely in flash without having to switch back and forth to FB.
    I like the new fast, streamlined code editor in Flash CC, but it is missing some great tools (as far as I can tell):
    From most important to least important:
    Refactoring (easily rename methods, properties and references.. This is a big one for me.)
    Correct Indentation
    Generate Getter / Setter
    Organize Imports
    I don't need the full robust tool set of Flash Builder, but at least a couple of simple tools would go a long way to making the code editor more powerful.
    Thanks!

    Are there any code refactoring tools available in the new code editor for Flash Professional CC? Sometimes I like to write in pure actionscript, in which case I'll use FlashBuilder. But a lot of times when I work with an artist who makes layouts and assets in Flash Professional, it would be nice to just be able to just work completely in flash without having to switch back and forth to FB.
    I like the new fast, streamlined code editor in Flash CC, but it is missing some great tools (as far as I can tell):
    From most important to least important:
    Refactoring (easily rename methods, properties and references.. This is a big one for me.)
    Correct Indentation
    Generate Getter / Setter
    Organize Imports
    I don't need the full robust tool set of Flash Builder, but at least a couple of simple tools would go a long way to making the code editor more powerful.
    Thanks!

  • Legacy code refactoring

    I have inherited a swing Applet project and there's a bunch of dodgy code, once of them is that the first parameter in most of the constructors is an "owner" reference to the Japplet extension.
    Because the code parts are not decoupled it is hard to extract functional units in order to use them for tests, demos or to re-use them in other projects.
    Looking at the code (30 .java modules) about half of the units reference the "owner" to access up to 50 different properties and methods. It's been suggested that I uses the interface segregation principle ("Refactoring: Improving the Design of Existing Code", Martin Fowler) to refactor to use an interface rather than the applet reference.
    Are there any other suggestions on how to reference the Applet in the other Java units without the code being so coupled?
    All comments are appreciated.
    Thanks, Tom.

    I would use interfaces, but I would also look at the code and wonder why 30 classes need to access 50 methods in this monster class. You might be able to move some logical code together or create some utility classes.

  • VIrtual PC version 7:  (Windows XP Home or Pro) on an iBook???

    Hello all,
    I currently have an iBook G4 with 1.33GHz, 256MB built in, 512MB L2 cache. I have 33.1 GB available on a 55.8 GB internal hard drive, plus an 80GB external iOmega hard drive.
    I've asked around regarding installing Virtual PC (windows XP) on my iBook and how it would run. Many are suggesting just to "forget it" becuase it will run slowly.
    The reason I need this Virtual PC is for a computer courses at college; they all run on Windows XP (Visual Basic, etc). I don't want to give up my Mac for a Windows machine just for college...so Virtual PC was my best option.
    What do you think?
    Thank you in advance for all your help!!!
    [email protected]
    iBookG4   Mac OS X (10.3.8)   External 80GB iOmega hard drive
    iBookG4   Mac OS X (10.3.8)   External 80GB iOmega hard drive

    I wouldn't recommend doing development on a virtual pc platform - especially on stretch system resources like yours. All but the most trivial projects require lots of memory and processing to develop and compile. Integrated Development Environments such as MS Visual Studio are well known to be resource hungry - especially when you start using features like code refactoring and debuggers all of which you will learn about on your college course.
    See if you can pick up a cheap laptop - especially inquire at your college about leasing deals - even a basic modern laptop will outperform a VPC on your system any day of the week.

  • Report Viewer control issue in Windows Server 2012 R2

    Hi,
    I have a reporting application (web) and it is using the Microsoft.ReportViewer.WebForms.dll (version 11.0.3366). While deploying I have kept all the Reporting Viewer related dll's into the bin directory and things are working fine in the below combinations.
    1) Windows Server 2008 R2 , SQL Server 2008 R2 SP2
    2) Windows Server 2012 and SQL Server 2012
    Today I have installed the same setup into the Windows Server 2012 R2 (with SqlServer 2012) machine and I am facing the some issue. The Print icon and find/next options are not visible in the Report Viewer . I am not sure what was the cause for this.
    Then  I have installed the Report Viewer 2012 runtime on the Windows Server 2012 R2 machine and things are working fine. So , I am wondering how the same setup worked fine in other two combinations with out installing Report Viewer 2012 runtime.
    Did any one have idea/suggestion on this.
    Thanks in advance!
    Best Regards
    Muthuraja

    Have you verified that the runtime assemblies are not on those servers? Maybe someone else added them. There are numerous other possibilities such as code refactoring that moved these elements from to other assemblies (unlikely) or that there was some other
    difference in your installation that you overlooked. I am glad that you were quickly able to resolve your issue however and may help others if they experience the same problem.
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • Bind variable "LOOP" not declared.

    Hi,
    I am very new to Pl/SQL.My job needs me to migrate MySQL database to Oracle(that I did successfully) but the procedures in the MySQL could not be migrated to Oracle,So have to create them manually.
    While creating procedure,Am getting these errors
    Error(4,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior The symbol "begin" was substituted for "DECLARE" to continue.
    Error(5,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior
    CREATE OR REPLACE PROCEDURE PROCEDURE1 AS
    BEGIN
    Declare v_date date;
    Declare v_particulars varchar(50);
    Declare v_quantity float default 0;
    Declare v_item integer default 0;
    Declare v_vendor integer default 0;
    Declare v_flag integer default 1;
    Declare v_supplier_id integer default null;
    Declare v_unit integer default 0;
    Declare v_srno integer default 0;
    Declare op_date date;
    declare op_bal float default 0;
    Declare temp_v_from_date date;
    Declare temp_v_to_date date;
    Declare done integer default 0;
    Declare cur1 cursor for  (select  sibs.opening_balance_date,'Opening Balance',sibs.item_id,
    sum(sibs.opening_balance_qty), '1'from store_item_batch_stock sibs  where sibs.opening_balance_date is not null
    and sibs.department_id = v_depart  and  sibs.item_id = v_item_id group by sibs.item_id);
    Declare cur2 cursor for  (select sgm.grn_date, concat('Receipt',' - (',sgm.grn_no,')'), sgt.item_id,
    sum(NVL((case d.formula when 1   then ((sgt.received_qty + sgt.free_qty) * sgt.mdq_value) / d.conversion_factor1
    else (sgt.received_qty + sgt.free_qty) end),0)), '2',sgm.supplier_id,sgm.unit_id from store_grn_m sgm,
    store_grn_t sgt, mas_store_item c, mas_store_item_conversion d
    where sgm.grn_date between v_from_date and v_to_date and  sgm.department_id = v_depart
    and   sgt.item_id = c.item_id  and   c.item_conversion_id = d.item_conversion_id  and   sgt.grn_master_id = sgm.grn_master_id
    and   sgt.item_id = v_item_id group by sgm.grn_master_id         );
    Declare cur3 cursor for (select sim.issue_date,concat('Issue',concat(' -(',concat(sim.issue_no,')'))), sit.item_issued,
    sum(NVL(sit.qty_issued,0)), '3'  from store_issue_m sim, store_issue_t sit
    where sim.issue_date between v_from_date and v_to_date and   sim.department_id = v_depart
    and   sit.issue_m_id = sim.id  and   sim.issue_type = 'i' and   sit.item_issued = v_item_id
    and   sit.issued = 'y' group by sim.id         );
    Declare cur4 cursor for (select sgrm.return_date, 'Vendor Return', sgrt.item_id,
    sum(NVL(sgrt.return_qty,0)), '3' from store_grn_return_m sgrm,store_grn_return_t sgrt
    where sgrm.return_date between v_from_date and v_to_date      and   sgrm.department_id = v_depart
    and   sgrt.grn_return_id = sgrm.grn_return_id  and   sgrt.item_id = v_item_id  group by  sgrm.grn_return_id         );
    Declare cur5 cursor for (select sadm.adjustment_date, 'Adjustment',sadt.item_id,
    sum(NVL(sadt.adjust_qty,0)), '2'                  from store_adjustment_m  sadm,
    store_adjustment_t  sadt where sadm.adjustment_date between v_from_date and v_to_date
    and   sadm.department_id = v_depart  and   sadt.adjust_id = sadm.id  and   sadt.item_id = v_item_id
    and   sadt.adjust_qty != 0 group by sadm.id                  );
    Declare cur6 cursor for (select sim.issue_date,'Receipt (Internal)', sit.item_issued,
    sum(NVL(sit.qty_issued,0)), '2' from store_issue_m sim, store_issue_t sit
    where sim.issue_date between v_from_date and v_to_date      and   sim.to_store = v_depart
    and   sit.issue_m_id = sim.id   and   sim.issue_type = 'i'   and   sit.item_issued = v_item_id
    and   sit.issued = 'y' group by sim.id         );
    declare cur7 cursor for (select siam.adjustment_date, 'Adjustment',siat.item_id,
    sum(NVL(siat.adjusted_qty,0)), '2'                  from store_item_adjustment_m  siam,
    store_item_adjustment_t  siat where siam.adjustment_date between v_from_date and v_to_date
    and   siam.adjustment_login_dept = v_depart  and   siat.item_adjustment_m_id = siam.item_adjustment_id
    and   siat.item_id = v_item_id and   siat.adjusted_qty != 0 group by siam.item_adjustment_id
    Declare oldcur1 cursor for  (select sgm.grn_date, 'Receipt', sgt.item_id,
    sum(NVL((case when d.formula =1  then ((sgt.received_qty + sgt.free_qty) * sgt.mdq_value) / d.conversion_factor1
    else (sgt.received_qty + sgt.free_qty) end),0)), '2'                  from store_grn_m sgm,
    store_grn_t sgt, mas_store_item c, mas_store_item_conversion d
    where sgm.grn_date between '2009-03-31' and (v_from_date -1)
    and   sgm.department_id = v_depart  and   sgt.item_id = c.item_id  and   c.item_conversion_id = d.item_conversion_id
    and   sgt.grn_master_id = sgm.grn_master_id  and   sgt.item_id = v_item_id  group by sgm.grn_master_id  );
    Declare oldcur2 cursor for (select sim.issue_date,'Issue', sit.item_issued,
    sum(NVL(sit.qty_issued,0)), '3' from store_issue_m sim, store_issue_t sit
    where sim.issue_date between '2009-03-31' and (v_from_date -1)
    and   sim.department_id = v_depart  and   sit.issue_m_id = sim.id  and   sim.issue_type = 'i'
    and   sit.item_issued = v_item_id   and   sit.issued = 'y' group by sim.id         );
    Declare oldcur3 cursor for (select sgrm.return_date, 'Return', sgrt.item_id, sum(NVL(sgrt.return_qty,0)), '2'
    from store_grn_return_m sgrm, store_grn_return_t sgrt
    where sgrm.return_date between '2009-03-31' and (v_from_date -1)
    and   sgrm.department_id = v_depart   and   sgrt.grn_return_id = sgrm.grn_return_id   and   sgrt.item_id = v_item_id group by sgrm.grn_return_id );
    Declare oldcur4 cursor for (select sadm.adjustment_date, 'Adjustment',sadt.item_id,
    sum(NVL(sadt.adjust_qty,0)), '2'  from store_adjustment_m  sadm, store_adjustment_t  sadt
    where sadm.adjustment_date between '2009-03-31' and (v_from_date -1)  and   sadm.department_id = v_depart
    and   sadt.adjust_id = sadm.id   and   sadt.item_id = v_item_id  and   sadt.adjust_qty != 0 group by sadm.id );
    Declare oldcur5 cursor for (select sim.issue_date,'RCPT', sit.item_issued, sum(NVL(sit.qty_issued,0)), '3' from store_issue_m sim,
    store_issue_t sit where sim.issue_date between '2009-03-31' and (v_from_date -1)  and   sim.to_store = v_depart
    and   sit.issue_m_id = sim.id   and   sit.item_issued = v_item_id   and   sit.issued = 'y' group by sim.id );
    declare oldcur7 cursor for (select siam.adjustment_date, 'Adjustment',siat.item_id,
    sum(NVL(siat.adjusted_qty,0)), '2'                  from store_item_adjustment_m  siam,
    store_item_adjustment_t  siat where siam.adjustment_date between '2009-03-31' and (v_from_date -1)
    and   siam.adjustment_login_dept = v_depart  and   siat.item_adjustment_m_id = siam.item_adjustment_id  and   siat.item_id = v_item_id
    and   siat.adjusted_qty != 0 group by siam.item_adjustment_id
    Declare closingStockUpdateCursor cursor for(select sno,date,qty,flag from ledger where dept_id = v_depart  and item_id = v_item_id
    and flag!=0 order by date  );
    Declare continue handler for not found set done =1;
    delete from ledger where item_id = v_item_id and dept_id = v_depart;
    Open cur1;
    item_loop:loop
    Fetch cur1 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    if not (v_date > v_from_date) then
    set op_bal = v_quantity;
    set op_date = v_date;
    End if;
    End loop item_loop;
    Close cur1;
    set  done = 0;
    Open oldcur1;
    item_loop:loop
    Fetch oldcur1 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    set op_bal = op_bal + v_quantity;
    End loop item_loop;
    Close oldcur1;
    set  done = 0;
    Open oldcur2;
    item_loop:loop
    Fetch oldcur2 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    set op_bal = op_bal - v_quantity;
    End loop item_loop;
    Close oldcur2;
    set  done = 0;
    Open oldcur3;
    item_loop:loop
    Fetch oldcur3 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then   Leave item_loop;
    End if;   set op_bal = op_bal + v_quantity;
    End loop item_loop;
    Close oldcur3;
    set  done = 0;
    Open oldcur4;
    item_loop:loop
    Fetch oldcur4 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    if op_date != v_date then
    set op_bal = op_bal + v_quantity;
    End if;
    End loop item_loop;
    Close oldcur4;
    set  done = 0;
    Open oldcur5;
    item_loop:loop
    Fetch oldcur5 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then   Leave item_loop;
    End if;
    set op_bal = op_bal + v_quantity;
    End loop item_loop;
    Close oldcur5;
    set  done = 0;
    Open oldcur7;
    item_loop:loop
    Fetch oldcur7 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then   Leave item_loop;
    End if;
    set op_bal = op_bal + v_quantity;
    End loop item_loop;
    Close oldcur7;
    set  done = 0;
    insert into ledger(date, particulars,qty,item_id,dept_id,flag,closing_stock)   values(v_from_date,'Opening Balance', op_bal, v_item_id,v_depart,'0',op_bal);
    Open cur2;
    item_loop:loop
    Fetch cur2 into v_date, v_particulars, v_item, v_quantity, v_flag, v_supplier_id, v_unit;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,vendor_id,closing_stock,unit_id)   values(v_date,v_particulars, v_quantity, v_item,v_flag,v_depart,v_supplier_id,0,v_unit);
    End loop item_loop;
    Close cur2;
    set  done = 0;
    Open cur3;
    item_loop:loop
    Fetch cur3 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars,v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur3;
    set  done = 0;
    Open cur4;
    item_loop:loop
    Fetch cur4 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars,v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur4;
    set  done = 0;
    Open cur5;
    item_loop:loop
    Fetch cur5 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then   Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars, v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur5;
    set  done = 0;
    Open cur6;
    item_loop:loop
    Fetch cur6 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars, v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur6;
    set  done = 0;
    Open cur7;
    item_loop:loop
    Fetch cur7 into v_date, v_particulars, v_item, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    insert into ledger(date, particulars,qty,item_id,flag,dept_id,closing_stock)   values(v_date,v_particulars, v_quantity, v_item,v_flag,v_depart,0);
    End loop item_loop;
    Close cur7;
    set  done = 0;
    Open closingStockUpdateCursor;
    item_loop:loop
    Fetch closingStockUpdateCursor into v_srno,v_date, v_quantity, v_flag;
    If done =1 then
    Leave item_loop;
    End if;
    if v_flag = 2 then
    set op_bal = op_bal + v_quantity;
    else
    set op_bal = op_bal - v_quantity;
    end if;
    update ledger set closing_stock = op_bal where sno = v_srno;
    End loop item_loop;
    Close closingStockUpdateCursor;
    set  done = 0;
    END
      NULL;
    END PROCEDURE1;
    /Please help where I am getting wrong

    Another comment.
    If two products are identical in features, there is nothing much to differentiate one from the other. And this is important as the differences between products are what drives the buyer's decision as to which one is the best.
    There are major differences between Oracle and mySQL. Some of them core and fundamental differences. And this is what makes one product "better" than the other - and drives the decision on whether to use Oracle or mySQL.
    Oracle makes a poor mySQL. It does the Oracle thing very well. So it does not make sense to take a design and code that works for mySQL, plonk it down on Oracle, and think that Oracle's differences will now make this design and code work and perform "better".
    Everything but. As Oracle does a poor mySQL imitation, the end result of that will be a system that performs worse than what it did on mySQL.
    To make use of that which makes Oracle "better" than mySQL, requires the application to be redesigned and code refactored.
    So IMO, what you/your company are doing, is bound for failure. You will pay more money for a more sophisticated and very able RDBMS product - that is unable to reach its potential as you are asking it to pretend to be mySQL and to do that, better than mySQL. That is an epic fail.

  • SAP Business By Design Software- A Review

    SAP Business By Design Software- A Review
    An Independent Enterprise Resource Planning Software Review :
    SAP is one of the most recognized and trusted brands within the enterprise resource planning (ERP) software industry. Having delivered SAP R/2 in 1979 and SAP R/3 in 1992, the company is one of the original vendors that defined the ERP software market. SAP was started by five IBM engineers in 1972 in exchange for 8% founders' stock. Today the German-based company retains the largest ERP market share of any software vendor; with the possible exception of Oracle depending upon how market share is calculated.
    SAP Business ByDesign is the company's software as a service (SaaS) offering targeted to small- and medium-size enterprises (SMEs). On September 19, 2007, a one-size-fits-all, subscription-based ERP system aimed at midmarket companies was released as the first SAP ERP SaaS product, previously code named A1S. After several troubled installations and a flawed go to market strategy, SAP pulled ByDesign from the market for a system revamp and significant code refactoring.
    Approximately three years later, Business ByDesign reemerged as a multi-tenant SaaS solution, complete with a new architecture, Silverlight presentation layer and PaaS tools for extensibility. As of December 2011, Business By Design was closing in on its first 1000 customer acquisitions and is available in Australia, Austria, Canada, China, France, Germany, India, Switzerland, the United Kingdom, and the United States.
    Though SAP ByDesign is targeted toward SMEs with 25+ users, the solution can be used by organizations with as few as 10 users. The ideal range is 25-500 users, but the cloud scalability should facilitate more users if required. Business By Design is also finding a place as a Tier 2 ERP solution—being installed at smaller line of business or geographically dispersed locations and integrated to parent companies using the SAP Business Suite.
    While Business ByDesign is the company's first back-office foray into the cloud, SAP has since also released cloud-based Line of Business applications. Sales OnDemand—an SFA application with strong social design—was released in July 2011 and is targeted at SAP ERP or Business Suite customers looking to extend their on-premise systems with add-on cloud components. Interestingly, the Line of Business applications were developed on the Business ByDesign framework, but don't integrate with Business ByDesign. Sales OnDemand only integrates with SAP ERP for back office business processes, so SAP customers seeking a complete software as a service CRM solution are limited to Business ByDesign.
    By Design is offered in four enterprise software categories: customer relationship management (CRM), financials, professional services automation (PSA), and supply chain management (SCM). These solutions each include a combination of different modules, and they can be acquired as stand-alone capabilities as well. The entire ERP software suite includes the following:
    Customer relationship management (CRM)
    Accounting and financials
    Project management
    Supply chain management (SCM)
    Supplier relationship management
    Human resources (HR)/payroll
    Analytics
    Compliance management
    REF: -------------------------
    SAP Business ByDesign Independent Review

    SAP Business One GUIs (“screens” or “forms”) are the primary interface elements. They usually cover a rectangular area on the computer screen and represent certain tasks or applications running on the computer. The user may move them around the computer screen, size, stack, activate, or de-activate them.
                 When we discuss screens in the context of the SAP Business One System, we usually refer to their work area. You, as the developer, position interface elements within the work area to adapt a screen to a certain task. In addition to the work area, a screen consists of elements. Some elements serve for basic window handling, and some of them are specific for SAP Business One.
             There are two basic kinds of screens in the SAP Business One System: primary screens (main menu/forms), and secondary screens (dialog boxes / message windows).
              SAP Business One application functions always reside in one main or primary screen where the user's main activity takes place. In addition, secondary screens appear in reaction to the user's actions to supplement the main screen. On both types of screens, the user may enter data, make choices or is informed of errors / consequences of actions. There may be more than one secondary screen opened simultaneously, but only one can be worked with at a time

  • Initializing JDialogs or Other GUI Components within SwingWorker

    Hello Every one,
    I have been using SwingWorker class heavily in my application and recently I noticed that If I click on a button twice or thrice the third or 4th it takes more time to perform the action in which SwingWorker is being used. So I started reading more about SwingWorker and after reading number of articles and posts on this forum I believe I am not using SwingWorker correctly. But, I am not still sure ( or may be I am afriad or I am not ready to change my code in so many files and so many locations :(
    So I thought to ask some gurus following questions, in this forum before I proceeed with the code refactoring.
    Question 1:* I am performing GUI operations in doInBackground() is it ok to perform swing operations or create swing components in this method of SwingWorker?
    Example Code :
    jbtnModifyUser Action Event
    private void jbtnModifyUserActionPerformed(java.awt.event.ActionEvent evt) {
    setButtonsState(false);
    final SwingWorker worker = new SwingWorker() {
    protected Object doInBackground() {
    try {
    openUserModifierDialog(SELECTED_PROFILE);
    } catch (Exception ex) {
    ex.printStackTrace();
    } finally {
    return null;
    public void done()
    setButtonsState(true);
    worker.execute();
    }Open Dialog Method wich I call from several other Swing Components Action performed event
    private void openUserModifierDialog(UserProfile profile) throws ServerException {
    UserModifierDialog modifier = new UserModifierDialog(_frame, true, profile);
    modifier.pack();
    modifier.setVisible(true);
    if (modifier.isModified()) {
    resetFields();
    populateUserTable();
    } If I click 3 to 4 times same button the 4th or 5th time the dialog opens after soem delay like 10 seconds. But in first two three click it opens quickly like in 2 to 3 seconds. Is it due to the fact that I am perfoming Swing GUI operations in doInBackgroundMethod()?
    Question 2: Should I use EventQueue.invokeLater() but as far as I have learned from the articles, the actionPerformed events already run on EDT.
    Question 3:_ Each dialog has multiple swing components like combo boxes, tables, tress which it populates after fetching data from the Database in its constructor. It takes like 1 to 2 seconds to bring data and initialize all swing components. Once the Dialog is initialized in the constructor I call my own function to set the existing user details ( As shown below ).
    I need to set all the details before I show the Dialog to the user. To achieve this what is the best practice? Where should I use SwingWorker in current scenario? in Dialog's PostInitialize()? In Dialog's Constructor()? or in the Frame's openModifierDialog()?
    public UserModifierDialog(java.awt.Frame parent, boolean modal, UserProfile userprofile)
    throws ServerException {
    super(parent, modal);
    if (userprofile != null) {
    SELECTED_USER_PROFILE = userprofile;
    }else{
    //throw new Exception("Invalid user record. User profile cannot be null. ");
    initComponents();
    postInitialize(); // my function called to set the user details on the screen
    private void postInitialize() throws ServerException {
    _userManager = new UserManager();
    initializeAllPermissions();
    initializeUserGroups();
    setFields(SELECTED_USER_PROFILE);
    private void initializeUserGroups() throws ServerException {
    _jcbUserGroup.removeAllItems();
    _jcbUserGroup.setModel(new ArrayListModel(_userManager.getAllUserGroups ()));
    _jcbUserGroup.setSelectedIndex(0);
    private void setFields(Userprofile profile) throws ServerException{
    _jlblUserID.setText(profile.getUserid().toString());
    _jtfUserName.setText(profile.getUsername());
    _jtfFirstName.setText(profile.getFirstname());
    _jtfLastName.setText(profile.getLastname());
    _jtfPassword.setText(profile.getPassword());
    _jtfConfirmPassword.setText(profile.getPassword());
    _jtaDescription.setText(profile.getDescription());
    _jcbUserGroup.setSelectedItem(_userManager.getUserGroup(profile.getUserGroupID()));
    } Question 4: I noticed that if I use following code in my openModifierDialog function to execute the worker rather then its own execute method the dialog opens quickly each time.
    Is it good idea to use the following to execute a SwingWorker or I shouldn't as I may fall in some threading issues later on which I am not aware of?
    Thread t = new Thread(worker);
    t.start();Hope to hear some useful comments / answers to my queries.
    Thanks in advance.
    Regards

    Thanks for your prompt reply and answers to my queries.
    Well, I know there are enormous faults in this code. Thats why I am seeking guru's advice to clean the mess. Let me give you breif background of the code. The current code was written by some one else using old version of SwingWorker and I am just trying to clean the mess.
    All the JDialog or Swing Components intialization code was in construct() method of previous SwingWorker. Later on when the SwingWorker became the part of Java SE 6 all application code was refactored and the GUI components initialization was moved to the new function doInBackground().
    The sample code represents the current condition of the code. All I needed was a shortcut to clean the mess or to avoid changes at so many places. But it seems that there is no easy workout for the current situation and I have to change the entire application code. I have gone through the SwingWorker API and tutorial @ [http://java.sun.com/developer/technicalArticles/javase/swingworker] and I am doing following to clean this mess.
    Well the following code is proposed refactoring of the previous code. Hope to hear your comments on it.
    private void jbtnModifyUserActionPerformed(java.awt.event.ActionEvent evt) {
    try{
    openUserModifierDialog(SELECTED_PROFILE);
    } catch (Exception ex) {
    logger.error(ex);
    //show some message here
    } finally {
    private void openUserModifierDialog(UserProfile profile) throws ServerException {
    UserModifierDialog modifier = new UserModifierDialog(_frame, true, profile);
    modifier.pack();
    modifier.setVisible(true);
    if (modifier.isModified()) {
    resetFields();
    //UserModifierDialog Constructor
    public UserModifierDialog(java.awt.Frame parent, boolean modal, UserProfile userprofile)
    throws ServerException {
    super(parent, modal);
    if (userprofile != null) {
    SELECTED_USER_PROFILE = userprofile;
    } else {
    //throw new Exception("Invalid user record. User profile cannot be null. ");
    initComponents();
    postInitialize(); // My function called to set the user details on the screen
    private void postInitialize() {
    _userManager = new UserManager();
    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
    final SwingWorker worker = new SwingWorker() {
    protected Object doInBackground() {
    try {
    return _userManager.getAllUserGroups(); //returns ArrayList of all user groups from database
    } catch (ServerException ex) {
    //Show Message here
    return null;
    protected void done() {
    try {
    if (get() != null) {
    _jcbUserGroup.setModel(new ArrayListModel((ArrayList) get()));
    _jcbUserGroup.setEditable(false);
    setFields(SELECTED_USER_PROFILE);
    else
    //show some error to user that data is empty
    } catch (InterruptedException ex) {
    //show message here
    } catch (ExecutionException ex) {
    //show message here
    } finally {
    setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
    worker.execute();
    private void setFields(Userprofile profile) throws ServerException {
    _jlblUserID.setText(profile.getUserid().toString());
    _jtfUserName.setText(profile.getUsername());
    _jtfFirstName.setText(profile.getFirstname());
    _jtfLastName.setText(profile.getLastname());
    _jtfPassword.setText(profile.getPassword());
    _jtfConfirmPassword.setText(profile.getPassword());
    _jtaDescription.setText(profile.getDescription());
    _jcbUserGroup.setSelectedItem(_userManager.getUserGroup(profile.getUserGroupID()));
    }In some places where data is way too huge I am going to use process and publish methods of SwingWorker.
    Now I have another question, how I can notify/throw any exceptions occured inside SwingWorker doInBackground method or done method to the function who executed SwingWorker. Currenlty I am catching the excpetions in the done method and showing a dialog box. But I want to throw it to the postInitialize method the method who created and executed the Worker. What is the best practice of handling exceptions in SwingWorker methods.
    Do you see any problems in proposed refactoring?
    Hope to hear your comments.
    Regards

  • Buy License Adobe Flex Builder 2

    In our company we are working on a project with Adobe Flex Builder 2, and we need to buy a license for Flex Builder 2. Our supplier reply us that Adobe sells only the latest versions (Flash Builder 4.5), but for our project we need the version 2 Adobe Flex. We have seen that Adobe Flash Builder 4.5 enables working in Flex 3 and 4 way, but not 2 which is what we need. I have not found a way to buy a license for version 2 of Adobe Flex Builder, how can we buy ??
    Thank you very much for your help

    Using multiple SDKs in Flash Builder 4
    Flash Builder lets you change the version of the SDK that you use to compile your projects. You can select the SDK when you first create a project or at any time you are working on a project.
    Using a different SDK can be useful if you are given a project that was developed using Flex Builder 2.0.1 (which uses the Flex 2.0.1 SDK), but you are running Flash Builder 4 (which uses the Flex 4 SDK by default). By selecting an older SDK to build with, you can maintain projects that have not been updated to be compatible with the latest version of the SDK. In addition, if you are currently working on a project for the Flex 2.0.1 SDK, but want to use the Flash Builder 4 features such as code refactoring, you can upgrade your edition of Flash Builder, but then select the older SDK as the default SDK

  • Recommendations for a good Java IDE...

    I've been using a few different editors. I tried NetBeans, it's not bad but seems a bit slow. I just downloaded Eclipse, I'm not sure what to think of it yet. Which is the best?

    At my job we use eclispe as company standard but at home i use Netbeans, i like it a lot, it compiles .jps, it has a good inferface to create GUI's, it has html code completions etc�
    But the best IDE is the one that you feel comfortable with and you don�t turnaround to much to find what you want.
    Eclipse has a strong point, it�s the powerful search engine also provides some very useful options for code refactoring.
    Best Regards,
    Nelson

  • ICA + Worker thread?!

    Hello everyone,
    I have a question concerning an image capture application which uses worker thread to transfer the newly captured images from the camera and in the same time to allow user input in the GUI. For the people who might be wondering what am i talking about - I use the ICA SDK to communicate with a camera that I have, my application enables the user to set all the possible camera settings via the user interface and in order for this user interface not to "freeze" during image transfer I use worker thread(second thread, the gui runs in the main application thread). Now, I implemented all this and it seems to work beautifully but I ask myself one question - What mechanism stops the simultaneous sending of transferObject request and for example setCameraSettings request? Example: The camera has the ability to shoot in the so called continuous mode so i start this mode, the camera begins shooting and transfernig images to the hard disk, in the same time I start changing the camera settings. As I said this works but I am afraid from what I do not know so, how does it work? If the approach is not right I thought about saving all the changes that the user made during transfer and send them to the camera only then when it is not busy, but why repairing something which is not borken? So, if anyone knows how the ICA handles such actions I will be glad to learn something new.
    Kind Regards
    -artOf...
    P.S. Sorry for the really long and confusing(for some) post.

    Hi etresoft,
    if I disable the ability to change settings while transfering images then the whole concept of multithreading I developed to keep the GUI alive will be useless. Well not useless but what happens on the user's monitor won't correspond to what happens in the camera(say the user is shooting images and simultaneously tries to change the shutter time - if I disable this change the GUI will show that the change has been made but this change will not actually be send to the camera), it will be like "laying to the user" and if I disable the changes to the GUI well then as I said my whole concept goes in the trash. Of course, there might be a "middle" way - not to change anything in the camera during a picture transfer(the picture transfers in continuous shooting mode come and go, there can be as much as 600 of them) this means, my application waits with sending any setCameraSettings commands until there is a window between transfers and then the command is send. It will be time expensive to implement and as I said I do not want to change something which is already working and possibly make it worst(my clients have tested the application for some time and never mentioned any problems concerning this issue) those are my arguments for delaying the code refactoring. Still, I am fully ready to do it if your oppinion guys here at the apple forum, who I really respect, is that I should do it and to just leave the application as it is, is a time bomb.
    Respect
    -artOf...

  • Swing Programming

    I am doing this Code Refactoring of a software which uses swings as its GUI. In it's programs wherevers the any window dialog is created, all the screen intialization, components creation and framing are done in the init method itself, within sections that are commented, Whether dividing those sections in seperate methods and calling them from init methods will make any difference or not, on the account of code readability and maintainability.

    This isn'r really specific to swing.
    There is a school of thought that says you should not need to document your code if it is made more readable.
    This is often done by the likes of changing ...
    into() {
    // Initialise panel A
    // here's how it's done
    // initialise panel B ...
    // here's how it's done
    to
    init() {
    initPanelA()
    initPanelB()
    * here's how it's done
    intitPanelA() {
    The methods comment themselves and any more complex comments become javadoc. I use this a lot to break things down.
    Whether you think it's worthwhile depends on how complex your code is.

  • Migrating existing POS into Oracle POS

    Hi All,
    During data migration of exisiting POS(Leading providers) into Oracle POS,Can you please anyone list the tables needs to be migrated?
    Thanks in advance,
    Krishnan.

    Oracle has a product called the Oracle Migration Workbench that would be useful in migrating the database backend. The MFC application should mostly work without significant changes-- it's mostly a matter of testing to figure out what the Access ODBC driver does differently than the Oracle ODBC driver and what impact that has on your application.
    Once the application functionality is migrated, you'll hopefully have a large chunk of schedule to optimize your code & refactor your queries to take advantage of Oracle. This is the biggest hurdle in my eyes-- there are lots of things that work really well against 1 database that perform or scale poorly on another database.
    Justin

  • Migrating Existing ODBC based Application

    I have an application that uses MFC/ODBC to connect to MS Access 97. I am looking into migrating it to an Oracle Backend.
    Whats the best way/practise for such an effort.
    What does it entail?

    Oracle has a product called the Oracle Migration Workbench that would be useful in migrating the database backend. The MFC application should mostly work without significant changes-- it's mostly a matter of testing to figure out what the Access ODBC driver does differently than the Oracle ODBC driver and what impact that has on your application.
    Once the application functionality is migrated, you'll hopefully have a large chunk of schedule to optimize your code & refactor your queries to take advantage of Oracle. This is the biggest hurdle in my eyes-- there are lots of things that work really well against 1 database that perform or scale poorly on another database.
    Justin

  • Coding best practice display name vs internal name in itemUpdated event receiver

    Hi,
    In an itemupdated event receiver, when referring to list fields, is it better to use the field's internal name, or its display name?
    Is there a clear guideline or best practice, or is this a subjective discussion?
    Thanks in advance for your replies

    Hi Jorge,
    One of the best practice I follow is Repository pattern for list access, on that scenario I always use Internal Names.
    The rational behind this decision is Fristly, I will have full control, Secondly I need not to worry about column names changes by business/endusers through SharePoint UI which I cannot control of. Though we had governance in place and trained
    the users, still no avail, users will go and change the column names. 
    Thirdly, My code will not break when there is a display name change. One of my client was too UI rather than business logic, since the enduser are high profile managers, spacing between columns and readabiltily are first class citizen.  Those changes
    that we made to the list library did not affect our code and the application was running without code refactoring.
    Backto your question, I will use Internal names in my CAML query to minimize error as follows
    item["internalName"]
    Your question is subjective, I have not seen any best practices on this subject, being said that, if you are looking for best practice and guidance I would suggest you to start here -
    SharePoint 2010 Guidance
    http://msdn.microsoft.com/en-us/library/ff770300.aspx ( no idea on SP 2013 guidance availablity)
    Go through the code and doc, You will get the design rational behind each choice.
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

Maybe you are looking for

  • Text Wrap not working

    I thought to create a text wrap you simply created a polygonal shape, selected it, and chose "Text Wrap" from the Options menu. In a new draw document, I am creating a text frame, filling it with text, creating a polygon, and with it selected choosin

  • How to put the sender name in the wf-system

    Hi, Can anybody pls tell me how to give the sender address in stead of WF-SYSTEM When ever a mail is triggered the mail is send to the mail inbox.in the mail inbox it is showing in the sender option : WF-SYSTEM... I want to put any name their . can i

  • Sales order status not changed

    Even after all line items Delivered and  Accounting document cleared, sales order's status is "Being Processed". SO is still showing open order list in VA05..There are not much changes done in SO...What could be the reason...

  • Getlist bapi for customer based on sales org, distbtn chnl

    Hi,     Is there any standard BAPI for customer Getlist , i want to filter based on distribution chanel and sales org and divison.         Now am using BAPI_CUSTOMER_GETLIST  its showing all customer list i want to filter this based on distribution c

  • "Low-level" authorizations for accessing BW reports - add users to role

    Using the advice in Topic "Low-level" authorizations for accessing BW reports, I have been able to publish a query to a role that has 3 test users and each user gets the same query but with different data, as determined in the tables. Is there a way