Coding Standards_for students
Coding Standards_for students
Coding Standards_for students
3
NAMING CONVENTIONS
Key aspect of coding standards that help ensure that code is
understandable, maintainable, and consistent across teams and
projects.
Proper naming conventions make code more readable and allow
others (or your future self) to understand its purpose and structure
at a glance.
Each language and development environment might have its own
conventions, but there are common practices that developers follow
across various programming languages.
GENERAL NAMING CONVENTIONS
CATEGORIES:
1.Variables: Descriptive names that reflect the role or purpose of
the variable.
2.Functions/Methods: Use verbs that describe the action or
purpose of the function.
3.Constants: Names that remain constant throughout execution.
4.Classes/Interfaces: Names representing objects, entities, or roles.
5.Files and Modules: File names reflect the purpose or content of
the file.
▪ In camel case, you start a name with a small letter. If the name has
multiple words, the later words will start with a capital letter:
▪ firstName / lastName
▪ Like in camel case, you start the name with a small letter in snake
case. If the name has multiple words, the later words will start with
small letters and you use a underscore (_) to separate the words.
▪ last_name / first_name
▪ Variables should have names
that clearly represent their
purpose or the data they
hold.Use camelCase (for
JavaScript, Java, C#, etc.) or
snake_case (for Python, Ruby)
depending on the language's
convention.
▪ Names in pascal case start with a capital letter. In case of the
names with multiple words, all words will start with capital letters.
▪ FirstName / LastName
▪ Kebab case is similar to snake case, but you use a hyphen (-)
instead of an underscore (_) to separate the words.
▪ first-name / last-name
FUNCTION/METHODS
▪ Functions should
describe the action
they perform, using
verbs or verb phrases.
It should be clear
what the function is
supposed to do just
by reading the name.
CONSTANTS
▪ Names that remain constant
throughout
▪ executionConstants are often
written in
SCREAMING_SNAKE_CASE or
PascalCase depending on the
language, and they should
represent values that do not
change during the program
execution.
CLASSES/INTERFACES
▪ Names representing objects,
entities, or roles
▪ Classes and interfaces should
use PascalCase, and they
should represent nouns or
entities in the application (e.g.,
objects, models, services).For
interfaces, the name should
describe a behavior or
capability.
FILE AND MODULES
▪ File names reflect the purpose or
content of the file
▪ File names should reflect the
content or purpose of the file.
Use snake_case (Python) or
kebab-case
(JavaScript/HTML/CSS), or
PascalCase if naming convention
allows.
SUMMARY: NAMING CONVENTIONS
INDENTION STYLES
K&R (KERNIGHAN & RITCHIE) STYLE
▪ Used in: C, C++, Java, JavaScript,
PHP, and many other languages.
▪ Key Point: The opening curly
brace { is placed on the same line
as the control statement (if, for,
function, etc.).
▪ Indentation: Typically 4 spaces
(or tabs) for each level of
indentation.
ALLMAN STYLE
▪ Used in: C#, some C/C++
projects.
▪ Key Point: The opening curly
brace { is placed on a new
line.
▪ Indentation: Typically 4
spaces.
WHITESMITHS STYLE
ACTIVITY: INDIVIDUAL
▪ Create a CONTACT ME page/screen
▪ Identify the programming language you are going to use (ex. PHP & CSS)
▪ Write the whole code using proper coding standards
▪ Printed: Lesson Learned: Reflection on Coding Standards (cite examples on
your code)