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

Improved naming about snapshot #12

Merged
merged 1 commit into from
Oct 19, 2024
Merged

Improved naming about snapshot #12

merged 1 commit into from
Oct 19, 2024

Conversation

petrknap
Copy link
Owner

@petrknap petrknap commented Oct 19, 2024

  • This pull request does not contain any breaking change
  • I asked the AI to briefly summarize, use and improve the feature(s), and I'm okay with the output:

Which class better informs that the object will do snapshot on each tick - A, or B?

class A {
    public function __construct(bool $listenToTicks) {}
}
class B {
    public function __construct(bool $snapshotOnTick) {}
}

Class B does a better job of making it clear that the object will take a snapshot on each tick. The constructor parameter snapshotOnTick directly conveys this intention. Clear communication in code is crucial, and B nails it. Does it resonate with your intent?

Is there any way to do it better?

Definitely. We can improve clarity and ensure the class’s purpose is immediately evident.

Consider using a more descriptive parameter name, maybe even adding a docblock to highlight the intent.

class SnapshotOnTick {
    /**
     * @param bool $enableSnapshotOnTick If true, the object will take a snapshot on each tick.
     */
    public function __construct(bool $enableSnapshotOnTick) {}
}

Here, the class name SnapshotOnTick combined with the parameter enableSnapshotOnTick makes it abundantly clear what the class is designed to do. Adding a docblock ensures that future developers understand the exact behavior and purpose of the parameter.

How does that feel? Clearer, right?

@petrknap petrknap force-pushed the snapshot-on-tick branch 3 times, most recently from 3f0c8b5 to ee0c65b Compare October 19, 2024 11:49
@petrknap petrknap marked this pull request as ready for review October 19, 2024 11:50
@petrknap petrknap merged commit 0fdf9d7 into main Oct 19, 2024
2 checks passed
@petrknap petrknap deleted the snapshot-on-tick branch October 19, 2024 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant