Hi guys, I am learning architecture and modulariza...
# android-architecture
k
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
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
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
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
Thanks for giving me great advice. What is 'UseCases' ?
d
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
sure, I'll take a look on architecture guide on more.
I really appreciate it.
c
Also a valid thing to do is to build sample apps with no real architecture and see where they start falling apart.
d
That's a great idea!
c
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
Sure, I'll keep in mind all these steps.. Thanks
c
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
Sure, thanks for advice.
c
thanks @curioustechizen i consider myself to be a pretty bad developer so that was a nice boost to my self esteem. cheers