volume one
volume one

Reputation: 7563

Is it safe/acceptable to have duplicate CFC names?

I've got a bunch of CFCs that I'm trying to organise into folders so it's easier to know what CFC does what, rather than relying on just the file name.

So now the folder that a CFC is in makes it understandable as to what it does. For example:

mysite/cfc/security/user.cfc
mysite/cfc/security/page.cfc
mysite/cfc/users/page.cfc

So here we have a duplicate name of page.cfc which are two different CFCs doing different things. One interacts with the user's page, the other interacts with the security page. This is just an example, of course.

The other alternative I can think of is to have all CFCs in a folder and prefix them with what application area they affect, e.g.:

mysite/cfc/security-user.cfc
mysite/cfc/security-page.cfc
mysite/cfc/user-page.cfc

These are poor names but hopefully you get the gist of it.

What's the best way to go about this? Class names (therefore CFCs) should be nouns and both ways of doing it adheres to that. But which one is better practice or is there an entirely better way of doing this?

Upvotes: 3

Views: 94

Answers (2)

Adam Cameron
Adam Cameron

Reputation: 29870

The path to a CFC includes its directory name, mysite/cfc/security/page.cfc and mysite/cfc/users/page.cfc are not considered the same. So it doesn't matter you have two files called page.cfc.

Of course if you don't path your CFC references then there's ambiguity, but you should always either fully path them or import the package dir before referencing them anyhow.

Upvotes: 2

Will
Will

Reputation: 3044

I would say put files in related folders. It will make it easier to find the files based on its function.

When you use them you can specify the path to them. createObject("component", "cfc.securit.user")

Upvotes: 3

Related Questions