Why Documenting Code is Crucial in Web Development

30 Nov 2018
Mike Patel
Mike Patel
Why Documenting Code is Crucial in Web Development

A lot of times, people who write code can wonder why so many insist on documenting each step of the process. Documentation can have a different importance for the unique roles of those interacting with the product, and can make or break the successful completion of functioning code.

Why Code Documentation Matters for Everyone on the Project

For Developers

Documentation provides a tangible roadmap to return to for reference. This is invaluable in testing, as the end stages can involve tweaking small parts of the same section of code.

For Reviewers (QA)

Documentation helps determine whether or not the code is functioning appropriately. An error could be overlooked if the input just happens to lead to the expected output by accident or coincidence.

For Maintainers

Documentation helps monitor functions for compatibility and continued use. As operating systems, platforms and dependencies change, the people working to keep an application running will have a better idea of which areas need focus.

For Users

Documentation can help users understand the functions built into the code. People with a basic understanding of code can better follow more intricate layers when they are following a labeled path.

For Developers Fixing Bugs

Documentation means you don’t have to troubleshoot blind if something causes issues down the line. Because the person fixing the issue may not be the one who wrote the code, documentation tells them how the code “should” function in every aspect, narrowing down the causes of potential defects.

Why Documentation Still Matters for Solo Projects

When developing apps for your own individual use, it can be tempting to assume that each of the above roles will only be performed by you. Even if this is true, documentation still helps with long-term use. The mindset you were in while writing the code will not be fresh when you revisit it later.

Best Practices for Writing Code Documentation

During the creation of an application, there are so many moving pieces that it can be a task to arrange the information to be used as a reference. When in doubt, it’s almost always better to include details than to leave them out. When writing the actual material, it is suggested that you:

  • Base everything around the code. Reviewers will be better able to follow the code and the documentation at the same time when both are structured similarly.
  • Make all formatting, tenses, and tones consistent. Documentation is easier to understand when the language flows smoothly.
  • Use plain English as much as possible. Jargon should only be used when unavoidable. Not everyone uses technical terminology consistently, and this could lead to unnecessary confusion.
  • Describe. Include examples. Avoid repeating basic how-to instructions that are covered elsewhere – link to those basics instead.
  • Be accurate, and revise updates as needed. If there is a difference between the app and the documentation, the reader may not know which is correct.

For a widely used framework for structuring documentation, see the Divio documentation system.

At a minimum, every project should have a README file that explains what the project does and how to set it up and run it, and a CHANGELOG that records what changed in each release. It also helps to treat your documentation like code (often called “docs-as-code”): keep it in Git next to the code so it is reviewed and updated with every change.

Internal Documentation: Using Comments in Your Code

Users and technicians who did not write the code will be able to understand it on a deeper level if they know the thought process behind its development. Even embedding comments within the code can make it easier for someone to find the section they need. Here’s a simple example of a PHP docblock:

This kind of internal documentation is excellent for quick reference. It allows the reviewer to read notes alongside the functions. Tools like PHPDoc and JSDoc can even generate reference documentation automatically from docblocks like this one. However, for simplicity’s sake, only a limited amount of information can be included without flooding the code. This creates a need for external documentation.

External Documentation: 5 Types Every Project Needs

For the big picture, many wonder what documentation should be produced, and struggle with trying to determine what information is vital and what is unnecessary. At its most basic, documentation needs to explain how the app works and how best to use it. The most common categories of documentation are:

User Documentation

Usually book-style, this explains the best way to use the features of the app.

Requirements Documentation

Lists the necessary components for the use of the app.

Architecture Documentation

Describes the system’s structure, components, data flows and key design decisions. Many teams also keep Architecture Decision Records (ADRs) – short notes that explain why a particular technical choice was made.

Technical Documentation

Describes the code as well as the interfaces and technical aspects of the app. This includes API documentation, which is often written using the OpenAPI (Swagger) specification. For online stores, technical documentation should also cover custom Magento/Adobe Commerce modules, Shopify apps and eCommerce integrations with ERP and PIM systems, so that upgrades, audits and agency handovers go smoothly.

Source Code

The pure text of the code for the app, often used for review during any changes.

Keep Your Reference Guides Easy to Update

Reference guides need to be information-focused. It helps to draft them so they are easy to expand or change as technology upgrades require. A consistent formatting structure makes later revisions easier and helps reviewers navigate the documents.

AI coding assistants can now help draft documentation and code comments, but a developer should always review what they produce for accuracy.

Prevent Spaghetti Code with Good Documentation

One of the most common, and frustrating, issues a coder can create is “Spaghetti Code.” Issues like this are preventable, or can be more easily fixed, when the code has been properly documented. It’s certainly worth the time, given all that it provides.

Need Help Cleaning Up or Documenting Your Codebase?

If your online store’s code is hard to maintain or poorly documented, ioVista can help. Our team can review your code with a technical code audit, provide ongoing support and maintenance, and handle custom eCommerce development that is built and documented to last.

Mike Patel
Mike Patel linkedin

Mike Patel is the Founder and CEO of ioVista, a leading digital commerce agency specializing in eCommerce solutions. With a strong background in business and technology, Mike Patel has been at the forefront of driving digital transformations for businesses. He has successfully navigated the ever-changing landscape of eCommerce, helping companies leverage the power of online platforms to grow their brand, increase revenues, and optimize their digital presence. Under his leadership, ioVista has become a trusted partner with major technology companies: Adobe/Magento, Google, BigCommerce, Shopify, and Yahoo. He is dedicated to staying ahead of industry trends, adopting cutting-edge technologies, and continuously improving strategies to provide clients with a competitive edge. Mike’s commitment to excellence and client satisfaction is evident in every project ioVista undertakes.

Get in Touch






    Let’s work together to create outstanding digital experiences.

    With 20+ years of industry experience, ioVista understands your eCommerce needs and delivers best-in-class solutions that help you gain a competitive edge.

    Platform Assessment

    TOP