开发者

JavaScript - Advisability of closing and returning state in a single method

My team is debating the right name for a UI framework JavaScript method that ultimately does the following:

  1. It gets the widg开发者_开发技巧ets state, if any
  2. It removes the widget from the page
  3. It returns the retrieved state so that the framework can recreate it later

The initially proposed name was 'destroy.' Some team members feel that people may not expect a method named destroy to return anything. The name 'getStateAndDestroy' is more descriptive but suggests a single responsbility principle failure.

Thoughts? Do you see this as more of a naming or design issue?


git has something very similar, with the name stash.


What about 'stow'?

Makes me think of packing it away for possible later use.


Sounds like the element/widget is being cloned and removed, to be re-created at a later point, in the process.

What about: cloneAndRemove or backupAndDestroy hmmm they're pretty similar to what you've already got though.


How about 'takeAway' or 'takeOut' or 'grab'. Also reminds me a bit of the 'pop' method on a stack. I also think 'remove' is suitable for returning what you removed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