Best verb for this function?

Welcome Forums General PowerShell Q&A Best verb for this function?

This topic contains 4 replies, has 4 voices, and was last updated by

1 year, 4 months ago.

  • Author
  • #82444

    Points: 96
    Rank: Member

    I have a simple function which accepts a few parameters (forename, surname etc.), does some string manipulation and outputs a suggested username, which can be passed on to something like New-ADUser. The function name will be XXX-CADUsername, but I haven't figured out the best verb yet...

    – New-CADUsername: seems wrong somehow, as it doesn't create anything beyond its own scope, just generates a string output. My understanding of New- functions is that they change system state, and usually don't return an object to the pipeline.
    – Get-CADUsername: again seems wrong, as it doesn't "get" anything, it builds/derives it
    – Build-CADUsername: seems OK, but not an approved verb

    Any thoughts? Maybe I'm wrong about "New-" as it does technically create a new string.


  • #82445

    Points: 749
    Helping Hand
    Rank: Major Contributor

    Wow ... you might overthink this question – it's just a function. 😉 I hope you know that you can get a list of valid verbs with this:

    get-verb | sort verb

    I think "Create" or "New" would fit actually because you create something new from something given. But you even could use "Join" or "Merge". 😉

  • #82450

    Points: 96
    Rank: Member

    @Olaf – I have the approved verbs, thanks. This should help me with the finer points.

    Am I overthinking – probably, but let's say someone wants to write their own version of my function next year. If the verb is misleading, that could lead to problems. For a simple function like this, it's obvious what's going on, but I can imagine other cases where the distinction is important.

    E.g. "New-EmailAddress" : does this OUTPUT an email address string based on parameters, or go off somewhere and actually WRITE a new email address to a file/database? Would "Build-EmailAddress" be better, even though it's an unapproved verb? Or perhaps the noun should just be clearer, e.g. New-EmailAddressString.

  • #82478

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    New. You're creating a new thing, even if it's just a string in a particular format. And technically, storing the email address someplace would likely be a Set, or a Write, or one of the database verbs.

  • #82579

    Points: 21
    Rank: Member

    I work with derived values frequently. The way I handle it is since the object will actually be a derived name, I add a descriptive noun while using the "get" verb. In the case above, you might consider "get-DerivedUsername". The nouns can become a little long, but tab completion works great!

The topic ‘Best verb for this function?’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort