开发者

JavaScript and PHP filename coding conventions

开发者 https://www.devze.com 2023-01-02 05:35 出处:网络
I would like to know the popular ways of naming files in JavaScript and PHP development. I am working on 开发者_如何学Pythona JS+PHP system, and I do not know how to name my files.

I would like to know the popular ways of naming files in JavaScript and PHP development. I am working on 开发者_如何学Pythona JS+PHP system, and I do not know how to name my files.

Currently I do for JS:

framework/
framework/widget/
framework/widget/TextField.js (Framework.widget.TextField())
Framework.js (Framework())

So, my folders are lowercase and objects CamelCase, but what should I do when the folder/namespace requires more than one word? And what about PHP?

jQuery seems to follow:

jquery.js
jquery.ui.js
jquery.plugin-name.js

so that it is

jquery(\.[a-z0-9-])*\.js

but ExtJS follows completely different approach. Douglas Crockford only gives us details about his preference for syntax conventions.


Personally I'd go for all lower case names for the folders, separating words with "-" as per jQuery, but that's without any evidence to back it up.

However, what ever system you choose, be consistent. This will not only help you 6 months down the line, but will help someone coming to your system. They'll soon learn their way around even if it's not 100% the same as other systems they've used in the past.

0

精彩评论

暂无评论...
验证码 换一张
取 消