Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to write code to access an API.
In that API there's an "either add or update" method for an object.
Whether you're adding or updating that object, you provide an ID. If that ID is found in their database, then you're updating that object. If not, you're adding it.
What would you call your subroutine which either added or updated a Widget?
Would you call it: addOrUpdateWidget() because that at least matches their API call (longwinded names are all over the place).
Would you have two subroutines addWidget() and updateWidget() to make it more transparent what the user was trying to do, and let you give a warning "you thought you were updating a Widget! Turns out you added it instead."?
Would you call it just widget()?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Subroutine naming convention/style
by kcott (Archbishop) on Oct 07, 2015 at 06:13 UTC | |
|
Re: Subroutine naming convention/style (set, config)
by tye (Sage) on Oct 07, 2015 at 04:45 UTC | |
|
Re: Subroutine naming convention/style
by Your Mother (Archbishop) on Oct 07, 2015 at 12:09 UTC | |
|
Re: Subroutine naming convention/style
by dsheroh (Monsignor) on Oct 07, 2015 at 09:05 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |