In my class, i am creating a new token and calling service method which then delete a token. Instead of creating a new instance, generating new token and then calling service method, can i just create a new token in constructor and then call service method at the same time?
All the methods in GCService class require token to perform some operation like get balance, verify customer and etc.
I have read that it is legit to call non virtual methods in constructor. I have never used this approach before so not sure if its a normal practise and can this be improved?
Public Class Customer : Implements ICustomer
{
//creating a new instance , setting class properties in constructor and then calling class method.
Dim result = New GCService(a,b).GetBalance(a);
}
public class GCService : IGCService
{
private
string Token { get; set; }
//constructor
public GCService(string _a, string _a)
{
//set some properties and get token
Token = GetToken(_a, _b);
}
private string GetToken(string a, string b)
{
//get token and return response
return response;
}
}