
Learn to write clean, readable code by applying best practices, avoiding common mistakes in loops, formatting, and recursion, and design guided by single responsibility, open-closed, and dependency inversion principles.
Clarify the prerequisites for best programming practices, noting the course is not a basic programming course and expects prior programming experience, with Python examples used for illustration.
Learn to write meaningful comments that add value and avoid redundant notes. Apply guidance on essential comments, keep code self-explanatory, and use warnings and records of decisions for reviews.
Choose variable names that clearly express their purpose, using long, informative names, meaningful constants, and consistent conventions like camel case to improve readability, maintainability, and code reviews.
Avoid magic numbers by giving constants meaningful names. In the circle area example, replace the 22/7 with a named constant and use radius squared to improve readability and maintainability.
Explore choosing minimal, appropriate variable types across languages, including booleans, integers, and chars, with attention to memory use, floating point limitations, and real-time constraints.
Improve code readability and reliability by using spaces around operators and blank lines to separate input, logic, and output blocks, boosting maintainability in simple versus compound interest examples.
Avoid using a single equals sign in a condition that checks for zero using the remainder, which in C or C++ leads to a logical error; Python disallows this syntax.
Rearrange conditions to improve clarity, readability, and maintainability. Use temporary variables, logical operators, and a switch or dictionary to simplify leap year logic.
Identify common errors with loop counters, such as missing increments or decrements and updates placed wrongly, which can cause infinite loops and faulty termination, especially in Python.
Identify common mistakes that cause infinite loops, such as missing or misplacing the break statement. Learn how proper break usage ensures the program terminates and keeps control flow safe.
Learn how to optimize loops in prime number checks by early exiting on divisibility, avoiding unnecessary iterations, skipping even divisors, and considering the square root limit.
Learn to respect boundaries in code by avoiding out of bounds exceptions when comparing two lists, iterating to the shorter length, and documenting or checking assumptions to handle errors.
Name functions descriptively to reveal purpose, maintain consistency in terminology, and prefer verbs; invest time in thoughtful naming and, if needed, safely refactor with global renaming.
Apply the single responsibility principle to define the function objective, ensuring each function does one task. Split checks into dedicated functions, avoid boolean flags, and reduce code repetition.
Explore sizing functions by adhering to the single responsibility principle, keeping functions small and precise, and avoiding pointless division of code into part one and part two.
Explore how to manage function arguments from zero to three, using object-oriented methods and the single responsibility principle, and learn to reduce arguments by bundling data into a class.
Validate function parameters to prevent incorrect results and defend against invalid input, using if checks rather than assertions so validation works in both testing and production.
Explore error handling in programming by comparing error codes with exceptions, and show how exceptions support single responsibility principle and the open-closed principle, with prime and even number examples.
Learn how missing an exit path in recursion leads to an infinite loop, as shown in a factorial example where the function keeps calling itself without an exit.
Keep class sizes small, ideally smaller than you expect, by applying the single responsibility principle and splitting when a class provides multiple public methods.
Explore cohesion by examining how class attributes and methods hang together to expose information, and identify when to split a class into smaller ones to uphold the single responsibility principle.
Organize for change by adding a new derived class instead of modifying the existing one, minimizing impact on interacting classes and managing versioning.
Learn to isolate dependencies via interfaces and abstract base classes to minimize the impact of changes, embodying the dependency inversion principle for flexible, long-lasting software design.
We write code, it works, but it is not elegant. it is not based on the software design principle. Sometimes it is not very much readable, not easily extensible, not easily explainable to others. Such a code might work, but it is not a clean code.
Clean code is actually Craftsmanship.
Writing a clean code requires knowledge and work. For writing clean code, we need to know the common mistakes which we may leave behind and the best practices which we should follow.
This course covers the knowledge part of writing the clean code. The knowledge is about learning from our own and from others experiences. Learning from others mistakes or experience is more important and should be done early as it saves huge cost of making the same mistakes ourselves. Understanding and walking the right path is easier if we adopt it early in our journey i.e. when we are learning to code.
This course also covers the common mistakes and the best practices of programming. It tells you about the common mistakes which are made while using the loops, in formatting the code, in using recursion, how we end up getting a dead code etc. We write code, it works, but it is not elegant. it is not based on the software design principle. Sometimes it is not very much readable, not easily extensible, not easily explainable to others. Such a code might work, but it is not a clean code.
Clean code is actually Craftsmanship.
Writing a clean code requires knowledge and work. For writing clean code, we need to know the common mistakes which we may leave behind and the best practices which we should follow.
This course covers the knowledge part of writing the clean code. The knowledge is about learning from our own and from others experiences. Learning from others mistakes or experience is more important and should be done early as it saves huge cost of making the same mistakes ourselves. Understanding and walking the right path is easier if we adopt it early in our journey i.e. when we are learning to code.
This course also covers the common mistakes and the best practices of programming. It tells you about the common mistakes which are made while using the loops, in formatting the code, in using recursion, how we end up getting a dead code etc.