User Libraries naming convention

Everything else that doesn't fall into one of the other PB categories.
Rinzwind
Enthusiast
Enthusiast
Posts: 690
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

User Libraries naming convention

Post by Rinzwind »

I like PureBasic and bought it. Works perfectly for small fast apps. I do understand OOP, but I like the procedural approach which works well for what I use PureBasic for.

I'm using the Droopy Lib (thanks for creating it!). However, I find it strange that there is no naming convention for libs. I did read the following in the manual: "If you find a function name similar to one in another lib, please contact me, I'll change the function name.". Why not use a simple prefix for ALL procedures in a user lib? this makes perfect sense to me.

Ex. DROGetComputerName()

What does PureBasic do when there are to simular named procedures in different libraries?

Also, where is the best practices guide on programming, code formatting, commenting and helpfile?

Just some ideas.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

there is no "best practice". every programmer has his likes or dislikes.

and a "UserLib" ist just a Library you can create on your own.
It doesn't matter if you want to publish it, ort if you just create it for internal use inside your project.

what would you tell someone who tries to tell you you'll have to name your procedures a different way or you must comment you code using "#" istead of "*"?


sure, if you want to create a UserLib you want to offer to the community,
it's best to name all functions with some unique prefixes...

but what if one didn't? throw cakes at him?
oh... and have a nice day.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

is the cake chocolate? :)

I'll mis-name stuff all day long for chocolate cake. :)
Rinzwind
Enthusiast
Enthusiast
Posts: 690
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Post by Rinzwind »

You DO get the point Kaero.

Regarding code formatting, it's good to have some basic rules which you can follow. Luckily PureBasic itself has decent procedure descriptions and examples which hopefully stimulates others if necessary.

It's nice if procedures follow some kind of logic regarding naming, use, arguments, return value processing.

That's all.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

> It's nice if procedures follow some kind of logic regarding naming, use, arguments, return value processing.

sure, I agree to that...

but who should proclaim this rules, and who should watch over them?

the lib-creating app, like tailbite?
I would kick some precompiler that alters the name of my procedures...

you can only do that yourself.
if you happen to find a lib with naming conventions you don't like or simply without naming conventions, don't use it.
oh... and have a nice day.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I agree that a prefix is a good idea, like gnozal does for his libs.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

PB wrote:I agree that a prefix is a good idea, like gnozal does for his libs.
+1

cheers
White Eagle
Enthusiast
Enthusiast
Posts: 215
Joined: Sun Jan 04, 2004 3:38 am
Location: Maryland

Post by White Eagle »

I have suggested this for years for lib names and lib functions/commands. However I gave up when people were flaming me for wanting to release libs instead of the source code.
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Re: User Libraries naming convention

Post by lexvictory »

Rinzwind wrote:Ex. DROGetComputerName()

What does PureBasic do when there are to simular named procedures in different libraries?
That particular example is like that because the function is a wrapper to the WinAPI command, why prefix that?

Similar named commands? it doesn't care.
Exactly the same name? the compiler won't start.
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

Another reason for using prefixed names, aside from preventing clashes
with other libs, is that when newbies post a question, the regulars here
know what's going on and can help instantly. Consider:

Without prefixed names:

Newbie question: "The lib I'm using isn't compressing my files."
Typical answer: "Which lib is that? We need more info to help."

With prefixed names:

Newbie question: "PureZIP isn't compressing my files."
Typical answer: "Try this code and report back: [snip]"

So that's two good reasons to use prefixed names, IMO.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

n00bs will always ask poorly verbalized questions.
they should be send to some "how to ask"-bootcamp, that's all.


@topic

even with includes it's a good idea to prefix groups of functions.

but how to force it?
should the compiler refuse to compile functions without prefixes?
omg!
oh... and have a nice day.
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

imo it would be stupid to prefix all Droopy commands, as there are subsections of it that do completely different things
plus the ones that do do the same thing generally ARE prefixed (just not with droopy_) - and most n00bs mention droopy in my experience

but I do agree to a certain extent that they should be prefixed in cases like PureZIP or some kind of HTTP lib, etc.
it makes narrowing of the autocomplete slightly better i think.

and i would dread adding prefixes to all lib commands in tailbite... it was hard enough doing it for the multilib option...
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Post Reply