User Tools

Site Tools


en:dev:all:wb-adaption

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
en:dev:all:wb-adaption [13.06.2015 15:27] – [Einrücken] translated mrbasemanen:dev:all:wb-adaption [13.06.2015 16:37] – [Funktionen und Methoden] translated mrbaseman
Line 20: Line 20:
 ==== Indentation ==== ==== Indentation ====
 The standard pitch of the tab should be set to 4 spaces. An indentation generally consists of 4 spaces. Tabs themselves are not allowed at any point and for convenience should be automatically converted by the editor each in 4 spaces. The standard pitch of the tab should be set to 4 spaces. An indentation generally consists of 4 spaces. Tabs themselves are not allowed at any point and for convenience should be automatically converted by the editor each in 4 spaces.
-==== Maximale Zeilenlänge ==== +==== Maximum Line Length ==== 
-Die Zielzeilenlänge ist 80 ZeichenEntwickler sollten jede Zeile ihres Codes unter 80 Zeichen haltensoweit das möglich und praktikabel istTrotzdem sind längere Zeilen in Ausnahmefällen erlaubtDie maximale Länge einer PHP Codezeile sollte 130 Zeichen jedoch nicht überscheiten. +The target line length is 80 charactersDevelopers should keep each line of their code below 80 charactersas far as is possible and practicableNevertheless, longer lines are allowed in exceptional casesHowever, the maximum length of a PHP code line should not exceed 130 characters.
-==== Zeilenbegrenzung ==== +
-Die Zeilenbegrenzung folgt der Unix Textdatei Konvention. Zeilen müssen mit einem einzelnen Zeilenvorschubzeichen(**LF**) enden. Zeilenvorschubzeichen werden durch eine ordinale 10, oder durch 0x0A (hexadezimal) dargestellt.\\ +
-:!: **Beachte:** Benutze nicht den Wagenrücklauf (**CR** / 0x0D) wie in den Konventionen von Apple oder die Kombination aus Wagenrücklauf und Zeilenvorschub (**CR/LF** / 0x0D, 0x0A) wie im Standard für Windows angegeben.+
  
-===== Namens-Konventionen =====+==== Line termination ==== 
 +Line termination follows the Unix text file convention. Lines must end with a single linefeed (**LF**). Newline characters are represented by an ordinal 10, or 0x0A (hexadecimal).\\ 
 +:!: **Note:** Do not use the carriage return (**CR** / 0x0D) as in the conventions of Apple or the combination of carriage return and line feed (**CR/LF** / 0x0D, 0x0A) as specified in the standard for Windows.
  
-==== Allgemeines ====+===== Naming conventions =====
  
