[Gambas-user] variable declaration everywhere ???
chrisml at deganius.de
Fri Dec 14 14:35:15 CET 2018
Am 14.12.18 um 11:49 schrieb Rolf-Werner Eilert:
>> Basic seems to be an easy language for beginners, but – as always –
>> allows a lot of very ugly code constructions.
> That's true - but it's in the programmer's hands.
Not really – if the programmer is a beginner.
As I was a beginner I wrote a lot of
i = 2
name = "Rolf"
' anywhere and then ...
'... lots of code later
firstname = name
Afterwards I had a lot of work with that. Ok, I also had a lot of work
with other silly stuff I wrote. But exactly here Gambas helped me a lot
showing me bad habits of me as a (young) programmer.
>> So this decision of Gambas leads to better code!
> this CAN have the effect you mention, but it doesn't need to. You still
> can produce ugly code, even in Gambas, even without the possibility to
> create a variable on the spot.
For sure there are a lot of other possibilities to create ugly code. But
is that really a good argument for creating extra ones?
> If you confine the use of declaring a variable to certain cases, like
> loops, it's ok. I wouldn't use it, but others might like it. They will
> find out for themselves that their code becomes unmanageable if they use
> this too frequently, but it can also become unmanageable through other
> (bad) habits. A bad programmer will produce bad code, you cannot keep
> him doing from it just by forbidding some kind of variable declaration.
For example loops ... now: If I see in the declaration of foreign code:
Dim i, j, k as Integer
This is a warning for me, that the programmer could have done something
nasty. Either too much functionality in the code or too deep iteration.
It doesn't have to be, but it could be ...
But if these declarations are not immediately visible to me but I would
have to think about that these informations could be "hidden" in the
code I'd find that a pity.
[x] nail here for new monitor
More information about the User