How to Reuse Use Cases Across Different Modules in a Modular Android App? - Stack Overflow

I have a modular Android application following Clean Architecture, where each module is responsible for

I have a modular Android application following Clean Architecture, where each module is responsible for a specific feature.

I have a Recipe Module that...

  • ... fetches recipe data from the server based on ID search or general search.

  • ... passes data through the Repository → Use Case → Presentation Layer.

Now, I have a Profile Module, which contains a section called Favorite Recipes. This section also needs to fetch recipes by ID, similar to how the Recipe Module does.

My Problem

Since the Recipe Module already has the logic for fetching recipes, should I rewrite the same logic in the Profile Module, or is there a way to reuse the existing logic without making the Profile Module tightly coupled with the Recipe Module?

Current Structure:

  • recipe-domain (Use Cases, Repository Interface, Models)

  • recipe-data (Repository Implementation, Network Calls, DB)

  • recipe-ui (Screens, ViewModels)

  • profile-module (has Favorite Recipes section)

I want the Profile Module to reuse the recipe fetching logic without depending on the entire Recipe Module (which includes UI components).

Now::

Should the Profile Module depend directly on the Recipe Module, or should I extract a shared domain module?

How do I manage dependencies efficiently to maintain modularity and separation of concerns?

What is the best way to share Use Cases between different modules?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744837396a4596347.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信