Code style, naming conventions

40 views
Skip to first unread message

Outnull

unread,
Apr 30, 2022, 12:20:28 PM4/30/22
to The Ring Programming Language
Hello, 

I am seeing common variable naming patterns but can't find a style guide. Can someone please provide best practices?

Some examples:

oView = Assuming o stands for object?

$url = Not sure what $ means

cStr = Assuming c stands for character? Is this for all string variables?

nFields = Assuming n stands for number? Used for all ints?

aResultRow = Assuming a stands for array even though Ring calls them lists?


And some function names in the Softanza library that use an uppercase Q: and a variable name that begins with @. Are these specific to this library or universal?

StzBinaryNumberQ, StzStringQ = Not sure what Q means

@cBinaryNumber = Not sure what @ means when used in a variable name

Are there any others? For example, constants? In other languages constants may be defined as CONSTANT = "VALUE".


Thank you

Mounir IDRASSI

unread,
Apr 30, 2022, 1:12:33 PM4/30/22
to The Ring Programming Language
Hi,

My understanding of variables naming convention in Ring is close to yours:
  • o prefix for objects
  • $ prefix for global variables
  • c prefix for strings
  • n prefix for numbers (integer or double)
  • a prefix for lists
Mahmoud is the authority for Ring so let's wait for his feedback.

Mahmoud Fayed

unread,
Apr 30, 2022, 2:14:59 PM4/30/22
to The Ring Programming Language
Hello Mounir

>> "Mahmoud is the authority for Ring so let's wait for his feedback"

I agree with you :D
In practice I am using o, c, n & a in the start of the variable name like (oObject, cString, nNumber, aList)
For constants I use C_ in the start of the name and write the constant using UPPER CASE like C_BUTTONWIDTH = 200

Using $ before global variable and @ before object attribute is possible and is similar to Ruby
I don't use global variables in large projects as much as I can
Also, Ring have (load package) command which load libraries in separate global scope, This avoid conflicts in global variable names
So, Sometimes I use $ before the global variable name, but in most cases I don't do that.

Ring as a language encourage freedom (Any Style + Any Programming Paradigm + Any platform)
So, what is more important is selecting a specific style for the project. A style that is suitable for the developers who are developing this project

Greetings,
Mahmoud

Mansour Ayouni

unread,
Apr 30, 2022, 8:02:40 PM4/30/22
to Mahmoud Fayed, The Ring Programming Language
Hello Outnull,

Softanza embraces the same naming conventions of Ring (c for strings, n for numbers, a for lists, and o for objects), and adds some specific ones...

Hence, @ is used for object attributes, and Q is used as a prefix to any function, taking the name of a Softanza object, to return that object for further processing.

So, for example, instead of writing:

o1 = new stzString("softanza")
o1.Uppercase()
o1.Spacifiy()
? o1.Content()
#--> "S O F T A N Z A"

We can just say it in one line like this:
? StzStringQ("softanza").UppercaseQ().SpacifyQ().Content() 
#--> "S O F T A N Z A"

As you can see, the Q puts the object in a "Queue" for fluently acting on the object while interrupting our train of thoughts.

Best,
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/6f896dd9-aafc-4c1f-9919-5568ed896f39n%40googlegroups.com.

Outnull

unread,
May 1, 2022, 12:36:27 PM5/1/22
to The Ring Programming Language
Hello Mounir, Mahmoud, and Mansour 

You were just the 3 I was hoping to hear from on this question. Thank you for the explanations! :)

Mansour, the more I learn about your Softanza library the more intrigued I become. Appreciate that clear example of how Q is used.

Regards.

Mansour Ayouni

unread,
May 1, 2022, 5:56:00 PM5/1/22
to Outnull, The Ring Programming Language
Hello Outnull,
You are welcome!
Best,
Mansour

Reply all
Reply to author
Forward
0 new messages