Procedure names, Library vs Include

Everything else that doesn't fall into one of the other PB categories.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Procedure names, Library vs Include

Post by SFSxOI »

Just a few questions;

1. Is there a standard naming convention for function/procedure names regarding the length of the name?

Code: Select all

Procedure This Is JustaLongExampleNameForaProcedureThatMightBeTooLong()

or...

Procedure ThisIsAnExampleName()
I like the shorter names, but I also want my procedure names to be sort of descriptive of the procedures purpose..e.g...

Code: Select all


Procedure ThisWillTurnOnTheWindow() ; tells exactly what this is for
or...
Procedure TurnOnWindow() ; gives an idea what this is for

and not just...

Procedure Window() ;does this tell us if it turns it on or not?
so if its just what ever you want to call it thats OK too, but when is long too long? Whats the general standard, if any?

2. It seems a library is basically an include file of sorts (not exactly but you could think of it that way). So...does it matter if a library is used instead of an Include file? The library has advantages in the sense that its available to you at all times where as an include seems to be mostly for a particular purpose, but you can put the include in with anything your developing. Is one faster then the other?
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

You can call your procedures what you like, it's you who has to type them in. :lol:

Edit: As long as they aren't the same name as a keyword, obviously!
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Procedure TurnOnWindow() ; gives an idea what this is for
I think names like this is what most of us use.

About librarys, I don't like using them, actually I have never used one. Because I like to have full control over every line of code in my app and if you're using a library it's difficult to share your code with others that doesn't use that library and such.
And about the speed, well some librarys can be written in optimized assembly, c++ or whatever and might be a little faster than what you could write with PB code in a include file.
I like logic, hence I dislike humans but love computers.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

If you are making a public include/library please put a prefix like mylib_DoThis() :)

I also do that with large projects. If i have a license system, the have a lic_ prefix so i remember them. Like lic_generatelicense
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Of somewhat more concern is variable names. Particularly in cases where global vars are used, if they appear in an include file they are global to your program and any other pbi's you've included. You can inherit some lovely huge bugs this way. So when writing code for this use it's important to prefix all names with something indicating that it belongs to this pbi, for example all vars start with 'nx_' or such. In the case where you compile the code with TailBite, this is not the case as all variables global to the compiled library have a scope that is confined to that library and they don't intrude upon your main program code.
BERESHEIT
Post Reply