https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
u

ursus

07/27/2020, 5:17 PM
why not split it into
:payments
:payments-ui
?
p

pardom

07/27/2020, 5:24 PM
That's what I'd recommend:
Copy code
:payments
:payments:android
:payments:core
:payments:data
:payments:view
u

ursus

07/27/2020, 5:48 PM
the first line is just a folder? or does it have code
where do viewmodels and fragments/controllers/whatever live in this?
-- and to sum it up, you basically say feature modules dont exist?
p

pardom

07/27/2020, 6:00 PM
The first is just a folder, but you can give it a
build.gradle
that includes the other projects.
fragments -> android, controllers -> view
u

ursus

07/27/2020, 6:27 PM
do you split each (android, core, data, view) module into api (interfaces) and impl? as to avoid circular dependencies?
say you want to share some part of ui, like "binder" of Foo ojbect to piece of ui, where would you stick it?
my classic example is I have playments screen, there is a piece of ui bound to ppayment object; and this piece of ui is also on a dashboard of the app (so two places)
p

pardom

07/27/2020, 6:29 PM
do you split each (android, core, data, view) module into api (interfaces) and impl? as to avoid circular dependencies?
Yes to isolate and enforce dependency rules
For shared UIs
Copy code
:core:android // common Android which features may depend on
u

ursus

07/27/2020, 6:30 PM
so technically it is
Copy code
:payments
:payments:android:api
:payments:android:impl
:payments:core:api
:payments:core:impl
:payments:data:api
:payments:data:impl
:payments:view:api
:payments:view:impl

 ?
p

pardom

07/27/2020, 6:30 PM
Ah, I see
u

ursus

07/27/2020, 6:31 PM
coreandroid? I thought you mean those two live on the same level
p

pardom

07/27/2020, 6:32 PM
I define APIs in
:feature:core
and implementations either in
:feature:data
for platform agnostic implementations (e.g.
<http://java.net|java.net>
) and
:android:data
for Android specific implementations (e.g.
<http://andorid.net|andorid.net>
)
u

ursus

07/27/2020, 6:33 PM
hm, and who do you then depend on, in some other module
p

pardom

07/27/2020, 6:33 PM
Eh,
:common
then.
Copy code
:common
:common:android
:common:core
:common:data
:common:view
u

ursus

07/27/2020, 6:33 PM
whats common? junkdrawer?
p

pardom

07/27/2020, 6:34 PM
Code you'd use across features.
u

ursus

07/27/2020, 6:34 PM
so youd have PaymentsRepository and MessageRepository etc in there?
as opposed to :payments and :messages modules?
p

pardom

07/27/2020, 6:34 PM
Also, in KMP project you might have
Copy code
:feature:ios
:feature:desktop
...
u

ursus

07/27/2020, 6:35 PM
feature = placeholder?
p

pardom

07/27/2020, 6:35 PM
Yeah
u

ursus

07/27/2020, 6:35 PM
k -- but I still dont understand the common module, unless its a junkdrawer
if you were to have payments code in common, then if you were to create a 3rd app, and that would not need payments, but would need something else from common, it would get payments as well
p

pardom

07/27/2020, 6:37 PM
It's for whatever you need across feature modules. For example, common types in
:common:core
(e.g.
User
,
Either
, etc), common Views in
:common:android
, etc.
u

ursus

07/27/2020, 6:37 PM
well, whats a feature, why is User not a feature?
p

pardom

07/27/2020, 6:38 PM
🤷🏼‍♂️ that part is up to you.
u

ursus

07/27/2020, 6:38 PM
my point was that everything is a feature, so nothing isa feature, and lets just call it modules, whatever
so the new app can actually pick and chose stuff it needs
in your project, do you have multiple apps or just one?
p

pardom

07/27/2020, 6:41 PM
Typically just one.
u

ursus

07/27/2020, 6:45 PM
whats the point of modularization when theres no code sharing
p

pardom

07/27/2020, 6:47 PM
Isolation, build times, scalability and large teams.
☝️ 2
u

ursus

07/27/2020, 6:50 PM
sure, but thats self imposed mostly, actually sharing code would lead to different design I believe
like that android specific module, I dont see how is it relevant -- unless KMP
p

pardom

07/27/2020, 6:52 PM
In that case modularization is a tool to enforce a dependency rule.
u

ursus

07/27/2020, 6:55 PM
true, thats why common module is a anti-pattern mostly
b

brandonmcansh

07/30/2020, 5:58 PM
I would personally split models into it's own models module. Each feature module own it's viewa and data handling in isolation
u

ursus

07/30/2020, 6:21 PM
^^ so if you need to the data handling in the another ui, other than the one youre in, would you only then split it into -data, -ui?
2 Views