During the development of an Angular 2 app involving multiple calculation services, I encountered some interesting questions:
- Is it beneficial to use static in an Angular service provided on the application level? Or is it unnecessary?
- How does a static method impact performance when multiple objects simultaneously call the same static method hundreds of times? Is the method instantiated more than once?
Below is a snippet from the class that houses various calculation methods and is instantiated on the 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 {
...
}
}
Any insights would be greatly appreciated. Thank you.