https://kotlinlang.org logo
k

KotlinLeaner

03/28/2023, 4:07 PM
Hi guys, I am learning architecture and modularization from basic. Some of the parts I didn't understand in architecture. I have logic for logIn, logout ...etc is using direct call with the help of Aws. I still didn't figure out where should I put this
Login
and
Logout
code. 1. Should I used this inside
viewmodel
or somewhere else? 2. Which layer is
domain
or
data
layer should I used?
Is there any example for this?
d

dewildte

03/28/2023, 4:51 PM
login
is often in it’s own module as it is generally a very complex part of the application. Many times you will see it have multiple screens and complex flows. I personally suggest treating it this way, kind of like a small application within the application.
k

KotlinLeaner

03/28/2023, 5:15 PM
Sure, I'll make a separate module called
login
inside my application/project. Which class should I used for my code i.e. viewModel or just simple class for logic ?
c

Colton Idle

03/29/2023, 2:58 AM
You can put the logic in the VM, but typically that'll get bloated after some point and you'll want to refactor into other simple classes. Like "UseCases" or similar.
k

KotlinLeaner

03/29/2023, 10:54 AM
Thanks for giving me great advice. What is 'UseCases' ?
d

dewildte

03/29/2023, 2:19 PM
A UseCase is usually an object that encapsulates a business process.
Android architecture docs have examples I encourage you to read. UseCase can also be called an Interactor in older code bases. That is also worth researching.
I highly advise you to do some more research into software architecture as it will pay off in the long run.
k

KotlinLeaner

03/29/2023, 2:23 PM
sure, I'll take a look on architecture guide on more.
I really appreciate it.
c

Colton Idle

03/29/2023, 3:26 PM
Also a valid thing to do is to build sample apps with no real architecture and see where they start falling apart.
d

dewildte

03/29/2023, 3:34 PM
That's a great idea!
c

Colton Idle

03/29/2023, 3:35 PM
yeah. when i first started i got into analysis paralysis. never built anything because i was obsessed with the right arch. after a while. the right arch starts to show itself.
you'll start seeing that having isolated fetching of data, manipulation of data, and presenting of data goes a long way
and that pretty much every arch is some variation of that
k

KotlinLeaner

03/29/2023, 3:44 PM
Sure, I'll keep in mind all these steps.. Thanks
c

curioustechizen

03/31/2023, 5:47 AM
I cannot stress enough how important Colton's point above is. In my experience, it is quite difficult to grasp all the architecture concepts if you haven't experienced first hand the problems that arise out of not having an architecture. I recommend folks to create something like a simple ToDo app with no architecture. Try to evolve it. Then you clearly see what the pain points are. That's when you start exploring the various architecture options and assess how each one solves the problems you uncovered earlier.
k

KotlinLeaner

03/31/2023, 8:03 AM
Sure, thanks for advice.
c

Colton Idle

04/01/2023, 7:47 PM
thanks @curioustechizen i consider myself to be a pretty bad developer so that was a nice boost to my self esteem. cheers
17 Views