Skip to content

When to use the static version of a method vs the non-static version #7625

Answered by ryanmio
marcusx2 asked this question in Q&A
Discussion options

You must be logged in to vote

Use static methods for utility, non-static for object state.

Static Methods

Use when operation doesn't depend on object's state.
Often more performant; no need to instantiate object.

Non-Static Methods

Use when operation depends on object's state.
Allows method chaining on the instance.

In context of authstatechanged and beforestatechanged, static methods likely recommended for state-independent utility.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by marcusx2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants