This repository was archived by the owner on Apr 22, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Fix #9: Naming conventions #10
Open
jpic
wants to merge
1
commit into
codingjoe:master
Choose a base branch
from
jpic:naming
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
5. [Forms](#Forms) | ||
6. [Templates](#Templates) | ||
7. [URL patterns](#URL patterns) | ||
8. [Naming conventions](#Naming conventions) | ||
|
||
4. [Documentation](#Documentation) | ||
5. [Git](#Git) | ||
|
@@ -118,6 +119,51 @@ urlpatterns = patterns( | |
) | ||
``` | ||
|
||
##### Naming conventions | ||
Avoid names which does not give additional meaning or are unclear. Some | ||
examples of such names are: Better, Quick, Smart, Clever, Simple, Fast, | ||
Strange, Stupid. | ||
|
||
In general one should not use abbreviations and acronyms unless its known by | ||
most programmers. Typical examples for known acronyms are: HTTP, HTML, URL. | ||
|
||
The following naming conventions should be used to ensure consistency | ||
throughout all source code. If the names don't make much sense in a given | ||
context other names should be found. Here are some recommendations: | ||
|
||
- For file or directory paths use `path`, | ||
- For filename without a path use `file`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shadows buildin |
||
- For directory name without a path use `dir`. | ||
- Use `load`, `save` for complete operations on the file system, for instance | ||
loading an entire `JSON` file. | ||
- Use `read`, `write` for partial operations of data stream, for instance | ||
storing 10 bytes to a file. | ||
- Use `fetch`, `store` for remote operations, for instance fetching data from a | ||
web server or database. | ||
- When adding elements the following naming should be used: | ||
- Use `add` when adding elements without a specific order. | ||
- Use `insert` when adding elements in a specific order, for instance at a | ||
given index or position. | ||
- Use `append` when adding elements to the end. | ||
- Use `prepend` when adding elements to the beginning. | ||
- Use `create` for object creation and `generate` for operations that | ||
generate text, code, SQL etc. | ||
- Use `reset` for resetting elements in the object. | ||
- When removing elements the following naming should be used: | ||
- Use `remove` when elements are no longer referenced but not actually | ||
deleted. For instance removing a file path from a list while still leaving | ||
the file on the file system. | ||
- Use `delete` when elements are no longer meant to exists. For instance | ||
unlinking a file from the file system or deleting a database record. | ||
- Short names are advised when their context is very clear. An example is a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if I would agree to this point. |
||
copy() function in a File class which has a source and a destination, it is | ||
quite clear that in this context we are working with files and can use | ||
abbreviated forms, `src` and `dest`. copy( src, dest ) The order of source | ||
and destination is always source first. | ||
- Some words are different in British English and American English. It is most | ||
common to use the American spelling and so all words should follow this. | ||
Some typical names are: initialize, finalize, color, grey. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
## Documentation | ||
- [pep257] | ||
- [pep287] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm missing the reference to PEP8 Prescriptive naming conventions.