[Gambas-user] usage of too much GOTO can be bad pracitce or make influence in the code?

Fernando Cabral fernandojosecabral at ...626...
Thu Jun 22 19:53:06 CEST 2017


On Thu, 22 Jun 2017, PICCORO McKAY Lenz wrote:

> > i only use to avoid a similar to this:
> >
> > if isnull(value ) then
> >    ' amount of 4000 lines of code
> > else
> >    ' amount of other lot of lines
> > endif
> > if not isnull()
> >   goto codepiecelabel1
> > endif
> >   ' amount of lines
>
> I don't want to be blunt, but I am forced to say that:

a) GOTO is always avoidable (even in COBOL)
b) The need for GOTO usally comes from poor coding (and perhaps poor
languages)
c)  For me, the above example is one of the worst situations to use GOTO.
It makes reading
    and understanding the code very, very hard.

My experience is that when you get to a point where GOTO seems to be the
best solution (sometimes, only solution) then probabibly you have thought
not enough about what you are coding -- or coded well enough.

Finally, if you set the GOTO to break a loop, or to jump to a nearby place,
you might be able to survive.
But if you use it to to jump over 4000 lines of code, that should sound a
LOUD, VERY LOUD alarm. Something is probabily very wrong. I simply can not
think about a situation where you have a single block of 4.000 lines of
code. It should have been broken down into a few tens or pehaps hundreds
functions.

It means, even thou I don't know your code, I would guess it has not been
well thought out..

Regards

- fernando

be put into a meaningful class. An object of this class contains all
> your relevant variables and you can pass a reference of that object
> (as a container for the variables) to a function.
>
> If there's no sensible grouping of variables into classes but you
> don't have dozens of variables, then you could try ByRef [1].
>
> Regards,
> Tobi
>
> [1] http://gambaswiki.org/wiki/doc/byref
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: fernandojosecabral at ...626...
Facebook: f at ...3654...
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.



More information about the User mailing list