Open yesmeck opened 8 years ago
Looks to me like /utils
is a place where you can place small snippets you can use throughout the application. Small functions to build bigger things with.
/helpers
is more of a place where you store code architectural snippets in my view. Things essential for bootstrapping components and developer ergonomics.
Looks to me like
/utils
is a place where you can place small snippets you can use throughout the application. Small functions to build bigger things with.
/helpers
is more of a place where you store code architectural snippets in my view. Things essential for bootstrapping components and developer ergonomics.
Hi @janhoogeveen, thanks for the answer. I couldn't quite grasp it, could you please explain in other form? Thank you :D
I've run into this "issue" too while trying to structure a project. Here's how it fits me better:
index.js
is the point of entry. It require
s the modules in /modules
/modules
contains the getAll.js
and getById.js
modules/libs
holds the individual steps a given module calls/utils
has very short and specific functions used throughout functions in /libs
I just search "helper vs utils" on google and found the issue. I got the wanted answer at StackOverflow, so let me show the URL of the question at StackOverflow: What are the differences between Helper and Utility classes?
In short, the answer is:
A Utility class is understood to only have static methods and be stateless. You would not create an instance of such a class. A Helper can be a utility class or it can be stateful or require an instance be created. I would avoid this if possible.
Hope it helps someone 😄
 | Helper Functions/Classes | Utility Functions/Classes -- | -- | -- Purpose | Provide support or aid to other parts of the program | Perform common or generic operations that are not tied to any specific part of the program Scope | Typically used within a specific module or part of the program | Can be used throughout the program or in multiple programs Dependencies | Often depend on other parts of the program or external libraries | Usually independent of other parts of the program Examples | Form validation functions, data formatting classes | String manipulation functions, math librariesNice and comprehensive explanation @pedronastasi
Is it a good practice to put the constant file inside utils folder ?
@sktsourav you can create a "constants" folder and keep your constants.js file inside it. Better still you can have an index.js file inside there then have a different files for different contexts and export them from index.js. This would help you keep all your constants in a centralized place whenever you decide to create constant values for different modules in your application.
I mean the
src/helpers
andsrc/utils
folder, what files should put in helpers folder, what should in utils folder?