Variable, function, and parameter names should accurately reflect their purpose, behavior, and content. Choosing descriptive names improves code readability and reduces bugs caused by naming confusion.
When naming variables and parameters:
Examples of issues to avoid:
# INCORRECT: Using "width" for height is misleading
img_height = image_processor.size.get("width", 224)
# CORRECT: Name accurately reflects the value
img_height = image_processor.size.get("height", 224)
# INCORRECT: CLI flag name doesn't match config parameter
scheduler_group.add_argument("--max-waiting-queue-length",
**scheduler_kwargs["limit_queue_length"])
# CORRECT: Consistent naming between CLI and config
scheduler_group.add_argument("--limit-queue-length",
**scheduler_kwargs["limit_queue_length"])
# INCORRECT: Name in __all__ doesn't match actual class name
__all__ = ["MoEConfig"] # But actual class is FusedMoEConfig
# CORRECT: Name in __all__ matches the actual implementation
__all__ = ["FusedMoEConfig"]
Descriptive and consistent naming serves as implicit documentation, making code more maintainable and reducing the likelihood of errors during development.
Enter the URL of a public GitHub repository