Skip to content

Possible improvement to method naming convention #199

@krisgesling

Description

@krisgesling

I'm sure I've had this conversation but couldn't find where - so if I'm duplicating please point it out and close this.

I've been thinking about the method names we use in formatting and wondering if we could make them more consistent and descriptive. We currently have two forms:

  1. pronounce_thing()
    I like this because it tells you what it's going to return - a human pronounceable string.
    You could argue that it is not 100% correct because the method doesn't actually pronounce the thing, it returns a string that is pronounceable.

  2. nice_thing()
    This one is a little muddier as it's used for getting either a displayable or a pronounceable string. Some methods handle both cases, others only one.

I'm wondering if it would be better to have everything named to mean either "give me a displayable version of thing" OR "give me a pronounceable version of thing". What these are I don't know. The first option that comes to mind is:

  1. format_thing_for_display()
  2. format_thing_for_speech()

Eg:

  1. format_time_for_display()
  2. format_time_for_speech()

Pro's

  • more consistent and descriptive
  • splitting the formatting of display and speech should reduce the complexity of individual methods

Con's

  • longer names (at least with my first attempt)
  • change inevitably includes some pain

This would be a big task to achieve, so I'm definitely not saying that this is what will happen, it's just come back to mind as I've been looking at a few LF PR's today and I'm interested in hearing other peoples thoughts on it.

It would clearly be a breaking change, and would split some methods eg nice_time() but we can retain all methods for some period of time while it's being deprecated, and nice_time() could call each of the new functions depending on the value of its speech argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions