Coding Standard - Md-Ashraful-Alam/CSE327_Section05_Group03_Hospital_Management_System GitHub Wiki

Coding Standards: (Python)

Naming Conventions:

Variable Name:

We will use lowercase letters for our variable names. When we will use multiple words for variable naming, we will use underscore in between those words.

Example:

hotel_rent
name="Riyad"
post= 6400.

For performing Boolean type operation we will use "is/has/have ". However, it is not mandatory at all. We will use it for more flexibility. As example as given below-

Examples:

is_worker = True
student= True

Constants Name:

Constants are usually defined on a module level and written in all capital letters with underscores separating words. If we do not use capital letter for a constraint type word it will not use or consider as a constant keyword

Examples:

    MAX_NUMBER
    TOTAL
    num "wrong"

Method Name:

Method name will be in lower case. If we use multiple word for naming a method, we have to use underscore in between them.

Example:

def my_function(radius):
    radius=6
    return radius

Package and Module Names:

Package or module name should in lower case and short. We will use underscore in between multiple word for package naming.

Class Name:

Class names should normally use the Pascal Casing convention.

Example:

class AnimalClass:
   name="Lion"

Exception Names:

As exceptions are in classes the class naming convention, The pascal case convention will also be applied here. However, we will add the suffix “Error” on our exception names.

Example:

  class DividebyZeroError(Error):
       "It will give error when divide any number by zero"


 try:
     num = int(input("Enter any number: "))
     if num ==0:
       error DividebyZeroError

except DividebyZeroError:
   print("Input value is zero, try again!")
   print()

Indentation:

We used four (4) spaces per indentation level.

Example:

    if this_is_false 
        do_something()