[fpc-pascal] How choose units names?

Marcos Douglas md at delfire.net
Thu Jul 22 14:03:49 CEST 2010


On Wed, Jul 21, 2010 at 6:46 PM, Marc Weustink <marc at dommelstein.net> wrote:
> 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 <gmartinez at burdjia.com>:
>
> 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.


On Thu, Jul 22, 2010 at 4:56 AM, Graeme Geldenhuys
<graemeg.lists at gmail.com> wrote:
>
> 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



More information about the fpc-pascal mailing list