From 6ce2a7537a407fbf17743dd8b4eabd933a59cc9a Mon Sep 17 00:00:00 2001 From: metu Date: Wed, 27 Mar 2019 07:11:50 +0200 Subject: [PATCH 01/10] Added example for event handler parameter names Added event handler method with 'sender' and 'e' parameter names for point number 24: "DO use two parameters named sender and e in event handlers." --- C# Coding Standards and Naming Conventions.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/C# Coding Standards and Naming Conventions.md b/C# Coding Standards and Naming Conventions.md index 0f91076..11d88fb 100644 --- a/C# Coding Standards and Naming Conventions.md +++ b/C# Coding Standards and Naming Conventions.md @@ -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.*** From 1387d1e798e28b35b8ed369bddb24252f8a12c10 Mon Sep 17 00:00:00 2001 From: rodolphito Date: Tue, 2 Apr 2019 00:31:39 -0700 Subject: [PATCH 02/10] Do not use abbreviations in 5. because of 6. The rule right after it says not to do it, yet it does it. Hypocritical, lol... --- C# Coding Standards and Naming Conventions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/C# Coding Standards and Naming Conventions.md b/C# Coding Standards and Naming Conventions.md index 11d88fb..95b69ee 100644 --- a/C# Coding Standards and Naming Conventions.md +++ b/C# Coding Standards and Naming Conventions.md @@ -74,9 +74,9 @@ public const string SHIPPINGTYPE = "DropShip"; #### 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.*** From dea8b9d98c98c741e585ae40e3044cc7c185e286 Mon Sep 17 00:00:00 2001 From: Joseph Adamita Date: Mon, 8 Apr 2019 10:48:04 -0400 Subject: [PATCH 03/10] Fixed spelling error on line 72 Corrected "grap" to "grab" --- C# Coding Standards and Naming Conventions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C# Coding Standards and Naming Conventions.md b/C# Coding Standards and Naming Conventions.md index 95b69ee..1b9547f 100644 --- a/C# Coding Standards and Naming Conventions.md +++ b/C# Coding Standards and Naming Conventions.md @@ -69,7 +69,7 @@ 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: From 9a9fe01d4c8ae8d662927b69720dded5056f95ec Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 19 Apr 2019 12:31:01 +0300 Subject: [PATCH 04/10] Add awesome SEI CERT Coding Standards --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d7c2bc..977d1e1 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,14 @@ - [MSDN Approved Verbs for Windows PowerShellCommands][6] - [The PowerShell Best Practices and Style Guide](https://github.com/PoshCode/PowerShellPracticeAndStyle) - [PostgreSQL naming conventions](https://stackoverflow.com/q/2878248/2298061) + - [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] @@ -52,7 +60,7 @@ - [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) From 2b3b1c689780ccdf6042ff9caaf0aa5aeeb62bea Mon Sep 17 00:00:00 2001 From: Patrick Roche Date: Thu, 23 May 2019 08:23:39 -0400 Subject: [PATCH 05/10] Fix typo in C# conventions doc --- C# Coding Standards and Naming Conventions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C# Coding Standards and Naming Conventions.md b/C# Coding Standards and Naming Conventions.md index 1b9547f..8688f5b 100644 --- a/C# Coding Standards and Naming Conventions.md +++ b/C# Coding Standards and Naming Conventions.md @@ -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 From 7432514d54450f8a55a783b2752b12c2c30d8c5c Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 27 May 2019 10:24:41 +0300 Subject: [PATCH 06/10] add useful description and update links --- README.md | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 977d1e1..551b48b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,18 @@ -# Templates for naming convention +# Templates for Naming Convention +> 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 +20,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 - [NET Naming Guidelines][1] - [Framework Design Guidelines][2] @@ -34,14 +49,15 @@ - [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]) @@ -54,7 +70,8 @@ - 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] @@ -72,12 +89,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 From 21faf2ec28724b4fb5b2c658e6d6cc698321f636 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 27 May 2019 11:39:48 +0300 Subject: [PATCH 07/10] Add badges to README --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 551b48b..1856fc8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,22 @@ # 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/) From 6bedc816032136023dbe86fb72a0fc4fe4ea1d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fda=C5=9F=20Karademir?= Date: Mon, 23 Sep 2019 01:44:51 +0300 Subject: [PATCH 08/10] Update C# Coding Standards and Naming Conventions.md --- C# Coding Standards and Naming Conventions.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/C# Coding Standards and Naming Conventions.md b/C# Coding Standards and Naming Conventions.md index 8688f5b..4af11b6 100644 --- a/C# Coding Standards and Naming Conventions.md +++ b/C# Coding Standards and Naming Conventions.md @@ -412,6 +412,15 @@ public class BarcodeReadException : System.Exception } ``` +#### 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 From 6f3ea372ffb9aed0ade96fe469fa165b8c0ed325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fda=C5=9F=20Karademir?= Date: Mon, 23 Sep 2019 01:56:48 +0300 Subject: [PATCH 09/10] Update C# Coding Standards and Naming Conventions.md --- C# Coding Standards and Naming Conventions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/C# Coding Standards and Naming Conventions.md b/C# Coding Standards and Naming Conventions.md index 4af11b6..61afea7 100644 --- a/C# Coding Standards and Naming Conventions.md +++ b/C# Coding Standards and Naming Conventions.md @@ -412,6 +412,8 @@ 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 From 41c8550dcc9e4dde95d92a5172a44996ddd3fa08 Mon Sep 17 00:00:00 2001 From: Ian Rashkin Date: Tue, 31 Dec 2019 16:03:03 -0500 Subject: [PATCH 10/10] Fix camelCase def in Javascript md --- JavaScript Name and Coding Conventions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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: