Page 1 of 2 12>
Topic Options
#94319 - 2002-10-13 11:32 PM RFC - Hungarian Notation for KiXtart & KiXforms
rclarke Offline
Starting to like KiXtart
*****

Registered: 2001-06-08
Posts: 178
Loc: Oxfordshire, United Kingdom.
KiXtart scripts are increasing in complexity, particularly with the advent of floating point support and extensions such as KiXforms and KiXGUI. Naming conventions such as Hungarian Notation can improve the legibility of code, therefore I would like to propose the definition of a variable naming convention for KiXtart and its associated plug-ins. Obviously, adoption of the convention is purely a matter of personal preference, however it would be beneficial to have a recognised and agreed upon standard that can be referred to by KiXtart programmers.

I have compiled an initial Table of variable prefixes at the KiXforms web site and would like to solicit your feedback and general opinion. This first pass has been compiled from a variety of sources including, the original document by Dr. Charles Simonyi, standards defined by Microsoft Consulting Services, and several papers on Visual Studio best practices. I appreciate that some programmers do not like using Hungarian Notation, however for those of us that do, I would prefer if this topic concentrated on the definition of a standard, rather than on the pros and cons of its use.

Many thanks in advance,

Rod.

Top
#94320 - 2002-10-13 11:44 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uh...
it will definitely make the coding harder.
and my codes will increase at minimum to triple the size.
also, with this, big part of the freedom of kix's syntax is lost.

me like the idea, but mostlikely am too lazy to use the conventions...

 

