Skip to content

Standardize private/public method naming conventions#439

Merged
ocots merged 1 commit into
developfrom
feature/private-public-methods
Jun 8, 2026
Merged

Standardize private/public method naming conventions#439
ocots merged 1 commit into
developfrom
feature/private-public-methods

Conversation

@ocots

@ocots ocots commented Jun 8, 2026

Copy link
Copy Markdown
Member

Overview

This PR standardizes the naming conventions for private and public methods across CTBase.jl, following the newly documented conventions in dev/philosophy/modules.md.

Changes

Documentation Updates

  1. dev/philosophy/modules.md — Added explicit naming conventions:

    • symbolpublic: exported via export; part of the documented API
    • _symbolprivate helper: unexported; internal implementation detail
    • __symboldefault value: unexported; provides a replaceable semantic default
  2. dev/planning.md — Improved checkpoint templates:

    • MCP get_test_command preferred for running tests
    • Fallback commands provided for when MCP is unavailable
    • Clear distinction between phase-specific and full-suite checkpoints

Code Refactoring

  1. src/Descriptions/ — Renamed private helper functions:

    • compute_similarity_compute_similarity
    • find_similar_descriptions_find_similar_descriptions
    • format_description_candidates_format_description_candidates
  2. src/Exceptions/display.jl — Renamed private helper functions:

    • extract_user_frames_extract_user_frames
    • format_user_friendly_error_format_user_friendly_error
    • ansi_color_ansi_color
    • ansi_reset_ansi_reset
    • print_ansi_styled_print_ansi_styled
  3. src/Extensions/Extensions.jl — Confirmed __display as a default value (double underscore convention)

Test Updates

  1. test/suite/descriptions/test_similarity.jl — Updated all calls to renamed functions

  2. test/suite/exceptions/test_display.jl — Updated calls to renamed functions

  3. test/suite/extensions/test_extensions_enriched.jl — Fixed extension stub testing:

    • Added fake types (FakeDocumenterReferenceTag, FakeCoveragePostprocessingTag, FakeTestRunnerTag)
    • Follows testing-creation.md §6 to prevent flaky tests when extensions are loaded elsewhere
    • Removed conditional UndefVarError checks in favor of deterministic fake types

Rationale

The naming convention clarification makes the intent of each symbol explicit:

  • Public symbols are exported and documented
  • Private helpers (_prefix) are internal implementation details
  • Default values (__prefix) are semantic defaults that can be overridden by extensions or subtypes

This aligns with the broader effort (PR #438) to improve code organization and documentation across the control-toolbox ecosystem.

Testing

All affected test suites pass:

  • test/suite/descriptions/test_similarity.jl
  • test/suite/exceptions/test_display.jl
  • test/suite/extensions/test_extensions_enriched.jl

- Add naming conventions to modules.md: symbol (public), _symbol (private helper), __symbol (default value)
- Rename private functions in Descriptions: compute_similarity → _compute_similarity, find_similar_descriptions → _find_similar_descriptions, format_description_candidates → _format_description_candidates
- Rename private functions in Exceptions: extract_user_frames → _extract_user_frames, format_user_friendly_error → _format_user_friendly_error, ansi_color → _ansi_color, ansi_reset → _ansi_reset, print_ansi_styled → _print_ansi_styled
- Update planning.md with improved checkpoint templates (MCP preferred, fallback commands)
- Fix extension tests to use fake types per testing-creation.md §6 (prevents flaky tests when extensions are loaded elsewhere)
@ocots

ocots commented Jun 8, 2026

Copy link
Copy Markdown
Member Author

Summary of Changes

This PR addresses the "Private/public method naming and distribution" item from PR #438's planned features.

What was done

  1. Documented naming conventions in dev/philosophy/modules.md:

    • symbol (no prefix) → public, exported, part of documented API
    • _symbol (single underscore) → private helper, internal implementation detail
    • __symbol (double underscore) → default value, replaceable semantic default
  2. Renamed private helper functions to follow the _prefix convention:

    • In Descriptions: compute_similarity, find_similar_descriptions, format_description_candidates
    • In Exceptions: extract_user_frames, format_user_friendly_error, ansi_color, ansi_reset, print_ansi_styled
  3. Improved planning documentation with better checkpoint templates (MCP-first approach)

  4. Fixed extension stub testing to use fake types per testing-creation.md §6, preventing flaky tests when extensions are loaded elsewhere in the test suite

Impact

@ocots
ocots merged commit bea4592 into develop Jun 8, 2026
6 checks passed
@ocots
ocots deleted the feature/private-public-methods branch June 8, 2026 17:06
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.

1 participant