This topic contains 4 replies, has 4 voices, and was last updated by
October 19, 2017 at 6:00 am #82444ParticipantPoints: 21Rank: 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.
October 19, 2017 at 6:08 am #82445ParticipantPoints: 154Rank: Participant
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". 😉
October 19, 2017 at 8:06 am #82450ParticipantPoints: 21Rank: 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.
October 19, 2017 at 2:07 pm #82478KeymasterPoints: 1,638Rank: 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.
October 19, 2017 at 10:46 pm #82579ParticipantPoints: 21Rank: 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.