Loading, please wait ...
Basic Coding Principles By Mukhtiar Zamin
Summary

Summary

0
Teachers with
Mukhtiar Zamin
0
Followers
For Learning
All
Visibility
Security Status
1
Contributions
By Teachers
Notes
  1. Students are auto-evaluated against related topics to ensure they learned it.


Variables Principles

  • Use Descriptive and Meaningful Variable, Function, and Class Names: Choose names that accurately represent the purpose and functionality of your code elements. Clear and concise names improve code readability and understanding, reducing the need for comments. 
  • Declare Variables in the Narrowest Scope Possible: Avoid declaring variables at the highest possible scope if they are only used within a specific block of code. By declaring variables closer to their usage, you improve code readability and prevent accidental misuse or interference. 
  • Initialize Variables When Declaring Them: Initialize variables at the point of declaration whenever possible. This makes your code more robust and eliminates potential issues caused by using uninitialized variables for example NullPointerException (causes 60% bugs)
  • Minimize the Use of Global Variables: Global variables can introduce hidden dependencies and make code harder to understand and maintain. Whenever possible, limit the scope of variables to the smallest necessary context. 
  • Follow the Principle of Single Responsibility: Functions and classes should have a single responsibility, performing one specific task. This improves code readability, reusability, and testability. Split complex functions into smaller, more focused functions.
  • Avoid Magic Numbers and Hardcoded Values: Instead of using arbitrary numbers or values directly in your code, assign them to named constants or variables. This improves code clarity, makes it easier to update values later, and enhances code maintainability. 

More Principles for All, By Mukhtiar Zamin

  • Write Self-Documenting Code
Aim to make your code as self-explanatory as possible. Use meaningful variable names, well-structured functions, and clear code organization. This allows others (and yourself) to understand the code without extensive comments. 
  • Keep Functions and Methods Short and Focused
Functions and methods should ideally be concise and focused on doing one thing well. If a function becomes too long or complex, consider refactoring it into smaller, more manageable pieces. 
  • Avoid Deeply Nested Code: Excessive levels of nesting in loops, conditionals, or function calls make code harder to understand. Strive for a shallow nesting structure and consider extracting nested code into separate functions or methods. 
  • Use Proper Indentation and Formatting: Consistent indentation and formatting make code more readable and maintainable. 
  • Follow the coding style conventions and guidelines of your programming language or organization. 
  • Comment Strategically: Use comments to explain complex logic, assumptions, or caveats, rather than commenting every line of code. 
  • Keep comments up to date with the code changes, and avoid redundant or misleading comments. 
  • Properly Handle Errors and Exceptions: Implement appropriate error handling mechanisms in your code. 
  • Use try-catch blocks or error propagation techniques to handle exceptions and communicate errors effectively. 
  • Optimize for Readability and Maintainability: Prioritize code readability and maintainability over premature optimization or micro-optimizations. Clear and understandable code is easier to debug, refactor, and enhance in the long run.

×

Basic Coding Principles Evaluation

To earn PASS status, system is about to evaluate you using multiple choice questions (MCQs) and True/False type questions.

  • CAREFULLY READ THE FOLLOWING INSTRUCTIONS!
  • Make sure you have learned this lecture along with its topics and tutorials.
  • On first evaluation you get 100% marks on correct answer, then on 2nd you get 95% marks and so on.
  • Answer the questions with a gap NOT MORE THAN A MINUTE, Otherwise it will re-start.

I have read above instrucitons and ready for evaluation.
Your's
Status
Not Registered
Teacher
Mukhtiar Zamin
TODO
Please ask your teacher to link related questions for this lecture.
Alert
Your performance monitoring will start when you register in a class of this course.

Questions on

No Linked topics!
Contact Us

support@subexpert.com
Write to Us View Help
Subject Expert Logo

Subject Expert

Learn, Evaluate and Optimize

Follow Us
Facebook Switch Display Mode Enable Translation
© 2025 - Subject Expert