Open bobwhitelock opened 5 years ago
The alternative to this is to have a class
that "owns" a particular file. Multiple classes shouldn't be accessing the same file. This indicates that there hasn't been proper separation of concerns.
If a single class owns a file, then it can define the file path internally within itself. Then all the other classes use the files "owner" as the interface to it.
Currently, some file paths are defined in
FilePath
, and others are defined inConstants
, with some metaprogramming to allow direct access to the latter via the former:https://github.com/alces-software/underware/blob/95e4fcdda0b5daf1135aae12fd12a622d069f864/lib/underware/file_path.rb#L84-L94
It would be better if we were more consistent with this, and the metaprogramming, in particular, makes it sometimes hard to work out where methods are coming from without knowing this detail of Underware. The natural place to do this would be to just move all file paths into
FilePath
, sinceConstants
is intended only for constants (and file paths can be both static and generated using method arguments).