Skip to content
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

Opinion on code structure #1

Open
lil5 opened this issue Nov 6, 2022 · 4 comments
Open

Opinion on code structure #1

lil5 opened this issue Nov 6, 2022 · 4 comments

Comments

@lil5
Copy link

lil5 commented Nov 6, 2022

Found your project on the fediverse

https://mastodon.social/@golang_discussions/109294976193078757

Here's my take:

  1. Move the contents of types.go in to dff.go
  2. Remove the DuplicateFilesFinder interface and make Find a pure public function
  3. Move the anonymous function of walk dir to a private function to keep complexity down.
  4. State the project license in your readme.

YAGNI

@nilesh-akhade
Copy link
Owner

nilesh-akhade commented Nov 6, 2022

Reiterating your suggestion with reasons, which may be wrong. Please correct if needed.

  1. Unless there are more than half-dozen domain model structs. Don't put them in a separate file.
  2. If there's only one implementation of the interface. Don't add the interface, it does not add any value.
  3. If an anonymous function consists of more than 6 lines. It should be named.
  4. Isn't the LICENSE file enough? GitHub even detects it and shows the license details on the project homepage.

@nilesh-akhade
Copy link
Owner

@lil5: Updated the code, as suggested. a9f2220

@lil5
Copy link
Author

lil5 commented Nov 6, 2022

You seem to be more interested in engineering structure than minimizing complexity.

YAGNI: You Ain't Gonna Need It

Forcing an arbitrary maximum size doesn't work if it all deals with the same action.

Seeing code as steps that must be completed helps writing those major steps as comments, then writing the code below each, and where necessary adding separation.

@nilesh-akhade
Copy link
Owner

Apologies, I am having a hard time understanding your comment.

Forcing an arbitrary maximum size

What is this about?

writing major steps as comments

My guess is it is about my todo about complicated duplicate-detection logic. Do you think it should be okay if we just explain the logic in code comments? No need to refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants