Back to all reviewers

Meaningful semantic naming

opencv/opencv
Based on 3 comments
Python

Choose names that clearly communicate purpose and follow consistent patterns across the codebase: 1. Use generic function names when the functionality is reusable, with parameters for specific values:

Naming Conventions Python

Reviewer Prompt

Choose names that clearly communicate purpose and follow consistent patterns across the codebase:

  1. Use generic function names when the functionality is reusable, with parameters for specific values:
    # Instead of:
    def check_have_ipp_flag(cmake_file):
        # Check specifically for HAVE_IPP flag
       
    # Prefer:
    def check_cmake_flag_enabled(cmake_file, flag_name):
        # Check for any flag
    
  2. When extending functionality that changes a method’s signature, create a new method with a descriptive name rather than modifying the existing one:
    # Instead of changing:
    corners, ids, rejected = aruco_detector.detectMarkers(img)
    # To:
    corners, ids, rejected, extra = aruco_detector.detectMarkers(img)
       
    # Create a new method:
    corners, ids, rejected, extra = aruco_detector.detectMarkersMultiDict(img)
    
  3. Apply naming conventions consistently using established patterns in the codebase rather than creating special cases. If a mechanism exists for handling naming scenarios (like namespace prefixing for functions), use it for similar cases too.
3
Comments Analyzed
Python
Primary Language
Naming Conventions
Category

Source Discussions