Utils or Helpers
March 19, 2024
When to use helpers and utils? Here is my rule of thumb.
helpersare specific to a project and are not usually reused across different projects.utils, on the other hand, are used for general purposes and can be reused across multiple projects.
Consider the following example:
- The
validatePasswordfunction can be a helper. This is because the criteria for password validation can vary significantly across different projects, often depending on specific business requirements. - A function like
formatDatecan be a utility. Because it offers functionality to format dates in various ways, making it suitable for different projects.