DEV Community

Ricardo Costeira
Ricardo Costeira

Posted on

Package by feature vs. feature by module

Hi everyone,

Lately I've been wanting to start a new personal Android project, and after attending a GDG DevFest event I finally found the inspiration to do so.

I'm used to organize everything following a "package by feature" logic, but I've read some articles recently where people were talking about having each feature in its own independent module.

Now, architecturally speaking, this seems like a really good option (high cohesion, loose coupling, feature reuse and all that), but probably due to the fact that I'm used to monolithic Android apps (with well defined boundaries between components though), I'm struggling to not see this as an overkill.

Do any of you have any experience with this? Or can you see any disadvantages? I'm figuring dependency injection and navigation might become a challenge to do in a clean way.

I'll probably end up doing it just to try it on my own, but I would like to hear your thoughts on this. Thanks! :)

Top comments (2)

Collapse
 
johnson_cor profile image
Corey Johnson

I think I heard somewhere that it's recommended to divide features into modules if you're planning on utilizing instant apps, however I'm not sure if that's still relevant.

As far as packaging by feature or feature by module: I've always tried to keep data and business logic in it's own module while housing the rest of it in an app module.

If you do end up packaging by module I'd be eager to see how you approach it!

Collapse
 
rcosteira79 profile image
Ricardo Costeira

Didn't even thought about instant apps. That makes sense!

As for your approach, I've seen it really shine in a company where I used to work, where there are a bunch of products that share parts of the business logic for user management and permission handling. It's was rather complex logic, so having everything in the same place really helped a lot.

Sure, I'll try to write about it if I do go forward with the idea :) Thank you for answering!