java - Is Utils file good practice? -
i saw lots of projects use kind of file. contains functions required lots of places in code. seems logicality save code number of classes , namespaces contain 1 or 2 functions. on other hand makes code less separated logical parts can make harder understanding of structure of project. question about. or bad have such file in project?
the language use c++ seems question refers programming language.
weather or not utils file bad practice depending on many factors. other factors (and list not exhaustive , subject opinions of different individuals):
- does contain functions logically belong together. or there functions in there don't. latter bad practice of course.
- is part of named namespace make clear purpose of utils is.
- alongside namespace structure directory structure
- unit tests show how utils working , how api supposed used users.
- if can find better name utils, means do.
- these utils file can show in many forms, service good.
- well named classes , function names, variables , ...
conclusion : if or bad heavily depending on broader context , on content of file in question. rules of clean code apply. idea of putting utility functions in separate files common practice, useful if structured people find there way them, , in them easily. if ok, people use them. otherwise people not use them, , still end many utils files still contain lot of duplication varying implementations.
Comments
Post a Comment