[Gambas-user] variable declaration everywhere ???
Jussi Lahtinen
jussi.lahtinen at gmail.com
Fri Dec 14 14:43:15 CET 2018
I'm quite skeptical about designing language so that it support only good
code. In my opinion inclusions / exclusions of features in the language
should be based solely on their usefulness,
regardless of their role in bad code. Otherwise you end up crippling the
language. Just think about it, no goto, restrictions on method length,
forced indention / whitespace part of syntax, etc.
All very bad decisions, and do they work? No! Just show me one language,
which do not have bad code!
Language is like any tool, more versatile the better, and the product made
with it comes from the skills of the craftsman.
Jussi
On Fri, Dec 14, 2018 at 10:57 AM Christof Thalhofer <chrisml at deganius.de>
wrote:
> Am 14.12.18 um 00:51 schrieb Benoît Minisini:
>
> > Or should I remove the possibility of declaring variables anywhere
> before?
>
> I would remove that.
>
> Option explicit and the decision to allow the declaration of variables
> only at top in my eyes are the main advantages of Gambas vs VB(A)
> concerning cleaner code.
>
> Basic seems to be an easy language for beginners, but – as always –
> allows a lot of very ugly code constructions.
>
> Because at the end code is always procedural, it can be distributed
> either over one long method or several different methods. The latter is
> usually much better, because small functions can be understood and
> debugged more easily. Also functions can be held stateless and so much
> more secure.
>
> Long method bodies for me are a clear sign for bad code.
>
> As I started programming long ago I did not understand the advantages of
> declaration of variables, and later – as I understood – I declared a lot
> of variables within the body of my methods. As I had to refactor that
> code mess later I found out that I packed a lot of functionality in
> loooong methods which were quite hard to understand.
>
> As I switched over to Gambas all these things did not work any more as
> the Gambas compiler complained about declarations within the body of
> these long methods. I had to refactor (bring all the variables to top)
> and found out that I did a lot of senseless things with variables:
>
> Often I packed content of one variable in a new one just because the
> name of the first variable did not fit into the current environment
> (scope) inside a long method. I did this, because I could declare the
> new variable within the body.
>
> I also tended to pack a lot of different functionality in one long
> method and I also had many headlines in my comments, each of which
> referred to a new section of the body that contained new functionality
> and new variables.
>
> Long Methods with a lot of functionality inside are bad. Really bad! You
> will find this out if you want to understand what you have written two
> weeks later. Or a year later.
>
> If variable declaration inside the body would be needed it is much
> better to think about it a while and then export the functionality to
> another method.
>
> If the declaration is at the top, at first it may be a bit inconvenient,
> but it will always remind you that it is much better to outsource
> functionality. And you will, simply because it will be more convenient.
>
> So this decision of Gambas leads to better code!
>
> I've put a lot of work into a lot of code and the older I get the
> smaller and clearer my methods become. I'm against making it easier for
> programmers to create huge functions full of spaghetti.
>
>
> Alles Gute
>
> Christof Thalhofer
>
> --
> Dies ist keine Signatur
>
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20181214/8a66b189/attachment-0001.html>
More information about the User
mailing list