I need help in determining if I should use a shared function or not. I should use a shared function if the value returned applies to the entire application, because a shared variable is stored in memory only once. If that is true, then I suppose my answer is no, I should not be using a shared function.
Right now I have shared function that returns a string based on what parameters are passed. If the page that uses this code is viewed by multiple people at once, will the function produce undesirable results?
Public Shared Function ToFeaturelHTML(ByVal has As Boolean, ByVal feature As String)
If has = True Then
Return String.Format("<li class='feature yes'>{0}</li> ", feature)
Else
Return String.Format("<li class='feature no'>{0}</li> ", feature)
End If
End Function
The function you provide does not access any shared state (i.e. it's not using any shared variables). Every call will use its own copy of both parameters ("has" and "feature"). Plus, inside your function you are calling a shared function of String, which is a thread safe type.
In these conditions, your function will not produce any undesirable results when accessed from multiple clients.
Hope this helps!