Graduate Program KB

Clean Code

Chapter 1

  • Learn to:

    • Differentiate between good and bad code
    • Write good code
    • Transform bad code into good code
  • Coding will remain relevant in the future. As high-level programming languages continue to add layers of abstraction, code still specifies the requirements for a machine to execute actions based off precise details

  • Why avoid bad code?

    • Difficult to maintain in large code bases
    • Less readability
    • Difficult to effectively implement new features
  • Approach code with the principle of simplicity

    • Write the minimal amount of code that works
    • Refactor after
    • This step by step process applies few dependancies, ensures test cases pass and code remains as simple as possible throughout development
  • Developers should understand risks of bad coding decisions, regardless of external influence to management and scheduling which should be addressed separately

  • Clean code according to many experienced developers involves:

    • Elegant to read
    • Relies on minimal dependencies
    • Has complete error handling
    • Simple enough to be extendable
    • Optimised
  • Most of the time is spent reading and reviewing code first, rather than writing code straight away. Which emphasises the importance of writing clean code to make this process more efficient