I saw lots of projects that use that kind of file. It usually contains functions that are required from lots of places in the code. It seems logicality to save code from the number of classes and namespaces that contain one or two functions. But on the other hand it makes code less separated into logical parts that can make harder understanding of structure of project. So what is my question about. Is it good or bad to have such file in project?
The language I use is c++ but it seems the question refers to any programming language.
Whether or not a utils file is bad practice is depending on many factors. Other factors are (and the list is not exhaustive and likely subject to opinions of different individuals):
Conclusion : if it is good or bad is heavily depending on the broader context and on the content of the file in question. The rules of clean code always apply. The idea of putting utility functions in separate files is common practice, but they are only useful if they are structured very well so people find there way to them, and in them easily. If this is ok, people will use them. Otherwise people will not use them, and you will still end up with many utils files that still contain a lot of duplication with slightly varying implementations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With