Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving code readability through centralized Color definitions #733

Closed
vigotskij opened this issue Dec 14, 2023 · 3 comments
Closed

Improving code readability through centralized Color definitions #733

vigotskij opened this issue Dec 14, 2023 · 3 comments
Labels
devx Work that will improve developer experience/velocity good first issue Good for newcomers

Comments

@vigotskij
Copy link

Description:

Currently, color declarations in the codebase are scattered throughout, utilizing plain text to represent hex color codes. This practice, while functional, tends to compromise code readability and maintainability. I propose a more structured and comprehensible approach by introducing a dedicated file that contains a Color class extension.

Proposed Solution:

1. Centralized Color Definitions:

Create a centralized file, perhaps named Colors.swift, to house a Color class extension. This extension will define colors using meaningful names, such as "primaryText," "primaryButton," "secondaryButton," etc. This approach not only imparts semantic meaning to color usage but also consolidates color declarations in a single location.

2. Improved Readability:

Utilizing a centralized color definition file enhances code readability by providing developers with a clear and concise reference for color choices. This becomes especially advantageous when maintaining a consistent color scheme across the entire application.

3. Ease of Maintenance:

Centralized color definitions simplify maintenance tasks. If a color scheme update is required or if there's a need to ensure color consistency, developers can conveniently refer to and modify the Colors.swift file instead of scouring the entire codebase for individual color declarations.

4. Consistent Naming Conventions:

Establishing a naming convention for colors, as achieved through the Color class extension, fosters consistency. Developers can quickly understand the purpose of each color, reducing ambiguity and the likelihood of color-related errors.

Objective:

The goal is to enhance code readability, maintainability, and consistency by transitioning from scattered hex color code declarations to a centralized Colors.swift file containing a Color class extension with semantically meaningful color names.

@joshuatbrown
Copy link
Contributor

@vigotskij thanks for this suggestion -- we've done some of this with SwiftGen but there are still places we have hex codes. I'm moving this into our Backlog so we can prioritize it.

@joshuatbrown joshuatbrown added the devx Work that will improve developer experience/velocity label Jun 4, 2024
@joshuatbrown joshuatbrown added the good first issue Good for newcomers label Aug 2, 2024
@joshuatbrown
Copy link
Contributor

This is done now -- thanks again for the suggestion, @vigotskij!

@vigotskij
Copy link
Author

This is done now -- thanks again for the suggestion, @vigotskij!

No problem! Glad to be of help 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devx Work that will improve developer experience/velocity good first issue Good for newcomers
Projects
Archived in project
Development

No branches or pull requests

2 participants