Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-07

How choose units names?

10 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas

How choose units names?

I was thinking what are the best names to my units to not to conflict with the units of the FPC, Lazarus, and others frameworks or libs. e.g. fpc\2.5.1\packages\fcl-web\src\base\webutil.pp

There are a great chance this unit name exists in some libs or frameworks, on the web.
Even I would take this name, isn't?

On the sources of FPC, exists a lot of units with a bit name... e.g. fpc\2.5.1\packages\ggi\src\*.pp (ggi.pp | gii.pp | ggi2d.pp)

All these names could be a name of variable...

How you have no conflict with names of the units? Do you use some prefix in your units as "uwebutils.pp", "mywebutils.pp", "xyzWebUtils.pp", etc.

Thanks,
MD

Reply by email

Marcos Douglas
to Marcos Douglas
Marcos Douglas wrote 18 lines
How choose units names? I was thinking what are the best names to my units to not to conflict with the units of the FPC, Lazarus, and others frameworks or libs. e.g. fpc\2.5.1\packages\fcl-web\src\base\webutil.pp There are a great chance this unit name exists in some libs or frameworks, on the web. Even I would take this name, isn't? On the sources of FPC, exists a lot of units with a bit name... e.g. fpc\2.5.1\packages\ggi\src\*.pp  (ggi.pp | gii.pp | ggi2d.pp) All these names could be a name of variable... How you have no conflict with names of the units? Do you use some prefix in your units as "uwebutils.pp", "mywebutils.pp", "xyzWebUtils.pp", etc.

Sorry, I think this is a OFF TOPIC... so, I changed the Subject.

MD

Reply by email

Marco van de Voort
to Marcos Douglas: How choose units names? I was thinking what are the best names to my units to not to…

In our previous episode, Marcos Douglas said:

How you have no conflict with names of the units? Do you use some prefix in your units as "uwebutils.pp", "mywebutils.pp", "xyzWebUtils.pp", etc.

Just take unique ones. There are 30000 words in avg use in the avg language, so if you just take the two letter words, you are already in the 30000^2 magnitude.

The few units in the FPC and Lazarus project pale in comparison to that number.

In the rare case that they conflict, I just pick a different one.

Reply by email

Marcos Douglas
to Marco van de Voort
Marco van de Voort wrote 14 lines
In our previous episode, Marcos Douglas said: > > How you have no conflict with names of the units? Do you use some > prefix in your units as "uwebutils.pp", "mywebutils.pp", > "xyzWebUtils.pp", etc. Just take unique ones. There are 30000 words in avg use in the avg language, so if you just take the two letter words, you are already in the 30000^2 magnitude. The few units in the FPC and Lazarus project pale in comparison to that number. In the rare case that they conflict, I just pick a different one.

These names are not too simplistic to assign with units?

MD

Reply by email

Marc Weustink
to Marcos Douglas: How choose units names? I was thinking what are the best names to my units to not to…
Marcos Douglas wrote 5 lines
How choose units names? How you have no conflict with names of the units? Do you use some prefix in your units as "uwebutils.pp", "mywebutils.pp", "xyzWebUtils.pp", etc.

I used to prefix my units and classes with MW.
At my job all internal library units start with CC (abbrev of our company name).
The product I'm working on now starts with a K so all classes and units belonging to it start with CCK. This product has some sub projects, Console, Control and Config. So those units and classes start with CCKConsole, CCKControl, CCKConfig (nad some 20 more). So in each of those projects I can have a CCKClasses, CCKConsoleClasses, CCKControlClasses, CCKConfigClasses unit without conflicts. By looking at the name I know what the impact will be if I change something in a class or unit.

Thanks, MD

Maybe prefix with MD ?

Marc

Reply by email

Guillermo Martínez Jiménez
Show quoted text 6 lines
Date: Wed, 21 Jul 2010 16:55:14 -0300 From: Marcos Douglas How you have no conflict with names of the units? Do you use some prefix in your units as "uwebutils.pp", "mywebutils.pp", "xyzWebUtils.pp", etc.

I do use descriptive names, of course. I also use a "Unit" or "U" prefix; i. e.: "UnitConfiguration" or "UConfiguration". Also in some projects use an unique prefix; i. e.: my Allegro.pas wrapper library uses "al" as prefix, such as "al3d", "alfile", "albase", etc.

Guillermo "Ñuño" Martínez.

Reply by email

Graeme Geldenhuys
to Marcos Douglas: How choose units names? I was thinking what are the best names to my units to not to…
Marcos Douglas wrote
How you have no conflict with names of the units? Do you use some prefix in your units as "uwebutils.pp", "mywebutils.pp", "xyzWebUtils.pp", etc.

