-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document everything #52
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Zoe 🙂 thank you for this!
So allot of seemingly strange layout and structure choices come from us using a blend of a few architecture patterns.
I started writing a review with notes on why we made certain decisions, but I think the fastest and best approach will be hopping on a call sometime this week and do a walk-through review / handover.
src/utils/config.rs
Outdated
@@ -1,24 +1,36 @@ | |||
//! Definitions for configuration of the service. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel "Definitions" is completely accurate, as this also has behavior implementation for how the config will be loaded. Goes back to these being secondary adapters wrapping external utilities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thank you Zoe! 2 small changes and 1 comment, but otherwise merge when ready 🙂
023d9dc
to
d66f2e6
Compare
This documents just about everything possible, to make future work easier. It's best to proofread this locally using
cargo doc --no-deps --open
and read through it on the webpage.My understanding of how this was structured grew as a wrote it so I'd appreciate any corrections of anything I said erroneously I didn't understand and forgot to go back and correct.
I also have some notes for future development not relevant to this PR, but fit here because I noticed them while working. Feel free to disagree (probably probably on Matrix). I'll work on refactoring them later if they seem good:
notes:
Don't store Snap ID every time in Ratings
Clean up modules (in particular put trait impls in the same module as the struct they're doing an impl on)
Borrow more instead of cloning
A lot of free functions should probably be added to the thing they create. The stuff in
use_case
is also confusingin how it just delegates to
interface
Similarly things like
ratings_band
is more idiomatically animpl
onVoteSummary
called [to_ratings_band
] or somesuchA lot of things can be coverted to
impls
on structs from the protobuf object (e.g.build_service
can beimpl
d on the protobuf object from another module instead of a free function, and is more idiomatic that way)No reason to separate
use_cases
andinfrastructure
unless I'm missing somethingIn library code, good to derive more not less. At minimal most things should derive Clone, Copy (if possible), Debug, PartialEq, Eq,
and Serialize/Deserialize. Unused derives will be compiled out.
Imports I normalized to
Likewise modules I normalized to
A lot of the failable
new
functions should probably betry_new
but probably not a big dealA lot of things (e.g. URIs) should probably be bespoke types (e.g.
std::https::uri
) or use their types defined elsewhere (e.g.ClientHash
) instead of just Strings. More idiomatic, less error prone, more self-documenting