From an App architecture perspective in Kotlin, which is a better design approach: A) To have multiple activities in your app B) To have less activities and more fragments in your app.
Please advice. Thank You.
From an App architecture perspective in Kotlin, which is a better design approach: A) To have multiple activities in your app B) To have less activities and more fragments in your app.
Please advice. Thank You.
There is no single right way to go about this decision. Depending on your application, you should first choose an architecture that suits you best. Popular choices in Android include, but are not limited to, MVP (Model View Presenter) and MVVM (Model View View Model).
Once you make that decision, you can start thinking about which method works best for you. You don't have to decide between multiple activities and activity with multiple fragments. You can have both several activities, each of which may contain multiple fragments. With the new Navigation component, part of the Architecture components, Google offers easy ways to manage fragment transactions and the back stack, which proved to be painful for most developers in the past. So, managing fragments is as easy as managing activities and you can choose what works best for you, without worrying about transactions, back stacks, navigation etc.
Myself, I prefer using different activities for separate tasks. The login flow & settings belong in separate activities, while the main actions of the applications (once the user is logged in) are handled as different fragments in a single activity that implements the navigation component. This makes navigating between fragments easier and promotes separation of concern, separating different features in different views and presenters/view models.
Overall, this topic is very subjective and there is no correct way. As other users pointed out, there are many different topics that you can look at, read different opinions and decide what works best for you.
By the way, "From an App architecture perspective in Kotlin" - the programming language you are using should not affect your architecture decision.
It's an eternal question that was asked a lot of times. You'll probably won't find a definite answer. So you need to read about philosophy and decide for yourself what approach is better in your situation.