Hi everyone! I've stumbled upon this old blog post...
# android
v
Hi everyone! I've stumbled upon this old blog post "Advocating Against Android Fragments" from 2014 which argues that dealing with Fragments is a nightmare and I am better off with custom views for everything. Is this still true in 2019? Did Google do anything to fix this? https://medium.com/square-corner-blog/advocating-against-android-fragments-81fd0b462c97
j
I would argue that Fragments are OK in most use cases. I would also say I’ve never experienced said nightmares in my roughly 10 years of doing android work.
👍 2
☝️ 1
m
If you plan on using Navigation Component, then fragment are the way to go, honestly custom views are not better to manage than fragments, and now with androidx, most fragments issues from the past have been fixed
d
I would say...depends. The 2014 problems is valid but we have now more tools to help us out on the final decision. I would create a fragment
r
Fragments today are much improved from their 2014 state, and there are a number of things that specifically address some of the issues from that blog post
r
2014 Android development ecosystem was in a different place. Things have improved since than. Fragments are the way to go for there usecase
p
I remember in 2014 when I read that article I did a big print of the Lifecycle Diagram. Every time I switched companies the first thing I did after being assigned an office was to print this Diagram and nail it in front of me. I love it. I agree with most people here that Fragments have improve and moving them out off the Framework also helps. But I still wonder where is the complexity to swap 2 Views in a Container Layout. Something that could be done with 2 lines of code in a ViewGroup calling removeChild/addChild methods was extremely over-architected with the Fragment API.
👍 1
c
some of the arguments are still true today (things like transaction exceptions, extra complicated lifecycles). I run into this tech talk

https://www.youtube.com/watch?v=RS1IACnZLy4

about fragments from Android Dev Summit ’19, which might be interesting to take a look tl;dr Android team is still working on improving it