Always reuse existing defined constants, resources, and reusable components instead of duplicating values or creating redundant implementations. This improves maintainability, ensures consistency across the codebase, and reduces the risk of introducing inconsistencies when values need to be updated.
Key practices:
{StaticResource StandardControlMaxWidth}
instead of hardcoding values like “1000”SettingsStackStyle
and PivotStackStyle
if they’re identical)Example of good practice:
<!-- Good: Reuse existing resource -->
<muxc:BreadcrumbBar MaxWidth="{StaticResource StandardControlMaxWidth}" />
<!-- Bad: Hardcode the same value -->
<muxc:BreadcrumbBar MaxWidth="1000" />
Example for C++ constants:
// Good: Move constant into function scope to avoid duplication
uint64_t rapidhash_withSeed(const void* key, size_t len, uint64_t seed) {
static const uint64_t rapid_secret[3] = { /* values */ };
// use rapid_secret here
}
// Bad: Global constant duplicated in every compilation unit
static const uint64_t rapid_secret[3] = { /* values */ };
This approach reduces maintenance burden and ensures consistent behavior across the application.
Enter the URL of a public GitHub repository