[Gambas-user] Better use of prefixes

Jussi Lahtinen jussi.lahtinen at gmail.com
Sun Mar 17 01:53:28 CET 2019


So, basically you are against prefixes, and instead you want suffixes. Also
you do not like the current abbreviations.
To me that sounds like too much work for nothing.


Jussi

On Sun, Mar 17, 2019 at 12:28 AM Cedron Dawg <cedron at exede.net> wrote:

> I think it was representative of a lot of the issues.  Put up a piece of
> code in your preferred style, and I'll make it Dawggy Style, and we can
> compare.  Not too long though, please.
>
> In this case there is clearly only one scrollbar, as the reference is
> inside a class definition that is not part of a form.
>
> Had there been more than one, a good name would be
>
> myCatapaultScrollBar or myCatapaultSB
>
> See, I'm not totally abbreviation averse.  I often name references to
> objects with an uppercase abbreviation for the Class name.  But I don't
> need a secret decoder ring to figure it out, just find the declartion and
> it becomes obvious.
>
>   Private myCatapaultSB As ScrollBar
>
> As the programmer, that is different than having to know "scb" in
> advance.  As a maintainer
>
>   Private $scbMain As ScrollBar
>
> would tell me what "scb" meant.
>
> Also, in the same Class, I have:
>
>   Private myW As Float ' Equilibrium Width
>
>   Private myPr As Float ' Position of Recoil Factor
>
>   Private myCoconut As CoconutClass
>
> So, if I do use an abbreviation, I try to always provide a comment right
> next to the definition saying what it stands for.
>
> Ever see a scroll bar hurl a button?  I've attached the code.
>
> As for the $ on object references, the naming convention link states "All
> private variable names of a class start with $".  I interpret an object
> reference as a variable.  If you leave the $ off, it does indeed make the
> code look less "geekish", but not by much.
>
> Previous renditions of BASIC have had type declaration characters.  Those
> were type suffixes enforced by the compiler and I used them heavily as I
> don't like having to dim all my variables.  First thing I would do in VB is
> shut off "Option Explicit".  Not many people used them, and Gambas doesn't
> support them, so that is a moot issue.  Though a few function names, like
> ChrS(), are vestigial leftovers.
>
>
>
> ----- Original Message -----
> From: "Jussi Lahtinen" <jussi.lahtinen at gmail.com>
> To: "user" <user at lists.gambas-basic.org>
> Sent: Saturday, March 16, 2019 6:02:14 PM
> Subject: Re: [Gambas-user] Better use of prefixes
>
> I don't think your code example is representative of the whole issue. What
> if there are multiple containers, buttons, etc? What if there are long /
> complex lines?
> Even in your chosen example "myScrollBar" says nothing about its function
> or identity, only that it is scrollbar. But "scbMain" hints right away how
> the scrollbar is used (not much but still).
> More descriptive the variable name is, longer it becomes and it really
> adds up in already long lines. So, I chose not to waste space for the type
> information, when it can easily be shortened.
>
> I don't think $ is used in names of controls. They shouldn't be public
> anyway.
>
>
> Jussi
>
>
> ----[ 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/20190317/e28c4e66/attachment.html>


More information about the User mailing list