Page 1 of 1
User Libraries naming convention
Posted: Sat Mar 14, 2009 5:54 pm
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.
Posted: Sat Mar 14, 2009 6:24 pm
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?
Posted: Sat Mar 14, 2009 9:08 pm
by SFSxOI
is the cake chocolate?
I'll mis-name stuff all day long for chocolate cake.

Posted: Sat Mar 14, 2009 9:27 pm
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.
Posted: Sat Mar 14, 2009 9:47 pm
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.
Posted: Sun Mar 15, 2009 2:12 am
by PB
I agree that a prefix is a good idea, like gnozal does for his libs.
Posted: Sun Mar 15, 2009 2:48 am
by rsts
PB wrote:I agree that a prefix is a good idea, like gnozal does for his libs.
+1
cheers
Posted: Mon Mar 16, 2009 8:45 pm
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.
Re: User Libraries naming convention
Posted: Sat Mar 21, 2009 8:53 am
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.
Posted: Sat Mar 21, 2009 1:00 pm
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.
Posted: Sat Mar 21, 2009 1:08 pm
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!
Posted: Sat Mar 21, 2009 1:16 pm
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...