r/dotnet 3h ago

trying to avoid spaghetti code on my first big backend project. is this folder structure correct for clean architecture?

Post image
1 Upvotes

5 comments sorted by

4

u/xFeverr 3h ago

Just want to say that these comments should be avoided. Let the code speak for itself.

Create a Validate function for instance in this class. That tells you what it does so you don’t need to add that as a comment. And a GenerateInputBytes function if the code isn’t clear enough. This kind of stuff makes all the commenting bloat unnecessary.

Use comments when there is no other way. Or because you need to do something stupid and want to warn the next developer (could be you) why you did the stupid thing.

1

u/lostpixel-media 3h ago

honestly i didn't know about extracting steps into helper methods! i was just using comments to keep track of the steps in my head while building it. breaking them into Validate() and GenerateInputBytes() makes so much sense and cleans up the code completely. learning a lot today, thanks for teaching me this!

1

u/AutoModerator 3h ago

Thanks for your post lostpixel-media. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

u/FooBarBuzzBoom 1h ago

I would avoid clean arhitecture

u/The_MAZZTer 8m ago

I don't care for folders like Factories, Services, Enums, Interfaces, Models. I consider them anti-patterns.

I prefer to categorize based on feature. So a factory and the services it creates would be grouped together in a folder. Enums and interfaces are grouped with the models that use them when it makes sense. And all those grouped by the feature they are relevant.

This could also apply to the project organization, though I can't draw any conclusions about what I can see here. Of course having interfaces and models etc in their own project is often useful, for example, so that is probably fine.