Eliminate redundant conditional logic, extract duplicated code, and choose simpler patterns over complex implementations. This improves code readability and maintainability by reducing cognitive load.
Eliminate redundant conditional logic, extract duplicated code, and choose simpler patterns over complex implementations. This improves code readability and maintainability by reducing cognitive load.
Key practices:
Example of simplifying redundant logic:
// Instead of:
if (textHeight > lineHeight) {
CGFloat difference = textHeight - lineHeight;
verticalOffset = difference / 2.0;
} else if (textHeight < lineHeight) {
CGFloat difference = lineHeight - textHeight;
verticalOffset = -(difference / 2.0);
}
// Use:
CGFloat difference = textHeight - lineHeight;
CGFloat verticalOffset = difference / 2.0;
Example of using existing properties:
// Instead of creating _initialProps, use existing _props:
if (_props) {
// Use _props directly
}
Enter the URL of a public GitHub repository