ADR Suggestion
Source code folder structure
#114
Replies: 2 comments 5 replies
-
I support the proposed restructuring and renaming. It makes sense and should improve maintainability. The transition can be broken into smaller steps to make the process easier. |
Beta Was this translation helpful? Give feedback.
-
This is a good thing to do with all API (user-facing) imports. This way, we can refactor/move around the actual implementation without having to modify the imports in the dependent modules. |
Beta Was this translation helpful? Give feedback.
-
General
The source code folder structure is important both from an user-experience point-of-view, but also for a maintainability point-of-view. When source code is structured into clearly distinct modules for their distinct functionalities, and when classes aren't hidden away in files with ambiguous names, it is easier for maintainers to find files and quickly gather what the purpose of the file is just from its location.
Good use of sub-modules also makes it easier for users to import their needed classes and functions and allows us to re-name things behind the scenes and provide aliases without directly interfering with the user-experience.
The current source code folder structure is confusing for both maintainers and users alike.
Current Implementation
This is the current source code folder structure of
easyscience
.Proposed Implementation
To make the source-code structure easier to navigate and less confusing, all source-files and folders should be full lowercase and each file should contain only 1 class and be named after the class it contains. The following is the suggested
easyscience
structure based on this suggestion:The unittest folder structure should mimic this structure, with the word "test" preprended to all the filenames and classes. I.e.
test_parameter
contains only 1 class: theTestParameter
class.Module imports
In each module/folder, including the root folder,, the
__init__.py
file contains the following code (snippet from thevariable
module):To ensure that
Parameter
can be imported as:Rather than:
Note that
DescriptorBase
has not been included despite being a class in thevariable
module. This is the case since it is a class which should not be imported by the user.We could then further import really critical classes to the root module, such as
Parameter
, for even easier imports. Should we do that? And which classes are then "really critical "?Beta Was this translation helpful? Give feedback.
All reactions