I've been trying to research this but can't see to find any recommendations. I've inherited a code base where the team is using classes with static methods instead of functions for helper methods. I've never seen this approach taken and trying to decide if I should have them go back and create functions out of them. I feel like this is unclean and bloats imports since you're importing the entire class instead of just the function you're intending?
Is one approach better than the other?
For example's sake in case I'm not being clear:
export class StringUtil {
public static alterString(str: string) {
return alteredString;
}
}
vs
export function alterString(str: string) {
return alteredString;
}
This would then be used like so:
import { StringUtil } from '../StringUtil';
getString(str: string) {
return StringUtil.alterString(str);
}
vs
import { alterString } from '../helper-functions';
getString(str: string) {
return alterString(str);
}