How you should group and organize your code, handle dependencies or manage file sizes.
Encapsulate Complexity
Hide complex or low-level operations behind higher-level abstractions. This makes the codebase more readable and easier to reason about.
Dependency Management
Clearly define and manage dependencies between different parts of your codebase. Use dependency injection or inversion of control to decouple components.
File Size and Complexity
Avoid excessively large files or functions. Break down large chunks of code into smaller, more manageable pieces.
If your files are super long, maybe your code is doing too much.
Directory Structure for Tests
Organize your tests in a separate directory structure mirroring your main codebase. This makes it easy to locate and run tests.
Group Related Code Together
Place code that serves a similar purpose or functionality together. For example, keep all database-related code in one section, UI-related code in another, and so on. This makes it easier to locate and understand the behavior of related code.
Use Namespaces or Packages
If your programming language supports it, use namespaces or packages to organize related code into logical units.
Modular Code
Break down your code into small, reusable modules or functions. This makes your codebase more maintainable and easier to understand.
Encapsulate related functionality in separate modules or packages. This allows for easier testing, reuse, and maintenance of code.
Separate Configuration from Code
Keep configuration settings (e.g., environment variables, constants) in separate files or environment-specific configurations.
Avoid Tight Coupling
Minimize dependencies between different parts of your code. Use interfaces, abstractions, and dependency injection to achieve loose coupling.
Avoid Circular Dependencies
Be mindful of dependencies that form a circular chain. This can lead to difficult-to-maintain code.
Do not leave code in comments
Others will be afraid to delete it, and will be irrelevant over time.
If it was important, you can bring it back from version control.