What's good naming convention between snake_case, camelCase and PascalCase

9 views   Programming  2021.01.09


I need to know which is best way(naming convention) to use between camelCase, PascalCase and snake_case according to different programming languages including Java, Python, Php, Javascript, C, C++ and C# because I use whatever style comes to my head first, Is it necessary to use them accordingly or it depends on language you are currently using, Dev help please!

Answers, ideas and Comments

» 2 ideas

gadrawin • 1 week ago
Both Pascal Casing and camelCasing are the same, but in first case, we capitalize each word and in the latter case, we capitalize each word except the the first letter which stays lowerCased, and first letter of every word, after that should be Upper Case. Example: PascalCasing Example 2: camelCasing Contrary to above cases, In snake_case multiple words are separated with underscore and stay lower_cased »

0 



gadrawin • 1 week ago
Before considering good naming convention to use it's better to know what it is about. As we see, there are many reasons for using a naming convention according to Wikipedia's article including:
  1. Readability
  2. Reducing the effort needed to read and understand source code
  3. To enable code reviews to focus on more important issues than arguing over syntax and naming standards.
  4. To enable code quality review tools to focus their reporting mainly on significant issues other than syntax and style preferences.
Again, it's always a good practice to choose a set of conventions based on programming you are working on. Example: Coding in Java:


/* 
Pascal case is mainly used while 
naming classes in all programming
including php, Java, Python, Ruby, etc.
*/

public class PascalCase {

   public static void main(String args[]) {
      PascalCase pc = new PascalCase();
      pc.setStyle("Pascal Case");
      pc.setRules("Each Letter must be started with Capital letter");

      System.out.print("The style is : " + pc.getStyle() + " and Rules: " + pc.getRules());
   }
}

Use camelCase when naming your functions especially in Javascript even though it's looks suitable in almost all languages.

function doCountWithProgress() {
   for(let i = 0; i <=40; i++) {
   // Something....
   }
}  

doCountWithProgress();
As I see, snake_case is a good thing when it comes to php and naming database names, attributes, entities and more like this : cases_table instead of CasesTable or casesTable

public function view_user_data ($username, $email)
{
   echo "Something...";
}
 »

0 



In order to go deep, share any relevant idea or posting solution to some questions, You have to sign in or create a new account if you don't have one. And get Donnekted(connected)




Log in now  Join the Team

This site is for sharing topics, questions, answers, experiences or other contents related to different stuffs, especially technology. For existing users, They can make any topic(post) to discuss about in hope for ideas or any result from other people from different communities. In order to get involved, Get donnekted(connected) by Joining us here!