actionscript 3 package naming conventions

半腔热情 提交于 2019-12-12 15:30:25

问题


What are the naming conventions for packages with names that contain more than one word? Lets say I have a package named 'garden hose', should I name it garden_hose, gardenHose or simply gardenhose?

I know that packages are normally named with lower-case letters only. I only see package names made out of one word in the api, are there any conventions for package names made out of several words?

With classes we have: ClassName. For instance RaceCar, what about packages?

I have a package named animationPath and I am wondering if I should rename it.


回答1:


Package names should all be lowercase. there are no examples in the ActionScript 3 documentation, since they all seem to have one-word-name, but several package names in another ECMAScript derived language, Java, reveals this convention. For example:

javax.swing.colorchooser
java.awt.datatransfer

However, I have also seen packages named in camelCase, ALLCAPS, and even CapitalCase. While i would suggest that you avoid using ALLCAPS, as this convention is typically reserved for constants, and CapitalCase convention is typically reserved for class names, i believe camelCase package names, if desired, would be more forgiving.




回答2:


Adobe used to have an article on their website with AS3 coding conventions, but it seems that with the opensourcing of the Flex framework, that page has gone. If I recall correctly, they suggested package names be camelCased like you did with animationPath. It doesn't look as nice as all lowercase, but underscores are even worse, in my opinion.

In the end, it's all about readability and trying to convey what the classes in your packages do. So do what you think best explains what's inside your packages.



来源:https://stackoverflow.com/questions/12763078/actionscript-3-package-naming-conventions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!