In the fpGUI project I now prefix all units with 'fpg_' and all classes start with 'Tfpg' - I indeed ran into unit or class name conflicts with FPC units. I suppose this is where languages like Java resolved this via directory and file namespaces - though I am not a fan of the directory namespace thing, but it seems to work for them.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Marcos Douglas
to Marc Weustink: I used to prefix my units and classes with MW. At my job all internal library units start…
Marc Weustink wrote 19 lines
Marcos Douglas wrote: > > How choose units names? > > How you have no conflict with names of the units? Do you use some > prefix in your units as "uwebutils.pp", "mywebutils.pp", > "xyzWebUtils.pp", etc. I used to prefix my units and classes with MW. At my job all internal library units start with CC (abbrev of our company name). The product I'm working on now starts with a K so all classes and units belonging to it start with CCK. This product has some sub projects, Console, Control and Config. So those units and classes start with CCKConsole, CCKControl, CCKConfig (nad some 20 more). So in each of those projects I can have a CCKClasses, CCKConsoleClasses, CCKControlClasses, CCKConfigClasses unit without conflicts. By looking at the name I know what the impact will be if I change something in a class or unit.

I think most people do it... I do, but I use lowercase for the prefix.

> Thanks, > MD Maybe prefix with MD ?

Yeah, for my personal contributions, some components, etc. I did that (and still do).

2010/7/22 Guillermo Martínez Jiménez :

Show quoted text 5 lines
I do use descriptive names, of course. I also use a "Unit" or "U" prefix; i. e.: "UnitConfiguration" or "UConfiguration". Also in some projects use an unique prefix; i. e.: my Allegro.pas wrapper library uses "al" as prefix, such as "al3d", "alfile", "albase", etc.

Okay Guillermo, thanks. The same as Marc above.
I use prefix "u" just only examples.

Graeme Geldenhuys wrote 6 lines
In the fpGUI project I now prefix all units with 'fpg_' and all classes start with 'Tfpg' - I indeed ran into unit or class name conflicts with FPC units. I suppose this is where languages like Java resolved this via directory and file namespaces - though I am not a fan of the directory namespace thing, but it seems to work for them.

The Pascal programmers has dislike "_" character, maybe just for constants, I think.

In the fpGUI project I now prefix all units with 'fpg_' and all classes start with 'Tfpg' - I indeed ran into unit or class name conflicts with FPC units.

That's what I was talking about! I'd be surprised if this was not happening... even after the explanation of Marco van de Voort.

I suppose this is where languages like Java resolved this via directory and file namespaces - though I am not a fan of the directory namespace thing, but it seems to work for them.

Yes, work for them... but the namespaces is very large in Java or C#. I like use, some times, the sintaxe: unit.function. Because of name conflicts of functions or prefix (also) the functions (besides classes), to not use name of unit as a prefix.

CONCLUSION:
I'm not a newbie programmer, even though my question says otherwise. I just like to know how the best programmers work in your daily. Some times I find some ideas to making my work better.

Thanks all.

MD

Reply by email

Graeme Geldenhuys
to Marcos Douglas
Marcos Douglas wrote
The Pascal programmers has dislike "_" character, maybe just for constants, I think.

I have been told that by a few, but I really don't know why they dislike it. I've gotten used to it rather quickly and use it more often now, even for small tests apps. eg: In fpGUI there is no extra "object" file for UI Forms - fpGUI only uses a single .pas file (no extensions like *.lfm or *.xfm or *.frm) , so I prefix a unit that contains a Form declaration with 'frm_'. This works great for me.

Yes, work for them... but the namespaces is very large in Java or C#. I like use, some times, the syntax: unit.function.

The more I think about it, the more I think Java had a good idea with directories as part of the namespace as well. This allows you to create code based on your companies domain name - and will not clash with others. Sometimes I with Object Pascal had something like that too.

Regards,   - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

Marcos Douglas
to Graeme Geldenhuys
Graeme Geldenhuys wrote 11 lines
On 22 July 2010 14:03, Marcos Douglas wrote: > > The Pascal programmers has dislike "_" character, maybe just for > constants, I think. I have been told that by a few, but I really don't know why they dislike it. I've gotten used to it rather quickly and use it more often now, even for small tests apps. eg: In fpGUI there is no extra "object" file for UI Forms - fpGUI only uses a single .pas file (no extensions like *.lfm or *.xfm or *.frm) , so I prefix a unit that contains a Form declaration with 'frm_'. This works great for me.

Sounds good for me.

Show quoted text 8 lines
> Yes, work for them... but the namespaces is very large in Java or C#. > I like use, some times, the syntax: unit.function. The more I think about it, the more I think Java had a good idea with directories as part of the namespace as well. This allows you to create code based on your companies domain name - and will not clash with others. Sometimes I with Object Pascal had something like that too.

Exactly.

We do not have directories as part of the namespace... but and if we could "rename" the units with an "nickname" to conflicts not happen? Look here one idea
http://lists.freepascal.org/lists/fpc-devel/2010-July/020699.html

MD

Reply by email