day-11: The Importance of Naming Conventions in Clean Code

Let us recall the topics Class: Logical Entity - Blue Print or Template - Company Object: Physical Entity - Sample of Class - Employee Method: Action - calculateSalary More meaningful examples: WHY: Object: Real Time Entity / Physical Entity / Representation (Sample) of a class / Instance of a Class Object: Combination of States and Behaviors: Mobile: State: நிலை - RAM, Processor, MP, Pricing Behavior: - Call, Browse, Chat Naming convention: 1) Class name should start with capital Letter Eg. Calculator 2) Should Follow Camel Case MyFirstJavaProgram, My_First_Java_Program 3) Should not start with Numbers Eg. 2Calculator --> Calculator2 4) No Special Characters except _, $ 5) MEANINGFUL NAME 6) Class Names should be Nouns, should not be Verbs. Eg. Browser, Browse is not correct. Object Name: Meaningful Calculator calculator = new Calculator(); Datatypes: தரவுவகை -> mp3,mp4, pdf, doc, xls --> Binary (0,1s) 1 Bit: Binary Digits (0,1s) 1 Byte: 8 Bits: String is a class. int, float, boolean - Not classes Example Programmes: 1). Theatre as Class public class Theatre { int ticket_fare; //int float show_time; //float String screen; //String boolean on_screen; //boolean public static void main(String[] args) { Theatre theatre = new Theatre(); theatre.playShow(); // } public void playShow() { System.out.println("Dar"); } } 2). School as a Class public class School { int no_students; //int float timing; //float String name; //String boolean open; //boolean public static void main(String[] args) { School school = new School(); } } 3). Bank as Class: public class Bank { int amount; //int float interest_rate; //float String name; //String boolean open; //boolean public static void main() { Bank bank = new Bank(); } } By following proper naming conventions and structuring your classes, objects, and methods effectively, you create clean, readable, and maintainable code that will stand the test of time. Happy Learning... ------------------------ End of the Blog -------------------------

Apr 1, 2025 - 18:57
 0
day-11: The Importance of Naming Conventions in Clean Code

Let us recall the topics

  1. Class: Logical Entity - Blue Print or Template - Company
  2. Object: Physical Entity - Sample of Class - Employee
  3. Method: Action - calculateSalary

More meaningful examples:
WHY:
Object: Real Time Entity / Physical Entity / Representation (Sample) of a class / Instance of a Class

Object: Combination of States and Behaviors:
Mobile:
State: நிலை - RAM, Processor, MP, Pricing
Behavior: - Call, Browse, Chat

Naming convention:
1) Class name should start with capital Letter
Eg. Calculator

2) Should Follow Camel Case
MyFirstJavaProgram, My_First_Java_Program

3) Should not start with Numbers
Eg. 2Calculator --> Calculator2

4) No Special Characters except _, $

5) MEANINGFUL NAME

6) Class Names should be Nouns, should not be Verbs.
Eg. Browser, Browse is not correct.

Object Name: Meaningful
Calculator calculator = new Calculator();

Datatypes: தரவுவகை
-> mp3,mp4, pdf, doc, xls --> Binary (0,1s)

1 Bit: Binary Digits (0,1s)
1 Byte: 8 Bits:

String is a class.
int, float, boolean - Not classes

Example Programmes:

1). Theatre as Class

public class Theatre {

    int ticket_fare; //int 
    float show_time; //float 
    String screen; //String 
    boolean on_screen; //boolean

    public static void main(String[] args) {
        Theatre theatre = new Theatre(); 
        theatre.playShow(); //     
    }

    public void playShow() {
        System.out.println("Dar");
    }

}

2). School as a Class

public class School {

    int no_students; //int 
    float timing; //float 
    String name; //String 
    boolean open; //boolean

    public static void main(String[] args) {
        School school = new School(); 
    }
}

3). Bank as Class:

public class Bank {

    int amount; //int 
    float interest_rate; //float 
    String name; //String 
    boolean open; //boolean

    public static void main() {
        Bank bank = new Bank();
    }

}

By following proper naming conventions and structuring your classes, objects, and methods effectively, you create clean, readable, and maintainable code that will stand the test of time.

Happy Learning...

------------------------ End of the Blog -------------------------