-WebsiteBaker übernimmt auch hier weitgehendst die PSR in einer an die Besonderheiten von WB angepassten Form. Die wichtigste Abweichung findet sich im Aufbau der Suchpfade für die Dateien. In späteren Versionen wird auch hier eine weitere Annäherung an PSR erfolgen. +==== General ====
-<blockquote>{{:info.png?nolink&32 |Hinweis}} +
-**Hinweis:** +
-Die strikte Einhaltung dieser Konventionen ist zwingend erforderlich, damit es bei verschiedenen Modulen keine Namensgleichheiten von Klassen und Funktionen/Methoden geben kann. Der Core ist dadurch in der Lage, die Position der Klassendateien anhand der Klassennamen eindeutig zu bestimmen, um sie durch den auf WB optimierten Autoloader nachzuladen. Eine explizite Einbindung der Klassendateien per include() oder require() wird dadurch überflüssig.  +
-</blockquote>WebsiteBaker ab v2.8.4 erfordert PHP 5.4.x als Mindestvoraussetzung. Für eine Übergangszeit sind noch 2 verschiedene Namenskonventionen für Klassen zulässig. Das erklärte Ziel ist jedoch die durchgängige Umstellung auf Namespaces um deren Vorteile zu nutzen und auch den Benennungsaufwand bei Klassen deutlich reduzieren zu können. +
-==== Klassen ==== +
-Klassennamen müssen in **StudlyCaps** (auch //**UpperCamelCase**// genannt) deklariert werden und müssen folgender RegEx-Regel entsprechen: '/[A-Z][a-zA-Z0-9]+/'. Nummern sind in Klassennamen gestattet, sollten jedoch auf das Notwendigste beschränkt werden und keine Verwechslungsgefahr mit Buchstaben bergen. Besteht der Klassenname aus mehr als einem Wort, so ist der jeweils erste Buchstabe eines Wortes groß zu schreiben. Mehrere aufeinanderfolgende Großbuchstaben sind nicht erlaubt. Beispiel anhand eines Namens: +
-^Bezeichner ^ Status | +
-|smtp_mailer | [color=red]falsch[/color] | +
-|Smtp_Mailer | [color=red]falsch[/color] | +
-|SMTPmailer | [color=red]falsch[/color] | +
-|SmtpMailer | [color=green]richtig[/color] |+
  
-==== Abstrakte Klassen und Interfaces ==== +Website Baker largely adopts the PSR here as well, in a version slightly adapted to the specific requirements WB. The main difference is found in the structure of the search paths for the files. In later versions also here a further approximation to PSR will take place. 
-Generell folgen abstrakte Klassen und Interfaces der gleichen Konvention wie Klassen, mit einer zusätzlichen Regel: Die Namen von abstrakten Klassen und Interfaces sollten mit dem Term "**Abstract**" bzw. "**Interface**" enden, und dem Term darf kein Unterstrich vorangestellt sein. Als Beispiel wird //**Plugin_Abstract**// als ungültig angenommenaber **PluginAbstract** oder **m_MyModul_PluginAbstract** wären gültige Namen.+<blockquote>{{:info.png?nolink&32 |Note}} 
 +**Note:** 
 +Strict compliance with these conventions is imperative so that there can be no homonyms of classes and functions / methods in different modules. The core is thus able to clearly determine the location of the class file based on the class name to reload them using the autoloader optimized on WB. An explicit inclusion of the class files via include () or require () is superfluous. 
 +</blockquote>Website Baker from v2.8.4 on requires PHP 5.4.x as a minimum requirement. For a transitional period 2 different naming conventions for classes are permitted. However, the stated objective is to convert entirely to namespaces to utilize their advantages and also to reduce the cost significantly when naming classes. 
 +==== Classes ==== 
 +Class names must be declared in **StudlyCaps** (also called //**UpperCamelCase**//) and correspond to the following RegEx rule:  '/[A-Z][a-zA-Z0-9]+/'. Numbers are permitted in class namesbut should be limited to what is necessary and do not pose any risk of confusion with lettersIf the class name consists of more than one word, the respective first letter of a word has to be in uppercase. Several consecutive uppercase letters are not allowed. Example based on a name: 
 +^Identifier ^ Status | 
 +|smtp_mailer | [color=red]wrong[/color] | 
 +|Smtp_Mailer | [color=red]wrong[/color] | 
 +|SMTPmailer | [color=red]wrong[/color] | 
 +|SmtpMailer | [color=green]correct[/color] |
  
-==== Emulierte Namespaces ==== +==== Abstract classes and interfaces ==== 
-In diesem Modus ist in Klassennamen zusätzlich der Unterstrich '_' als Sonder-/Funktionszeichen gestattet. Er dient jedoch ausschließlich als Pfadseperator. Klassennamen bestehen hier nicht allein aus dem bis jetzt definierten Namensondern müssen zusätzlich noch genau definierte Präfixes enthalten. Nur dann ist es möglichaus dem Klassennamen den exakten Dateinamen zu ermittelnso dass die passende Datei bei einem Zugriff auf eine Klasse automatisch geladen(included) werden kann.+In generalabstract classes and interfaces follow the same conventions as classeswith an additional rule: The names of abstract classes and interfaces should end with the term "**Abstract**" or "**Interface**", and the term must not be preceded by an underscore. As an example //**Plugin_Abstract**// is considered invalidbut **PluginAbstract** or **m_MyModul_PluginAbstract** would be valid names.
  
-Die Klassenbibliotheken von WebsiteBaker sind in mehrere Gruppen aufgeteilt:\\ +==== Emulated namespaces ==== 
-**Klassen des Kerns**:  sind im Verzeichnis **''wb/framework/''** oder einem seiner Unterverzeichnisse zu findenHierfür ist kein Prefix erforderlich.\\ +In this mode in class names the underscore '_is permitted additionally as special/functional characterHoweverit is intended solely as path separatorClass names in this context do not only consist of the name defined so farbut they must also contain a well-defined prefixOnly then it is possible to find the correct file out of the class name, so that the appropriate file can be loaded automatically (included) when accessing a class.
-**Klassen der Module**: Klassen der Module im jeweiligen Modulverzeichnis **''wb/modules/%modul_name%/''** oder einem seiner Unterverzeichnisse. Der Bezeichner muss zwingend den Prefix  '**m_**' erhalten. **Beispiel:** m_MyModule_PluginInterface \\ +
-**Klassen des ACP**: (AdminControlPanel => ehem. Backend) sind im Verzeichnis **''wb/admin/''** oder einem seiner Unterverzeichnisse zu finden. Der KlassenBezeichner muss zwingend den Prefix '**a_**' erhalten. **Beispiel:** a_Pages_PageTree\\ +
-**Klassen der third-party libraries**: die im Verzeichniss **''wb/include/''** sowie seinen Unterverzeichnissen liegenwerden vom Autoloader nicht automatisch erfasstJede Library hat jedoch die Möglichkeiteine eigene Registrierung im SPL-Autoloaderstack vorzunehmenMehr dazu in der Beschreibung des Autoloaders der jeweiligen WB-Version.+
  
-==== Dateinamen ==== +The class libraries of WebsiteBaker are divided into several groups:\\ 
-Soweit die vorgenannten Regeln für Klassennamen eingehalten wurden, ergeben sich die Dateinamen eindeutig aus den KlassennamenDie Klasse **m_MyModul_PluginAbstract** findet sich demnach in der Datei **''wb/modules/MyModul/PluginAbstract.php''**.\\ +**The core classes**: reside in the directory **''wb/framework/''** or one of its subdirectoriesFor these no prefix is needed at all.\\ 
-Für alle anderen Dateien sind nur alphanummerische Zeichen und der Bindestrich (**-**) gestattetLeerzeichen sind völlig verboten.\\ +**Classes of modules**: classes of modules in the appropriate module directory **''wb/modules/%module_name%/''** or one of its subdirectoriesThe identifier must necessarily get the prefix '**m_**'. **Example:** m_MyModule_PluginInterface \\ 
-Jede Datei, die ausführbaren PHP Code enthält sollte mit der Endung **.php** enden und in UpperCamelCase-Schreibweise ausgeführt sein+**Classes of ACP**: (AdminControlPanel => Former backendare located in the directory **''wb/admin/''** or one of its subdirectoriesThe ClassIdentifier must necessarily get the prefix '**a_**'**Example:** a_Pages_PageTree\\ 
-==== Verzeichnise ==== +**Classes of third-party libraries**: lying in the directory **''wb/include/''** and its subdirectories are not automatically covered by the autoloader. However, each library has the ability to carry out its own registration in the SPL autoloader stack. More on this can be found in the description of the autoloader the respective WB version
-Zur Benennung von Verzeichnissen gelten die selben Grundlagen wie für Dateien. Es sind nur alphanummerische Zeichen sowie nur wenige Sonderzeichen des Standard 7-Bit-ASCII Bereiches <128 (**[color=blue] ! # . @ ~ [/color]**) zulässigWie bei Dateinamen, sind Leerzeichen und der Unterstrich grundsätzlich verboten.  +==== Filenames ==== 
-==== Funktionen und Methoden ====+As far as the above-mentioned rules for class names have been complied with, the filename would clearly result from the class name. The class **m_MyModul_PluginAbstract** accordingly can be found in the file **''wb/modules/MyModul/PluginAbstract.php''**.\\ 
 +For all other files, only alphanumeric characters and the dash (**-**) are allowedSpaces are strictly prohibited.\\ 
 +Each file which contains executable PHP code should end with the extension **.php** and be carried out in UpperCamelCase.
  
-Funktionsund Methodennamen dürfen nur Alphanummerische Zeichen enthaltenUnterstriche sind nicht gestattet. Nummern sind in Funktionsnamen gestattet aber in den meisten Fällen nicht empfohlen. +==== Directories ==== 
-Wortreichtum wird generell befürwortetFunktionsnamen sollten so wortreich wie möglich sein um deren Zweck und Verhalten möglichst genau zu erklären.+For naming directories the same basis as for files apply. Only alphanumeric characters and a few special characters of standard 7-bit ASCII range <128 (**[color=blue] ! # - . @ ~ [/color]**) are allowedAs with file names, spaces, and the underscore are prohibited.
  
-Funktionen oder Methoden sollen möglichst immer in //**lowerCamelCase**// (oder einfach //**camelCase**//) geschrieben werden. Das bedeutet, mit einem klein geschriebenen Verb wie //get//, //set//, //add//, //delete//, //load//, //save//, //execute// etc. beginnen, das dann von einem Substantiv in StudlyCaps gefolgt werden kann, welches das zu bearbeitende Objekt beschreibt. Beispiel: <php> $oMyObject->saveItemList(); </php> oder <php> reloadAllModules(); </php>+==== Functions and Methods ====
  
-:!: **Achtung:** Es dürfen niemals doppelte Unterstriche als Prefix für Methoden-Funktions- oder Variablennamen verwendet werdenEs besteht hier die Gefahr, dass es zu Überschneidungen mit aktuellen oder zukünftigen, PHP-eigenen Magic-Functions etc. kommt.+Function and method names may only contain alphanumeric characters. Underscores are not permitted. Numbers are however permitted in function names in most cases however not recommended. Verbosity is generally encouraged. Function names should be as verbose as possible to describe their purpose and behavior as precisely as possible. 
 + 
 +Functions or methods have to be written whenever possible in //**lowerCamelCase**// (or simply //**camelCase**//). This means they should begin with a lowercase verb like //get//, //set//, //add//, //delete//, //load//, //save//, //execute// etc. followed by a noun in StudlyCaps that describes the object to be processed. Example: <php> $oMyObject->saveItemList(); </php> or <php> reloadAllModules(); </php> 
 + 
 +:!: **Warning:** doulble underscores may never be used as a prefix for methodfunction, or variable namesThere is the danger that it overlaps with current or future, PHP's intrinsic Magic Functions etc..
  
en/dev/all/wb-adaption.txt · Last modified: 13.06.2015 16:39 by mrbaseman