Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

Question about package stucture

Open japplin opened this issue 8 years ago • 5 comments

The purpose of this repo is to demo what using uncle bob's clean coding principles looks like on android but, doesn't the package structure completely go against what he suggests. Packages shouldn't be named presenters or views, MVP is a pattern not a specific part of the application. Instead, I believe that each activity should be in its own package with all of its components(presenter, interactor ...). This also has the benefit of being able to make the presenters package local. What are your thoughts?

japplin avatar Nov 26 '16 07:11 japplin

@japplin This repo is just an example and possible interpretation of Clean Architecture. You should not follow the same way, this is like understanding of @android10 of Uncle Bob's architecture.

As for naming convention again it depends. You are trying to achieve something like VIPER in Android world (ViewController)

I try to think of activity as a view. In Android SDK activity is god object, but however its main purpose to display information, so I try to delegate some parts provided by activity to specific component which should be responsible for that, for example Permission Handler, Context...

Your proposal also have a lot of benefits, personally I've used approach of acting Activity as Fragment container and in this case one module contained one activity and a lot of Fragments.

You can implement your idea and share your experience with others, it would be great.

CROSP avatar Dec 03 '16 20:12 CROSP

You're right, @android10 has address this in this talk. He said something like,

Do as I say, not as I do

Maybe because primary usage for this repo is to demonstrate Clean Architecture in Android, not a full blown implementation. I've been using your approach for some of my apps and it works fine.

aldoKelvianto avatar Dec 09 '16 12:12 aldoKelvianto

@aldoKelvianto exactly 😄

android10 avatar Dec 09 '16 12:12 android10

@japplin that can be interpreted in different ways but there is actually a refactor to get rid of the modules and have every feature in its own package. Neither silver bullets nor perfect solution.

Check it out: https://github.com/android10/Android-CleanArchitecture/pull/103

android10 avatar Dec 09 '16 13:12 android10

@japplin you should separate the initial directories by data, domain and presentation, but you should make sure that you separate presentation layer by features instead of activity/adapter/etc

Zhuinden avatar Mar 05 '17 17:03 Zhuinden