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

Tobias Boege taboege at ...626...
Thu Jun 22 16:23:58 CEST 2017


On Thu, 22 Jun 2017, PICCORO McKAY Lenz wrote:
> 2017-06-22 10:00 GMT-04:00 Jussi Lahtinen <jussi.lahtinen at ...626...>:
> 
> > Usually the problem with goto is that it can render the code hard to debug
> > or read.
> >
> AH OK, so in large complex dependences must be avoid..
> 
> 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
> 
> so i put
> 
> if not isnull()
>   goto codepiecelabel1
> endif
>   ' amount of lines
> 
> codepiecelabel1:
> ' here the 4000 lines
> 
> 
> i cannot use a sub procedures due manage some variables
> 

This is excessive. Maybe you can think about if your variables can
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




More information about the User mailing list