Page 2 of 7 FirstFirst 12345 ... LastLast
Results 11 to 20 of 65
  1. #11

    Default Re: goto statement - any comment


    sa vb akong pasabot ang error bai.. mora wala mai try og catch sa vb6..
    and yah kabaw ko anang try catch statements bai..
    anyway, i dont use goto statements on C++ and java... i only use it on vb,asembly,.. kai mao mai gi tudlo sa maistro..

  2. #12

    Default Re: goto statement - any comment

    u said *mora* og VB...keyword is *mora*

  3. #13

    Default Re: goto statement - any comment

    "on error goto ERRORHANDLER:" i bet familiar ni nimo kani nga syntax.. mora wala mani sa c++ or sa java.. so.. i was impliying directly to VB.. although i wasnt sure kong ma apply ba sa c++ or sa java ang "on error" nga keyword since ni butang man ko og keyword nga *mora* but ofcourse i know nga naai alternative / substitute.. nga statement/s.. ang keyword nga "on error" which is try, catch, if() og uban pa.. nga statements.. to cut my point short.. you can use goto statements on errorhandling with the mix of other helpful functions ofcourse ... kong dili vb imong gi gamit.., program control, og oban pa..

    ex:

    if(failed(x)) {
    goto nextProcess
    }

    //some codes...
    //....
    nextProcess:
    //.. execute codes.. etc..

    which is equivalent to VB like:

    on error goto nextProcess
    'codes...
    '....
    nextProcess:
    'execute some codes..

  4. #14

    Default Re: goto statement - any comment

    Ang ako lang masulti di ko mogamit ug goto kay wala ko maanad.

    Nya sige mo lalis gamay ra ning butanga.. Kamo ray gibuang ni professor djikstra, nya tuo sad mo dayon.

    I barely have more than 50 lines of code in a method, how could goto make my code spaghetti. If you have long method, then there's a problem of your design so it's time to refactor it.

    Focus on very good interface, exception, assertion, and validation for every method.

    Btw, based on my skill of coding stylell, I am assigned as code reviewer in our company and I optimize them too.
    Mora ni ug comics akong code nga ang mobasa kasabot na so dili na kinahang butangan ug comment.

    So what does that mean to you? It means nga ayaw na'g lalis kay kapoy na.



  5. #15

    Default Re: goto statement - any comment

    Here is a goto statement from one of the open source application for Linux. I find it buggy and was able to fix it since it can easily be trace.

    if (!(spans[i - clip_ymin])) spans[i - clip_ymin] = s;
    else
    {
    Span *ps, *ss;

    ps = NULL;
    for (ss = spans[i - clip_ymin];
    ss;
    ss = ss->next)
    {
    if (s->x <= ss->x)
    {
    if (!ps) spans[i - clip_ymin] = s;
    else ps->next = s;
    s->next = ss;
    goto nospans;
    }
    ps = ss;
    }
    /* last span on line and still not < ss->x */
    if (ps) ps->next = s;
    nospans:
    }
    }
    if (i == y2) goto nolines;
    i += step;
    }
    nolines:
    }

    The above code uses goto.....
    Take a look on where it falls to be an erroneous..... This program doesn't compile.....
    Don't mind the brackets... just the gotos..
    This is the clue on why gotos are not good to apply on high level languages like C/C++...

  6. #16

    Default Re: goto statement - any comment

    xyberblue,

    very good example. it's ridiculous oi. you should fire the programmer.

  7. #17

    Default Re: goto statement - any comment

    hehehehe... mo lang... Im having hard time to debug that sucky goto codes. But only one character is only lacking in order to solve that program....

    if (!(spans[i - clip_ymin])) spans[i - clip_ymin] = s;
    else
    {
    Span *ps, *ss;

    ps = NULL;
    for (ss = spans[i - clip_ymin];
    ss;
    ss = ss->next)
    {
    if (s->x <= ss->x)
    {
    if (!ps) spans[i - clip_ymin] = s;
    else ps->next = s;
    s->next = ss;
    goto nospans;
    }
    ps = ss;
    }
    /* last span on line and still not < ss->x */
    if (ps) ps->next = s;
    nospans: --> this is the erroneous part that sometimes made confusing to people that sucks gotos...
    }
    }
    if (i == y2) goto nolines;
    i += step;
    }
    nolines: --> this is the erroneous part that sometimes made confusing to people that sucks gotos...
    }

    Those lines made the code error and cause the compiler to stop....

  8. #18

    Default Re: goto statement - any comment

    do not use it if possible.

    if all else fails, proceed with the goto statement.
    I end up with a loop statement code which i cant use 'break' or 'continue' i end up using 'goto' statement because i have no other choice.
    Next morning, i rewrote the whole function just to remove the goto statement.
    'goto' statement are popular choice for lazy programmers who wants an easy "Exit and forget".
    dont use it only if you dont have a choice. if you end up in always "no choice" situation,
    study programming again. design patterns and programming practices.


    Spaghetti code is a pejorative term for source code which has a complex and tangled control structure, especially one using many GOTOs, exceptions, threads, or other "unstructured" branching constructs.

    It is named such because program flow tends to look like a bowl of spaghetti, i.e. twisted and tangled. Also called kangaroo code because such code has so many jumps in it.

    [br]Date Posted: November 23, 2005, 02:25:27 PM_________________________________________________i f you cant exit use goto statement.

    in vb, there was no other choice for catching an error, goto was there to save vb6.
    in assembly, it is the easiest to use and very powerful to jump any line of assembly code.
    in c++ or java or c#, you can break or continute or exit from loop, you can use subfunction or procedures, goto is too powerful since it can go to any line of code and could easily break your application. its too much of a risk. not to mention, sphagetti code problem.

    goto uses?
    you can simulate a For loop, an IF Else , a DO While, WHILE, Break, Continue, Exit, TryCatch statements,
    you can also simulate functions or procedures.

    my first reason to use if i want to exit a function/loop/code immediately (if only i have no other choice)

  9. #19

    Default Re: goto statement - any comment

    you can always end the loop(for) statement by changing the variable.. x=num...

    goto... hmmmm, i dont really use it... ambot lang kay murag dili kasaligan..

    jiro, mulang gamit sad ang goto sa vb6, para dericho na..

  10. #20

    Default Re: goto statement - any comment

    its been a while nga wa ko kagamit ug goto statement but as far as i can remember we use it to only to for error handling and then force exit ang program
    ALONE:Hated and Punished

  11.    Advertisement

Page 2 of 7 FirstFirst 12345 ... LastLast

Similar Threads

 
  1. Any comments on Lami-Ah??
    By darkwing in forum Food & Dining
    Replies: 10
    Last Post: 02-21-2009, 06:37 AM
  2. Replies: 4
    Last Post: 10-05-2007, 10:12 PM
  3. any comment sa Palit gf8500gt sonic and gt8600gt sonic
    By baijo in forum Computer Hardware
    Replies: 28
    Last Post: 06-01-2007, 11:12 PM
  4. Comparing 3 Switches, Any Comments...
    By Chipmunk888 in forum Networking & Internet
    Replies: 21
    Last Post: 10-27-2006, 07:45 AM
  5. Brighton monitor? Any comment on this?
    By erik garcia in forum Computer Hardware
    Replies: 2
    Last Post: 12-03-2005, 10:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top