Internal documentation
Why comment your code?
What is the purpose of internal documentation?Explaining and justifying data and code structures Internal documentation provides insights into the logic behind the design choices made in the code. It explains why certain data structures are chosen, how they are organised, and how they relate to each other. This helps developers understand the code more easily, especially when they need to modify or extend it. It is useful for intricate algorithms or unconventional solutions where a simple comment can significantly enhance comprehension. Code maintenance As software evolves over time, developers may need to revisit and modify existing code. Internal documentation serves as a guide for maintaining and updating code by documenting the intended behaviour of functions, classes and modules. It helps developers quickly grasp the functionality of different parts of the code, reducing the time required for debugging and refactoring. Placeholder comments for future development (stubs) When implementing a feature or fixing a bug, developers may need to leave unfinished parts of the code (known as stubs) to be completed later. Internal documentation helps in identifying these stubs by providing placeholder comments that outline what needs to be implemented and why. This ensures that unfinished code segments are not overlooked and facilitates smoother collaboration among team members working on different parts of the project. Programmers rarely work solo – usually in a team In a collaborative environment, internal documentation serves as a means of communication among team members. It ensures that everyone is on the same page regarding the code's structure, design decisions and implementation details. This fosters collaboration, reduces misunderstandings and promotes consistency across the project. Programmers often work on their own code, and years later when they need to revisit code will have forgotten it all Internal documentation acts as a memory aid for developers, including their future selves. It helps programmers recall their past thought processes, design considerations and implementation details, even after a significant amount of time has passed. This reduces the challenges with revisiting old code and accelerates the ramp-up time for developers returning to a project. |