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

🧑‍💻 Clean code for improving readability and stability #522

Open
neon-mmd opened this issue Feb 14, 2024 · 2 comments
Open

🧑‍💻 Clean code for improving readability and stability #522

neon-mmd opened this issue Feb 14, 2024 · 2 comments

Comments

@neon-mmd
Copy link
Owner

What would you like to share?

Work Expected From The Issue

Improve the readability and stability of code by making the following changes listed below:

  • Use constant and static data types for values directly used within the code.

For example:
In the code below, the 3.14 value is used directly. So we can move into a constant data type declaration (as shown in the code snippet below the previous one).

fn calculate_area_of_circle(radius: u32) -> f32 {
	3.14 * radius * radius
}
const PI: f32 = 3.14;

fn calculate_area_of_circle(radius: u32) -> f32 {
	PI * radius * radius
}
  • Use std::cell::OnceCell for declaring constant data types by constructing the value once before use. Similarly, std::sync::OnceLock for declaring mutable static data types by constructing the value once before use.

  • Rename functions, structs, enums, etc. according to the Rust convention.

  • Replace &Option<T> to Option<&T> to stabilize the function signatures to reduce introducing breaking changes to the Codebase.

For more information on how making this change can stabilize function signature. See:

https://piped.video/watch?v=6c7pZYP_iIE

Reasoning Behind The Proposed Changes

The reasoning behind the following changes is to improve the readability and stability of code, which can drastically improve developer experience and avoid unintentional breaking changes.

Do you want to work on this issue?

None

Additional information

No response

Copy link

The issue has been unlocked and is now ready for dev. If you would like to work on this issue, you can comment to have it assigned to you. You can learn more in our contributing guide https://github.com/neon-mmd/websurfx/blob/rolling/CONTRIBUTING.md

@neon-mmd neon-mmd changed the title ♻️ Idiomatic code for improving readability and stability 🧑‍💻 Idiomatic code for improving readability and stability Feb 14, 2024
@neon-mmd neon-mmd changed the title 🧑‍💻 Idiomatic code for improving readability and stability 🧑‍💻 Clean code for improving readability and stability Feb 14, 2024
Copy link

Stale issue message

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2024
@neon-mmd neon-mmd reopened this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant