Good programming style

11.5.3.12 follow the rules of good programming style when writing a program code

Good programming style. 

Rules of good programming style

  1. Use clear and meaningful variable names: Choose variable names that accurately reflect what they represent. Use camelCase or snake_case to make them easy to read and understand.
     
  2. Write comments: Write comments to explain your code so that other developers can easily understand what your code does. Comments also help you to remember why you wrote the code.
     
  3. Use white space: Use white space to make your code easy to read. Use indentation to show the structure of your code.
     
  4. Be consistent: Use a consistent style throughout your code. For example, if you use camelCase for variable names, use it consistently throughout your code.
     
  5. Keep it simple: Keep your code simple and easy to understand. Don't try to do too much in one function or module.
     
  6. Avoid hardcoding values: Avoid hardcoding values in your code. Use constants or variables instead.
     
  7. Use error handling: Use error handling to prevent crashes and unexpected behavior. Make sure to handle both expected and unexpected errors.
     
  8. Use version control: Use version control to keep track of changes to your code. This makes it easier to collaborate with other developers and track bugs.
     
  9. Write readable code: Write code that is easy to read and understand. Avoid using complex code or tricks that may be hard to understand for other developers.

Questions:

  1. Explain what means "Good programming style".
  2. Provide three rules of good programming style.
  3. Explain what "control structure" means in program code.
  4. How does good programming style affect the development of large programs?

Exercises:

 


Exam questions:

 

Категория: Algorithms | Добавил: bzfar77 (04.04.2023)
Просмотров: 1957 | Теги: Programming | Рейтинг: 5.0/2
Всего комментариев: 0
avatar