naming convention in java

greendog768

New member
## Công ước đặt tên Java

** 1.Trường hợp lạc đà **

Trường hợp lạc đà là quy ước đặt tên phổ biến nhất trong Java.Đó là một phong cách viết trong đó các từ chỉ được viết hoa ở đầu mỗi từ, ngoại trừ từ đầu tiên trong một câu.Ví dụ: `myclass`,` mymethod` và `myvarable`.

** 2.Trường hợp Pascal **

Trường hợp Pascal là một phong cách viết trong đó mỗi từ trong một tên được viết hoa.Ví dụ: `myclass`,` mymethod` và `myvarable`.

** 3.Vỏ rắn **

Vỏ rắn là một phong cách viết trong đó các từ được phân tách bằng dấu gạch dưới.Ví dụ: `my_class`,` my_method` và `my_varable`.

**4.Trường hợp kebab **

Trường hợp kebab là một phong cách viết trong đó các từ được phân tách bằng dấu gạch ngang.Ví dụ: `My-Class`,` My-Method` và `My-Varable '.

** 5.Trường hợp trên **

Trường hợp trên là một phong cách viết trong đó tất cả các từ trong một tên được viết hoa.Ví dụ: `class`,` Phương thức` và `Biến`.

** Tôi nên sử dụng quy ước đặt tên nào? **

Công ước đặt tên tốt nhất để sử dụng phụ thuộc vào bối cảnh.Trường hợp lạc đà là phổ biến nhất và thường được coi là dễ đọc nhất.Trường hợp Pascal cũng là phổ biến và thường được sử dụng cho các lớp và giao diện.Trường hợp rắn ít phổ biến hơn nhưng đôi khi được sử dụng cho các biến và phương pháp.Trường hợp kebab và trường hợp trên hiếm khi được sử dụng.

** Dưới đây là một số lời khuyên để chọn một quy ước đặt tên: **

* Sử dụng một quy ước đặt tên nhất quán trong suốt mã của bạn.
* Làm cho tên của bạn càng mô tả càng tốt.
* Tránh sử dụng chữ viết tắt hoặc từ viết tắt.
* Tránh sử dụng các từ quá dài hoặc quá ngắn.
* Tránh sử dụng các từ quá giống nhau.

** Ví dụ về tên tốt: **

* `mycustomerlist`
* `getCustomerByid ()`
* `setCustomerName ()`

** Ví dụ về tên xấu: **

* `Clist`
* `getCustByid ()`
* `setCustName ()`

## hashtags

* #Java
* #naming quy ước
* #Programming
* #Software Development
* Kiểu #code
=======================================
## Java Naming Convention

**1. Camel Case**

Camel case is the most common naming convention in Java. It is a style of writing in which words are capitalized only at the beginning of each word, except for the first word in a sentence. For example, `myClass`, `myMethod`, and `myVariable`.

**2. Pascal Case**

Pascal case is a style of writing in which each word in a name is capitalized. For example, `MyClass`, `MyMethod`, and `MyVariable`.

**3. Snake Case**

Snake case is a style of writing in which words are separated by underscores. For example, `my_class`, `my_method`, and `my_variable`.

**4. Kebab Case**

Kebab case is a style of writing in which words are separated by dashes. For example, `my-class`, `my-method`, and `my-variable`.

**5. Upper Case**

Upper case is a style of writing in which all words in a name are capitalized. For example, `CLASS`, `METHOD`, and `VARIABLE`.

**Which naming convention should I use?**

The best naming convention to use depends on the context. Camel case is the most common and is generally considered to be the most readable. Pascal case is also common and is often used for classes and interfaces. Snake case is less common but is sometimes used for variables and methods. Kebab case and upper case are rarely used.

**Here are some tips for choosing a naming convention:**

* Use a consistent naming convention throughout your code.
* Make your names as descriptive as possible.
* Avoid using abbreviations or acronyms.
* Avoid using words that are too long or too short.
* Avoid using words that are too similar to each other.

**Examples of good names:**

* `myCustomerList`
* `getCustomerById()`
* `setCustomerName()`

**Examples of bad names:**

* `cList`
* `getCustById()`
* `setCustName()`

## Hashtags

* #Java
* #naming conventions
* #Programming
* #Software development
* #code style
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock