[go: up one dir, main page]

0% found this document useful (0 votes)
10 views5 pages

Naming

Uploaded by

phuong.bui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Naming

Uploaded by

phuong.bui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Naming

Why names matter


Well-named “Things” allow readers to understand your code without going
through it in detail

How to Name Things Correctly


Variables & Constants: Data containers
Functions / Methods: Commands or Calculated values
Classes: Use classes to create “things”

Name Casing
snake_case: python →variables, functions, methods
camelCase: java, javaScript → variables, functions, methods
PascalCase: python, java, javaScript → classes
kebab-case: <side-drawer> → html → custime HTML elements

Three main kinds of values


Object: Describe the value ex: user, database
Number or String: Describe the value ex: name, age

Boolean: Answer a true/false question ex: isActive, loggedIn

Naming 1
Naming function & methods
Function performs an operation: Describe the operation
Function computes a Boolean: Answer a true/false question

Naming classes
Describe the object

Classes are typically instantiated

Naming 2
Exception should be aware of
Access the method in classes as a property ( related to get method )

ex: It’s not get connected client it’s just connected client

Can’t change name of function in library

Don’t include redundant information in names


Names should avoid describing unnecessary or redundant details

Avoid slang, unclear abbreviations & disinformation

Naming 3
Choose distinctive names

Be consistent

Naming 4
Naming 5

You might also like