diff --git a/C# Coding Standards and Naming Conventions.md b/C# Coding Standards and Naming Conventions.md index 0f91076..61afea7 100644 --- a/C# Coding Standards and Naming Conventions.md +++ b/C# Coding Standards and Naming Conventions.md @@ -69,14 +69,14 @@ public const string ShippingType = "DropShip"; public const string SHIPPINGTYPE = "DropShip"; ``` -***Why: consistent with the Microsoft's .NET Framework. Caps grap too much attention.*** +***Why: consistent with the Microsoft's .NET Framework. Caps grab too much attention.*** #### 5. Use meaningful names for variables. The following example uses seattleCustomers for customers who are located in Seattle: ```csharp -var seattleCustomers = from cust in customers - where cust.City == "Seattle" - select cust.Name; +var seattleCustomers = from customer in customers + where customer.City == "Seattle" + select customer.Name; ``` ***Why: consistent with the Microsoft's .NET Framework and easy to read.*** @@ -378,7 +378,7 @@ public delegate void ReadBarcodeEventHandler(object sender, ReadBarcodeEventArgs ***Why: consistent with the Microsoft's .NET Framework and easy to read.*** -#### 23. Do not create names of parametres in methods (or constructors) which differ only by the register: +#### 23. Do not create names of parameters in methods (or constructors) which differ only by the register: ```csharp // Avoid @@ -392,6 +392,13 @@ private void MyFunction(string name, string Name) #### 24. DO use two parameters named sender and e in event handlers. The sender parameter represents the object that raised the event. The sender parameter is typically of type object, even if it is possible to employ a more specific type. +```csharp +public void ReadBarcodeEventHandler(object sender, ReadBarcodeEventArgs e) +{ + //... +} +``` + ***Why: consistent with the Microsoft's .NET Framework*** ***Why: consistent with the Microsoft's .NET Framework and consistent with prior rule of no type indicators in identifiers.*** @@ -407,6 +414,17 @@ public class BarcodeReadException : System.Exception ***Why: consistent with the Microsoft's .NET Framework and easy to read.*** +#### 26. Do use suffix Any, Is, Have or similar keywords for boolean identifier : + +```csharp +// Correct +public static bool IsNullOrEmpty(string value) { + return (value == null || value.Length == 0); +} +``` + +***Why: consistent with the Microsoft's .NET Framework and easy to read.*** + ## Offical Reference 1. [MSDN General Naming Conventions](http://msdn.microsoft.com/en-us/library/ms229045(v=vs.110).aspx) diff --git a/JavaScript Name and Coding Conventions.md b/JavaScript Name and Coding Conventions.md index 473fa2e..9731721 100644 --- a/JavaScript Name and Coding Conventions.md +++ b/JavaScript Name and Coding Conventions.md @@ -3,10 +3,10 @@ | Object Name | Notation | Length | Plural | Prefix | Suffix | Abbreviation | Char Mask | Underscores | |--------------------|------------|--------|--------|--------|--------|--------------|------------|-------------| | Function name | PascalCase | 50 | Yes | No | Yes | Yes | [A-z][0-9] | No | -| Function arguments | CamelCase | 50 | Yes | No | No | Yes | [A-z][0-9] | No | -| Local variables | CamelCase | 50 | Yes | No | No | Yes | [A-z][0-9] | No | +| Function arguments | camelCase | 50 | Yes | No | No | Yes | [A-z][0-9] | No | +| Local variables | camelCase | 50 | Yes | No | No | Yes | [A-z][0-9] | No | | Constants name | PascalCase | 50 | Yes | No | No | Yes | [A-z][0-9] | No | -| Field name | CamelCase | 50 | Yes | No | No | Yes | [A-z][0-9] | No | +| Field name | camelCase | 50 | Yes | No | No | Yes | [A-z][0-9] | No | ## Coding conventions are style guidelines for programming. They typically cover: diff --git a/README.md b/README.md index 1f84fd3..9b397a5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,36 @@ -# Templates for naming convention +# Templates for Naming Convention +[![licence badge]][licence] +[![stars badge]][stars] +[![forks badge]][forks] +[![issues badge]][issues] +[![contributors_badge]][contributors] + +[licence badge]:https://img.shields.io/badge/license-MIT-blue.svg +[stars badge]:https://img.shields.io/github/stars/ktaranov/naming-convention.svg +[forks badge]:https://img.shields.io/github/forks/ktaranov/naming-convention.svg +[issues badge]:https://img.shields.io/github/issues/ktaranov/naming-convention.svg +[contributors_badge]:https://img.shields.io/github/contributors/ktaranov/naming-convention.svg + +[licence]:https://github.com/ktaranov/naming-convention/blob/master/LICENSE.md +[stars]:https://github.com/ktaranov/naming-convention/stargazers +[forks]:https://github.com/ktaranov/naming-convention/network +[issues]:https://github.com/ktaranov/naming-convention/issues +[contributors]:https://github.com/ktaranov/naming-convention/graphs/contributors + +> There are only two hard things in Computer Science: cache invalidation and naming things +> -- [Phil Karlton](https://www.karlton.org/2017/12/naming-things-hard/) + +[Naming convention][99] is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities 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; + - To enable code reviews to focus on more important issues than arguing over syntax and naming standards. + - To enable code quality review tools to focus their reporting mainly on significant issues other than syntax and style preferences. + +[99]:https://en.wikipedia.org/wiki/Naming_convention_(programming) + + +## Templates in Markdown Format - [C# Coding Standards and Naming Conventions](C%23%20Coding%20Standards%20and%20Naming%20Conventions.md) - [Git Comment Convention](Git%20Comment%20Convention.md) - [JavaScript Name and Coding Conventions](JavaScript%20Name%20and%20Coding%20Conventions.md) @@ -6,6 +38,7 @@ - [R style guide and name convention](R%20style%20uide%20and%20name%20convention.md) - [SQL Server Name Convention and T-SQL Programming Style](SQL%20Server%20Name%20Convention%20and%20T-SQL%20Programming%20Style.md) + ## Useful links for name conventions - [PEP 8 — the Style Guide for Python Code](https://pep8.org/) - [PHP Standards Recommendations](https://www.php-fig.org/psr/) @@ -31,13 +64,22 @@ - [PostgreSQL naming conventions](https://stackoverflow.com/q/2878248/2298061) - [Lint commit messages](https://github.com/conventional-changelog/commitlint) - [Comprehensive language-agnostic guidelines on naming variables](https://github.com/kettanaito/naming-cheatsheet) + - [SEI CERT Coding Standards](https://wiki.sei.cmu.edu/confluence/display/HOME) + - [SEI CERT C Coding Standard](https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Coding+Standard) + - [SEI CERT C++ Coding Standard](https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=88046682) + - [SEI CERT Oracle Coding Standard for Java](https://wiki.sei.cmu.edu/confluence/display/java/SEI+CERT+Oracle+Coding+Standard+for+Java) + - [Android Secure Coding Standard](https://wiki.sei.cmu.edu/confluence/display/android/Android+Secure+Coding+Standard) + - [SEI CERT Perl Coding Standard](https://wiki.sei.cmu.edu/confluence/display/perl/SEI+CERT+Perl+Coding+Standard) + - [SEI CERT Perl Coding Standard](https://wiki.sei.cmu.edu/confluence/display/perl/SEI+CERT+Perl+Coding+Standard) + ## Relation Database Documentation - - [SQL Server Documentation][7] - - [SQLite Documentation][8] - - [PostgreSQL Manual][9] - - [Oracle DB documentation][10] - - [MySQL documentation][11] + - [SQL Server Documentation](https://docs.microsoft.com/sql/sql-server/sql-server-technical-documentation) + - [SQLite Documentation](https://www.sqlite.org/docs.html) + - [PostgreSQL Manual](http://www.postgresql.org/docs/current/static/) + - [Oracle DB documentation](https://docs.oracle.com/en/database/database.html) + - [MySQL documentation](http://docs.oracle.com/cd/E17952_01/index.html) + ## Different Languages Style Guides - C# Language ([C# Programming Guide]) @@ -51,13 +93,14 @@ - R Language ([R Language Definition]) - Transact-SQL ([T-SQL Reference]) - Procedural Language/PostGres Structured Query Language ([PL/pgSQL Manual]) - - [Python PEP](https://www.python.org/dev/peps/pep-0008/) + - [Python PEP](https://www.python.org/dev/peps/) + ## R Language - [Google R Style Guide][3] - [Hadley Wickham R style guide](http://r-pkgs.had.co.nz/style.html) - [Stackoverflow R discussion](http://stackoverflow.com/questions/10013545/are-there-any-official-naming-conventions-for-r) - - [Bioconductor R coding standards](http://bioconductor.org/developers/how-to/coding-style/) + - [Bioconductor R Coding Standards](http://bioconductor.org/developers/how-to/coding-style/) - [Bioconductor R Package Guidelines](http://bioconductor.org/developers/package-guidelines/) - [Colin Gillespie’s R style guide](http://csgillespie.wordpress.com/2010/11/23/r-style-guide/) - [Hadley Wickham’s R style guide](http://stat405.had.co.nz/r-style.html) @@ -72,12 +115,6 @@ [5]:http://msdn.microsoft.com/en-us/library/dd878270%28v=vs.85%29.aspx [6]:http://msdn.microsoft.com/en-us/library/ms714428%28v=vs.85%29.aspx -[7]:https://docs.microsoft.com/sql/sql-server/sql-server-technical-documentation -[8]:https://www.sqlite.org/docs.html -[9]:http://www.postgresql.org/docs/current/static/ -[10]:https://docs.oracle.com/en/database/database.html -[11]:http://docs.oracle.com/cd/E17952_01/index.html - [C# Programming Guide]:http://msdn.microsoft.com/ru-ru/library/67ef8sbd.aspx [R Language Definition]:http://cran.r-project.org/doc/manuals/R-lang.html [T-SQL Reference]:https://docs.microsoft.com/en-us/sql/t-sql/language-reference