I have a function that takes in a bool, shown below:
public void LoadEndPoints(bool mock)
{
}
I can call this via LoadEndpoints(true) or LoadEndpoints(false), but this can be a bit hard to understand, as you need to know what true/false represents. Is there a way to pass the parameter name and value to a function such as LoadEndPoints(mock = true)?
LoadEndPoints/LoadMockedEndPointsor; 2) Take in a enumeration (or other type) that conveys more meaning:LoadEndPoints(EndpointMode.MockOnly)or; 3) Move the configuration to a [class-level] setting:var epl = new EndPointLoader { Mock = true }; epl.LoadEndPoints(); etc.mockparameter. Perhaps the name could be expanded (e.g.mockOnly), but otherwise I think it's generally "ok". There are many methods that takebooltypes and it's up to the caller to know how to call the method correctly.