Names should accurately reflect their actual functionality and behavior. Avoid misleading or vague identifiers that don’t match what the code actually does.
Key principles:
allowOverwrite
instead of Rotation
when not doing true rotation)IsNetworkGateway
instead of IsGateway
to differentiate from other gateway types)WithService
instead of AddService
; if it updates cache, name it accordingly rather than GetPublicKey
Key()
instead of GetIstioEndpointKey()
when called on an IstioEndpoint)clt.Config().Service()
instead of "a"
)k
in variable names (annotation
instead of kAnnotation
)Example:
// Poor: misleading name
func (ep *IstioEndpoint) GetIstioEndpointKey() string { ... }
// Better: concise and clear
func (ep *IstioEndpoint) Key() string { ... }
// Poor: doesn't reflect actual behavior
func AddService(service *Service) WasmPluginListenerInfo { ... }
// Better: indicates non-mutating operation
func WithService(service *Service) WasmPluginListenerInfo { ... }
Enter the URL of a public GitHub repository