While coding an app with Angular 2 and multiple calculation services I faced the following questions:
- When do I use static in a Angular service provided on application level? Is that nonsense?
- How does a static method reflect on performance? Lets say a couple hundret objects call at the same time the same static method. Is this method instantiated more than once?
This is a snap of the class, that provides me multiple calculation methods and is instantiated on application level:
@Injectable()
export class FairnessService {
constructor(){}
private static calculateProcentValue(value: number, from: number): number {
return (Math.abs(value) / Math.abs(from)) * 100;
}
public static calculateAllocationWorth(allocation: Allocation): number {
...
}
}
Thanks for helping.