Closed davidbtadokoro closed 3 weeks ago
@OJarrisonn, @th-duvanel, @lorenzoberts, and/or @gabrielsrd, could you guys give me your opinions on this? The problem at hand (the messy src/
directory) is undeniable, IMHO, but I don't know if the solution I took is the best one...
I really like what you've done. Grouping those files in this lore
module (that could potentially become a separate crate, since it is completely decoupled from patch-hub)
I really like what you've done. Grouping those files in this
lore
module (that could potentially become a separate crate, since it is completely decoupled from patch-hub)
Thanks for the time and the feedback! I am going to sit this PR a little bit more as it changes a lot of the structure, but, considering your response, I will probably merge it soon.
In the same line as this PR, I was thinking of creating a module for the library crate that encompasses everything else we can call the "application" part of patch-hub
. More specifically, a module on the same level as lore
that would house the current app
, handler
, and ui
modules. The objective is to keep the binary crate as minimal as possible with only main.rs
and utils.rs
. I remember reading that this is a good practice on Rust projects (sorry if I am mistaken).
I was reading about some architectural patterns that we can use in this "application" part, and one that naturally fits the MVC-inspired architecture the tool was based on is The Elm Architecture (TEA). FWIU is basically an MVC in terms of components but with messages being generated by the handler, which enables us to chain updates before refreshing the view and allows us to reason about the application more as an FSM (with the model states being the states and the messages the transitions).
In this sense, we could rename the current app
and ui
modules to model
and view
, respectively, and name this top-level module sibling to lore
as app
. So src
would only contain lib.rs
, lore/
, lore.rs
, app/
, app.rs
, utils.rs
, main.rs
, and test_samples/
.
What do you guys think?
[What]
Create a module named
lore
in the library crate to house all domain-specific modules. This considerably cleans thesrc/
directory, with the only con of adding another nesting level to the library crate and having to collaterally update a handful of imports.[Why/Context]
Currently, the
src/
directory of the project is a mess as it is crowded with the modules defined in the library crate and the binary crate as well. Specifically, the modules from the lib crate (defined inlib.rs
) are domain-specific, i.e., they represent implementations that are significantly or entirely coupled with the Lore objects and API.In this sense, we could extract every module from the library crate (at the moment, they all live directly in
src/
) to a directorylib/
. This would result in a good clean-up, as all directories of these modules, likelore_api_client/
,lore_session/
, etc., would be encapsulated insidelib/
, but the modules themselves (lore_api_client.rs
,lore_session.rs
), would still need to be directly undersrc/
.Volume Comparison
Below are two screenshots: before
src/
before the refactor (left) and after the refactor (right). Note that we have to add two entries insrc/
for the refactor,lore.rs
andlore/
.