Naming Conventions
As a computer programmer, inventing variable names which represent objects in real life can be very time-consuming. Perhaps these naming conventions will save me time.
See also: How To Write Unmaintainable Code - Ensure a job for life ;-) by Roedy Green
Contents
Command line
+--------------+ 1 * +----------+ | command line +-------+ argument | +-------+------+ +-----+----+ 1 | /_\ | 1 | +----+----+ +----+---+ 1 * +-----------------+ | command | | option +-------+ option argument | +---------+ +--------+ +-----------------+
Figure 1. Command line class diagram
A `command line' consists of a `command' and `arguments'. Non-mandatory arguments are called `options'. An option may have zero or more optional arguments: `option arguments'.
Temporary files
Suffix temporary or generated files with a tilde (~), e.g.:
foo.sh~
Advantages of the tilde suffix are:
- Subversion automatically ignores files ending with `~'
- Vim is still able to recognize the filetype, effectively ignoring the `~' suffix
Filesystem
- http://www.pathname.com/fhs/
- Conventions for directory tree layout. The Filesystem Hierarchy Standard (FHS) has been designed to be used by Unix distribution developers, package developers, and system implementors.
- http://zendframework.com/manual/1.11/en/project-structure.project.html
- Recommended project structure for PHP Zend Framework project.
Testing framework
JUnit.org features a comprehensive site about unit testing. Naming conventions:
+-----------+ * +------------+ | TestSuite +---------+ TestCase + +-----------+ * +------------+ +-----------+ +------------+ | + addTest | | + run | | + run | | + setUp | | + runTest | | + tearDown | +-----------+ +------------+
Db
- http://dbdeploy.com/
- System to change the database by using version-controlled SQL delta scripts.
URI components
Ascii Art
foo://example.com:8042/over/there?name=ferret#nose \_/ \______________/\_________/ \_________/ \__/ | | | | | scheme authority path query fragment ------------------------------------------------------- uri
example.com:8042 \_________/ \__/ | | host port
mailto:fred@example.com \____/ \______________/ | | scheme path foo://info.example.com?fred \_/ \______________/ \__/ | | | scheme authority query
RFC 3986
- Scheme
- Authority
- User Information
- Host
- Port
- Path
- Query
- Fragment
authority = [ userinfo "@" ] host [ ":" port ]
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
What happened to the word 'domain'? -- FVu, 7 Jul 2005
External links
RFC 3986, Uniform Resource Identifier (URI): Generic Syntax
RFC 3987, Internationalized Resource Identifiers (IRIs)
Be
Prefix a variable with `be' to indicate that the sole existance of the variable or filename suffices: the actual value of the variable doesn't matter. Think of it as: to be or not to be, that's the question.
$beChecked = ""; // Any value will indicate "is checked" isset($beChecked) || check() // Good, the actual value of $beChecked doesn't matter $beChecked == true || check() // Wrong, the actual value of $beChecked doesn't need to be checked
Backup
incr incremental diff differential full full
Home Directory Organization Policy
- Home Directory Organization Policy
- "This document specifies a "best practice" for filing"
See also
- GNU Coding Standards
- "Their purpose is to make the GNU system clean, consistent, and easy to install."
- A Proper Server Naming Scheme
- Guide how to choose good hostnames
- http://namingschemes.com
- All kinds of lists of names