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

Add Show trait for printing records as zonefiles #379

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

tertsdiepraam
Copy link
Contributor

@tertsdiepraam tertsdiepraam commented Aug 30, 2024

No description provided.

@tertsdiepraam tertsdiepraam changed the title Add Present trait for printing records as zonefiles Add Show trait for printing records as zonefiles Sep 4, 2024
pub type Result = std::result::Result<(), Error>;

/// Show a value as zonefile format
pub trait Show {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pick a name that has something to do with zonefile format. How would anyone guess that 'Show' means zonefile format? It's not like the name has to be short. For example, ToZonefileFormat would be a lot more desciptive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trait creates data in presentation format and I think ‘show’ is a pretty good verb for that. It is also consistent with the related traits in the crate. We have “parse“ and “compose” for dealing with wire format and “scan“ and now “show” for presentation format.

Copy link
Contributor Author

@tertsdiepraam tertsdiepraam Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short version: because I bikeshedded this endlessly with Martin.

We figured that this would be a good companion to Scan and that other options would be very verbose. We'd then have parse, compose, scan and show none of which refer to what they're really parsing/displaying and it doesn't seem to matter much. Present would be better if it didn't have too many other meanings ("gift" and the tense).

Also we tried to keep it a verb.

That being said, I'm happy find and replace the names if we shed bikes further. Naming things continues to be hard :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment race condition 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with your notion that names must be (or, indeed, can be) fully self describing. That sort of thing leads to long, complicated names and people having assumptions about how things work.

These concepts are very fundamental to what this crate is providing, so I think giving them short designators and provide a thorough definition of what they do is a good approach. You look this up in the documentation and then remember that “show” means printing in presentation format.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has taken until now to discover that we don't actually have a way to write zonefile format and that using Display for that has issues.

So it seems that this feature may be fundamental, but is not commonly used. Features that are rarely used benefit from longer names that are more descriptive. The whole point of this feature is to generate zonefile format. So the name can include that without being overly specific.

This feature is introduced because the intent is to not show the output (to a user). We already have Display for showing output. This feature is a specific text-based encoding that is meant to be used by other software. Obviously, expert users can look at text-based encodings. But that is not the main purpose. Some fields that could have been mnemonic have to be output as numbers because that is what zonefile format requires. Again a good hint that the purpose is not to show that output to a user.

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.

3 participants