BestPractices
From NZ PHP User's Group
Best Practices
PHP best practices go here - edit this page to add your own.
Contents |
Coding Conventions
Coding conventions are a set of guidelines for a specific programming language that recommend programming style, practices and methods for each aspect of a piece program written in this language. These conventions usually cover file organization, indentation, comments, declarations, statements, white space, naming conventions, programming practices, etc. Programmers are highly recommended to follow these guidelines to help improve the readability of their source code and make software maintenance easier. Coding conventions are only applicable to the software maintainers and reviewers of a project. Conventions may be formalized in a documented set of rules that an entire team or company follows, or may be as informal as the art posters habitual coding practices of an individual. Coding conventions are not enforced by compilers. As a result, not following some funny quotes or all of the rules has no impact on the executable programs created from the source code.
===Naming Conventions=== nursery rhymescrazy tattoos dental implantshilarious quotesfunny quotes
A naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types and functions etc. in source code and documentation.Reasons for using a naming convention (as opposed to allowing programmers to choose any character sequence) include the following:
- to reduce the effort needed to read and understand source code;[1]
- to enhance source code appearance (for example, by disallowing overly long names or abbreviations).
The choice of naming conventions can be an enormously controversial issue, with partisans of each holding theirs to be the best and others to be inferior. Colloquially, this is said to be a matter of "religion". Many companies have also established their own set of conventions to best meet their interests.
Under Scoring
One approach is to delimit separate words with a nonalphanumeric character. The underscore ('_'), (e.g., the two word name "two words" would be represented as "two_words").
Camel Casing
Another approach is to indicate word boundaries using medial capitalization (also called "CamelCase" and many other names), thus rendering "two words" as either "twoWords" or "TwoWords".
White Space
todo...
MVC
Model–View–Controller (MVC) is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns).
The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). In event-driven systems, the model notifies observers (usually views) when the information changes so that they can react.
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.
The controller receives user input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input. Tampa Web Design Company
Code Sniffers
todo...
Frameworks
- CodeIgniter
- CakePHP
- Zend Framework
- Symfony
- Drupal
- Joomla
- Kohana
- Yii
- SilverStripe

