Is it okay to write a class like this:
public class AlexaApi
{
public string CreateRandomPhrase()
{
return "Hello World" //There's more code, but needless for my question
}
public object ResponseBuilder(string text)
{
//CODE HERE
}
}
But then when I use the class, call "new" each Time I want to access its functions.
new AlexaApi().ResponseBuilder(new AlexaApi().CreateRandomPhrase());
I understand that this creates two instances of the AlexaApi object and it most likely should be written like:
var alexa = new AlexaApi();
alexa.ResponseBuilder(alexa.CreateRandomPhrase());
Would it use up more memory calling "new" each time? What is the worst thing that can happen? Is it really bad form to do what is written in the first example?