[ 13. October 2002, 23:45: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#94321 - 2002-10-14 12:10 AM Re: RFC - Hungarian Notation for KiXtart & KiXforms
rclarke Offline
Starting to like KiXtart
*****

Registered: 2001-06-08
Posts: 178
Loc: Oxfordshire, United Kingdom.
Hi Lonk,

Thank you for the feedback, however as I stated in the last sentence of my first post, I want to concentrate on defining a standard for those who want to use Hungarian Notation. Furthermore, most data type prefixes only increase the variable name by one character, and it is still only three characters for object types. As for 'losing the freedom of KiX's syntax', I disagree, HN is all about making code more legible and if that helps new starters with learning KiX by studying other programmer's code, then I'm all for that.

Rod.

[ 14. October 2002, 00:10: Message edited by: rclarke ]

Top
#94322 - 2002-10-14 12:12 AM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeh, like I said, I like the idea.
but it's unlikely that I'm going to learn to use other vars than $ and $c and $f

maybe someday, but haven't seen that day yet.

{edit}
what comes to the freedom, all I ment was that defining the type before hand, does not allow same variable used for multiple tasks.
which, kixtart itself allows and which is one of it's greatest plus'es.

[ 14. October 2002, 00:14: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#94323 - 2002-10-14 05:54 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Rod,
Could we include UDF naming conventions as well? There was some discussion of UDF naming a while back and it made good sense.

BTW, discussions of the merits of HN have been taken to another thread in respect for Rod's wishes.

Topic: RFC - Hungarian Notation for KiXtart & KiXforms - Discussion
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#94324 - 2002-10-14 06:44 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
rclarke Offline
Starting to like KiXtart
*****

Registered: 2001-06-08
Posts: 178
Loc: Oxfordshire, United Kingdom.
Certainly, I assume you are referring to this post for the actual naming of the UDF rather than just adding the fn prefix, in which case it is a good idea and will be added to the web page.

So what does everyone think of the prefixes proposed so far? Are there any missing? Are there any that just don't work? Let's hear about it.

Rod.

[ 14. October 2002, 18:45: Message edited by: rclarke ]

Top
#94325 - 2002-10-14 07:05 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Rod,

fn is already shown as a Float (32-bit floating point)

Part of what I think needs to be done is to have a more decisive understanding of what is what.

I often use $x or $nul simply for blanking the numbers from KiXtart to the screen. Is that a function, action, or what? How should it be used then. As a function $fNul or $fx ???

p.s. Sorry for the hijacking of your post... but it was the only way I knew to try and keep this one here cleaner. I think it is too difficult to leave most topics without another venue to air ones thoughts, so I created another so as to hopefully keep this one on topic as you requested. [Wink]

Top
#94326 - 2002-10-14 08:38 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
rclarke Offline
Starting to like KiXtart
*****

Registered: 2001-06-08
Posts: 178
Loc: Oxfordshire, United Kingdom.
Hi Ron,

In actual fact f is Floating Point and fn is Function. As for the handling of dummy variables, the prefix should reflect the data type returned, so $sDummy is a dummy string, $lDummy is a dummy long integer etc. As for the creation of a second topic, no worries, I think all is back on track now [Wink]

Rod.

Top
#94327 - 2002-10-18 12:06 AM Re: RFC - Hungarian Notation for KiXtart & KiXforms
rclarke Offline
Starting to like KiXtart
*****

Registered: 2001-06-08
Posts: 178
Loc: Oxfordshire, United Kingdom.
Ok, to cut to the chase, does anyone have any issue with defining the following as standard KiXtart Hungarian Notation:

b is Boolean (not a 'real' KiXtart data type)
c is Char (also not a 'real' KiXtart data type)
f is Float
fn is User Definable Function
l is Integer (Long)
s is String

... plus we then have two other prefixes which are used with the data types above, namely:

a is Array
g is Global (as in variable scope)

The following are up for further discussion:

e is for Error
i is for Index (as in Array)
v is for Variant (as in undetermined data type)

So, please tell me what you think, I'm sure you will [Wink]

Rod.

Top
#94328 - 2002-10-17 01:05 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
eh, as there is no way to limit variable length, I think the c is not needed.
it will still reserve memory of character array even there is only one char.

boolean then, it indeed is supported by kixtart even though creation of boolean false/true is little tricky.
_________________________
!

download KiXnet

Top
#94329 - 2002-10-17 01:52 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
rclarke Offline
Starting to like KiXtart
*****

Registered: 2001-06-08
Posts: 178
Loc: Oxfordshire, United Kingdom.
Hi Jooel,

I sort of agree that we should drop the 'c' prefix for Char. Anybody else have any thoughts on this one?

Rod.

Top
#94330 - 2002-10-17 02:44 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
quote:
I sort of agree that we should drop the 'c' prefix for Char. Anybody else have any thoughts on this one?
I'd be inclined to leave it in.

I use it as a mnemonic for a variable that will hold a single character. Typically these are variables which are assigned a value by things like "Get" or "Chr()".

As the prefixes are simply to provide documentation or programming hints, using "c" to indicate a variable which must only have a single character assigned to it is still valid.

Of course it would still be valid to use "s" for a variable length string, even if that length were always one character.

The difference is that the "c" prefix implies that the variable must never exceed a single character, and in the event that it does only the first character is ever considered - extra information may be lost. As such it still has a purpose.

Top
#94331 - 2002-10-17 02:49 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
rclarke Offline
Starting to like KiXtart
*****

Registered: 2001-06-08
Posts: 178
Loc: Oxfordshire, United Kingdom.
Good argument Richard, and on that basis we shall keep 'c' in for Char. Thank you for your input.

Rod.

Top
#94332 - 2002-10-17 03:29 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
We should also standardize on precedence, e.g. a/g must come before the variable type b/f/l/s.
_________________________
There are two types of vessels, submarines and targets.

Top
#94333 - 2002-10-17 03:35 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ok - just so I get this straight - a global long counter would be:

glCount

yeah ?

One of the ones I use quite a bit in C and is used alot in some circles, is a logical extention of the l notation called n. n stands for number or maybe more specifically count as in "this variable contains a number representing a count" (as opposed to a number representing something else) fe.

nItems
nEmployees

[ 17. October 2002, 15:38: Message edited by: Shawn ]

Top
#94334 - 2002-10-17 03:43 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes, as in 'array of integers' = ai and 'global string' = gs.

Can there be a boolean string in your code? [Big Grin]

[ 17. October 2002, 15:44: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#94335 - 2002-10-17 03:52 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
boolean string?
can't think of one.
boolean array though...
_________________________
!

download KiXnet

Top
#94336 - 2002-10-17 04:13 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Figure you could go crazy with this and say

gai global array of integers
gal global array of longs
gaf global array of floats

but if memory serves (and this should be decided upon) don't recall ever seeing much of this extended notation ... mostly just see this (please correct me if im worng):

ga global array of things

not sure how to reconcile this one. It would seem to me the notation gal would provide all the needed information,

Top
#94337 - 2002-10-17 04:23 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
wouldn't your ga be gav?
_________________________
!

download KiXnet

Top
#94338 - 2002-10-17 05:29 PM Re: RFC - Hungarian Notation for KiXtart & KiXforms
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Lonkero: The boolean string was more play-of-words with regards to the equivalent HN for a boolean string [Wink]

Is there a gaga ?

[ 17. October 2002, 17:29: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 2 12>


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 802 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

Generated in 0.036 seconds in which 0.011 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org