How do I separate my executable files from my library files?
I still haven't gotten an answer that I'm happy with. Please do submit some answers if you have a nice system for your Python or PHP projects.
I'm having a management issue with my PHP and Python projects. They both have t开发者_如何转开发wo kinds of code files: files that should be run in the console or web browser, and files that should be included from other files to extend functionality. After my projects grow into large namespace or module trees, it starts getting disorienting that "executable" files and library files lay side by side with the same file extensions in all my folders. If PHP and Python were pre-compile languages, this would be the files with the main
function.
For example, picture I have the namespace com.mycompany.map.address
which contained multiple .py or .php files depending on the project. It would contain models for different kinds of addresses and tons of functions for working with addresses. But in addition, it would contain some executable files that runs from the terminal, providing a user tools for searching for addresses, and perhaps adding and removing addresses from a database or such.
I want a way of distinguish such executable files from the tons and tons of code files in my namespace trees
If the files had separate file extensions this wouldn't be a problem. But since they don't, I'm thinking I should separate folders or something, but I don't know what to name them. In PHP I could perform the hack solution of configuring PHP to parse different file extensions, so my project could contain phps
or phpx
files, for instance.
If anyone has some language-independent advice on how to handle this issue, I'd appreciate it. This could also apply to languages such as C, where one project might compile into many executable files. How should one separate the source files containing main
functions from the rest of them?
Separate them somehow (by name, by extension, by location).
Example:
Here's the layout of our test automation system (output is manually sorted for clarity):
$ ls -1 automation
atf \ two major homebrew libraries, with many submodules
atflib /
atfconfig configuration files in .py form
configuration \ configuration files in .ini form
res_manager /
test_scripts - scripts to be invoked directly
Then we place the automation
folder into PYTHONPATH
and can import atf.<smth>
anywhere.
To run tests, we change into test_scripts
.
For my PHP projects, I follow a very Java-esque naming convention (my background):
index.php
/classes/{organization type: net, org, com}/{organization name}/{component}
/includes/ <- general configuration, etc; all non-executable;
/lib/ <- third party libraries that are tied to specific releases; not modified, patched/upgraded as needed;
/modules/ <- place for extensions written within the score of the project
精彩评论