Skip to content

refactor(result): split large result.h into modular sub-headers#246

Merged
kcenon merged 1 commit into
mainfrom
refactor/split-result-header
Dec 28, 2025
Merged

refactor(result): split large result.h into modular sub-headers#246
kcenon merged 1 commit into
mainfrom
refactor/split-result-header

Conversation

@kcenon

@kcenon kcenon commented Dec 28, 2025

Copy link
Copy Markdown
Owner

Summary

  • Split 913-line result.h into 8 focused sub-headers under result/ directory
  • Convert result.h to umbrella header for full backward compatibility
  • Update documentation with new header structure and include strategies

Changes

New Header Structure

include/kcenon/common/patterns/
├── result.h                      # Umbrella header (backward compatible)
└── result/
    ├── fwd.h                     # Forward declarations, result_state enum
    ├── error_info.h              # error_info struct, error_code alias
    ├── result_core.h             # Result<T> class definition
    ├── optional.h                # Optional<T> class
    ├── result_funcs.h            # Factory/helper functions (ok, make_error)
    ├── error_codes_compat.h      # Backward compatibility aliases
    ├── exception_conversion.h    # exception_mapper, try_catch utilities
    └── result_macros.h           # Convenience macros

Documentation Updates

  • Updated BEST_PRACTICES.md with new header structure and include strategies
  • Updated CHANGELOG.md with change description

Benefits

  1. Improved Compilation Times: Consumers can include only needed headers
  2. Better Maintainability: Each header has a focused responsibility
  3. Clearer Dependencies: Explicit header organization shows relationships
  4. Full Backward Compatibility: Existing #include <.../result.h> unchanged

Test Plan

  • All 107 existing tests pass
  • Build succeeds on macOS with CMake
  • Backward compatibility verified via umbrella header

Closes #243

Split 913-line result.h into focused sub-headers under result/ directory
to improve compilation times and maintainability:

- result/fwd.h: Forward declarations and result_state enum
- result/error_info.h: error_info struct and error_code alias
- result/result_core.h: Result<T> class definition
- result/optional.h: Optional<T> class
- result/result_funcs.h: Factory and helper functions
- result/error_codes_compat.h: Backward compatibility aliases
- result/exception_conversion.h: try_catch utilities
- result/result_macros.h: Convenience macros

result.h becomes an umbrella header that includes all sub-headers,
maintaining full backward compatibility with existing code.

Closes #243
@kcenon kcenon merged commit 0605442 into main Dec 28, 2025
20 checks passed
@kcenon kcenon deleted the refactor/split-result-header branch December 28, 2025 09:20
kcenon added a commit that referenced this pull request Apr 13, 2026
Split 913-line result.h into focused sub-headers under result/ directory
to improve compilation times and maintainability:

- result/fwd.h: Forward declarations and result_state enum
- result/error_info.h: error_info struct and error_code alias
- result/result_core.h: Result<T> class definition
- result/optional.h: Optional<T> class
- result/result_funcs.h: Factory and helper functions
- result/error_codes_compat.h: Backward compatibility aliases
- result/exception_conversion.h: try_catch utilities
- result/result_macros.h: Convenience macros

result.h becomes an umbrella header that includes all sub-headers,
maintaining full backward compatibility with existing code.

Closes #243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Split large header files for improved compilation and maintainability

1 participant